Makefile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. BASEDIR=~/lfs-book
  2. DUMPDIR=~/lfs-commands
  3. CHUNK_QUIET=1
  4. ROOT_ID=""
  5. PDF_OUTPUT=LFS-BOOK.pdf
  6. NOCHUNKS_OUTPUT=LFS-BOOK.html
  7. lfs: validxml profile-html
  8. @echo "Generating chunked XHTML files..."
  9. @xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
  10. -stringparam rootid $(ROOT_ID) -stringparam base.dir $(BASEDIR)/ \
  11. stylesheets/lfs-chunked.xsl /tmp/lfs-html.xml
  12. @echo "Copying CSS code and images..."
  13. @if [ ! -e $(BASEDIR)/stylesheets ]; then \
  14. mkdir -p $(BASEDIR)/stylesheets; \
  15. fi;
  16. @cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
  17. @if [ ! -e $(BASEDIR)/images ]; then \
  18. mkdir -p $(BASEDIR)/images; \
  19. fi;
  20. @cp images/*.png $(BASEDIR)/images
  21. @cd $(BASEDIR)/; sed -i -e "s@../stylesheets@stylesheets@g" *.html
  22. @cd $(BASEDIR)/; sed -i -e "s@../images@images@g" *.html
  23. @echo "Running Tidy..."
  24. @for filename in `find $(BASEDIR) -name "*.html"`; do \
  25. tidy -config tidy.conf $$filename; \
  26. true; \
  27. sh obfuscate.sh $$filename; \
  28. sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
  29. done;
  30. @$(MAKE) wget-list
  31. pdf: validxml
  32. @echo "Generating profiled XML for PDF..."
  33. @xsltproc --nonet --stringparam profile.condition pdf \
  34. --output /tmp/lfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \
  35. /tmp/lfs-full.xml
  36. @echo "Generating FO file..."
  37. @xsltproc --nonet -stringparam rootid $(ROOT_ID) \
  38. --output /tmp//lfs-pdf.fo stylesheets/lfs-pdf.xsl /tmp/lfs-pdf.xml
  39. @sed -i -e 's/span="inherit"/span="all"/' /tmp/lfs-pdf.fo
  40. @echo "Generating PDF file..."
  41. @fop /tmp/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
  42. nochunks: validxml profile-html
  43. @echo "Generating non chunked XHTML file..."
  44. @xsltproc --nonet -stringparam profile.condition html \
  45. -stringparam rootid $(ROOT_ID) --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  46. stylesheets/lfs-nochunks.xsl /tmp/lfs-html.xml
  47. @echo "Running Tidy..."
  48. @tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  49. @sh obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  50. @sed -i -e "s@text/html@application/xhtml+xml@g" \
  51. $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  52. validxml:
  53. @echo "Validating the book..."
  54. @xmllint --nonet --noent --xinclude --postvalid \
  55. -o /tmp/lfs-full.xml index.xml
  56. profile-html: validxml
  57. @echo "Generating profiled XML for XHTML..."
  58. @xsltproc --nonet --stringparam profile.condition html \
  59. --output /tmp/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
  60. /tmp/lfs-full.xml
  61. wget-list:
  62. @echo "Generating wget list..."
  63. @mkdir -p $(BASEDIR)
  64. @xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
  65. stylesheets/wget-list.xsl chapter03/chapter03.xml
  66. dump-commands:
  67. @echo "Dumping book commands..."
  68. @xsltproc --xinclude --nonet --output $(DUMPDIR)/ \
  69. stylesheets/dump-commands.xsl index.xml
  70. validate:
  71. @echo "Validating the book..."
  72. @xmllint --noout --nonet --xinclude --postvalid index.xml
  73. all: lfs nochunks pdf dump-commands
  74. .PHONY : all dump-commands lfs nochunks pdf profile-html validate validxml wget-list