Makefile 3.1 KB

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