Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. @echo "Generating PDF file..."
  48. $(Q)if [ ! -e $(BASEDIR) ]; then \
  49. mkdir -p $(BASEDIR); \
  50. fi;
  51. $(Q)fop $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
  52. nochunks: validxml profile-html
  53. @echo "Generating non chunked XHTML file..."
  54. $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
  55. --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  56. stylesheets/lfs-nochunks.xsl $(RENDERTMP)/lfs-html.xml
  57. @echo "Running Tidy..."
  58. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  59. @echo "Running obfuscate.sh..."
  60. $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  61. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
  62. $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  63. tmpdir:
  64. @echo "Creating and cleaning $(RENDERTMP)"
  65. $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
  66. $(Q)rm -f $(RENDERTMP)/lfs-{full,html,pdf}.xml
  67. $(Q)rm -f $(RENDERTMP)/lfs-pdf.fo
  68. validxml: tmpdir
  69. @echo "Processing bootscripts..."
  70. $(Q)bash process-scripts.sh $(RENDERTMP)
  71. @echo "Validating the book..."
  72. $(Q)xmllint --nonet --noent --xinclude --postvalid \
  73. -o $(RENDERTMP)/lfs-full.xml index.xml
  74. $(Q)rm -f appendices/*.script
  75. $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
  76. maketar:
  77. @echo "Making tarballs..."
  78. $(Q)sh make-aux-files.sh $(RENDERTMP)
  79. profile-html: validxml
  80. @echo "Generating profiled XML for XHTML..."
  81. $(Q)xsltproc --nonet --stringparam profile.condition html \
  82. --output $(RENDERTMP)/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
  83. $(RENDERTMP)/lfs-full.xml
  84. wget-list:
  85. @echo "Generating wget list..."
  86. $(Q)mkdir -p $(BASEDIR)
  87. $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
  88. stylesheets/wget-list.xsl chapter03/chapter03.xml
  89. dump-commands: validxml
  90. @echo "Dumping book commands..."
  91. $(Q)xsltproc --output $(DUMPDIR)/ \
  92. stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
  93. validate: maketar validxml
  94. @echo "Validation complete."
  95. all: lfs nochunks pdf dump-commands
  96. .PHONY : all dump-commands lfs nochunks pdf profile-html tmpdir validate \
  97. validxml wget-list maketar