Makefile 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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)fop /tmp/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
  47. nochunks: validxml profile-html
  48. @echo "Generating non chunked XHTML file..."
  49. $(Q)xsltproc --nonet -stringparam profile.condition html \
  50. -stringparam rootid $(ROOT_ID) --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  51. stylesheets/lfs-nochunks.xsl /tmp/lfs-html.xml
  52. @echo "Running Tidy..."
  53. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  54. @echo "Running obfuscate.sh..."
  55. $(Q)sh obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  56. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
  57. $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  58. validxml:
  59. @echo "Validating the book..."
  60. $(Q)xmllint --nonet --noent --xinclude --postvalid \
  61. -o /tmp/lfs-full.xml index.xml
  62. profile-html: validxml
  63. @echo "Generating profiled XML for XHTML..."
  64. $(Q)xsltproc --nonet --stringparam profile.condition html \
  65. --output /tmp/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
  66. /tmp/lfs-full.xml
  67. wget-list:
  68. @echo "Generating wget list..."
  69. $(Q)mkdir -p $(BASEDIR)
  70. $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
  71. stylesheets/wget-list.xsl chapter03/chapter03.xml
  72. dump-commands: validxml
  73. @echo "Dumping book commands..."
  74. $(Q)xsltproc --output $(DUMPDIR)/ \
  75. stylesheets/dump-commands.xsl /tmp/lfs-full.xml
  76. validate:
  77. @echo "Validating the book..."
  78. $(Q)xmllint --noout --nonet --xinclude --postvalid index.xml
  79. all: lfs nochunks pdf dump-commands
  80. .PHONY : all dump-commands lfs nochunks pdf profile-html validate validxml wget-list