Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. BASEDIR = ~/lfs-book
  2. DUMPDIR = ~/lfs-commands
  3. RENDERTMP = $(HOME)/tmp
  4. CHUNK_QUIET = 1
  5. ROOT_ID =
  6. PDF_OUTPUT = LFS-BOOK.pdf
  7. NOCHUNKS_OUTPUT = LFS-BOOK.html
  8. ifdef V
  9. Q =
  10. else
  11. Q = @
  12. endif
  13. lfs: maketar validxml profile-html
  14. @echo "Generating chunked XHTML files..."
  15. $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
  16. -stringparam rootid "$(ROOT_ID)" -stringparam base.dir $(BASEDIR)/ \
  17. stylesheets/lfs-chunked.xsl $(RENDERTMP)/lfs-html.xml
  18. @echo "Copying CSS code and images..."
  19. $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
  20. mkdir -p $(BASEDIR)/stylesheets; \
  21. fi;
  22. $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
  23. $(Q)if [ ! -e $(BASEDIR)/images ]; then \
  24. mkdir -p $(BASEDIR)/images; \
  25. fi;
  26. $(Q)cp images/*.png $(BASEDIR)/images
  27. $(Q)cd $(BASEDIR)/; sed -i -e "s@../stylesheets@stylesheets@g" *.html
  28. $(Q)cd $(BASEDIR)/; sed -i -e "s@../images@images@g" *.html
  29. @echo "Running Tidy and obfuscate.sh..."
  30. $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
  31. tidy -config tidy.conf $$filename; \
  32. true; \
  33. /bin/bash obfuscate.sh $$filename; \
  34. sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
  35. done;
  36. $(Q)$(MAKE) wget-list
  37. pdf: validxml
  38. @echo "Generating profiled XML for PDF..."
  39. $(Q)xsltproc --nonet --stringparam profile.condition pdf \
  40. --output $(RENDERTMP)/lfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \
  41. $(RENDERTMP)/lfs-full.xml
  42. @echo "Generating FO file..."
  43. $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
  44. --output $(RENDERTMP)/lfs-pdf.fo stylesheets/lfs-pdf.xsl \
  45. $(RENDERTMP)/lfs-pdf.xml
  46. $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
  47. $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
  48. @echo "Generating PDF file..."
  49. $(Q)if [ ! -e $(BASEDIR) ]; then \
  50. mkdir -p $(BASEDIR); \
  51. fi;
  52. $(Q)fop $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
  53. nochunks: maketar validxml profile-html
  54. @echo "Generating non chunked XHTML file..."
  55. $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
  56. --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  57. stylesheets/lfs-nochunks.xsl $(RENDERTMP)/lfs-html.xml
  58. @echo "Running Tidy..."
  59. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  60. @echo "Running obfuscate.sh..."
  61. $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  62. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
  63. $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  64. tmpdir:
  65. @echo "Creating and cleaning $(RENDERTMP)"
  66. $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
  67. $(Q)rm -f $(RENDERTMP)/lfs-{full,html,pdf}.xml
  68. $(Q)rm -f $(RENDERTMP)/lfs-pdf.fo
  69. validxml: tmpdir
  70. @echo "Processing bootscripts..."
  71. $(Q)bash process-scripts.sh
  72. @echo "Validating the book..."
  73. $(Q)xmllint --nonet --noent --xinclude --postvalid \
  74. -o $(RENDERTMP)/lfs-full.xml index.xml
  75. $(Q)rm -f appendices/*.script
  76. $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
  77. maketar:
  78. @echo "Making tarballs..."
  79. $(Q)sh make-aux-files.sh
  80. profile-html: validxml
  81. @echo "Generating profiled XML for XHTML..."
  82. $(Q)xsltproc --nonet --stringparam profile.condition html \
  83. --output $(RENDERTMP)/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
  84. $(RENDERTMP)/lfs-full.xml
  85. wget-list:
  86. @echo "Generating wget list..."
  87. $(Q)mkdir -p $(BASEDIR)
  88. $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
  89. stylesheets/wget-list.xsl chapter03/chapter03.xml
  90. dump-commands: validxml
  91. @echo "Dumping book commands..."
  92. $(Q)xsltproc --output $(DUMPDIR)/ \
  93. stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
  94. validate: maketar validxml
  95. @echo "Validation complete."
  96. all: lfs nochunks pdf dump-commands
  97. .PHONY : all dump-commands lfs nochunks pdf profile-html tmpdir validate \
  98. validxml wget-list maketar