Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. $(Q)sed -i -e "s@../wget-list@wget-list@" \
  65. $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  66. $(Q)$(MAKE) wget-list
  67. tmpdir:
  68. @echo "Creating and cleaning $(RENDERTMP)"
  69. $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
  70. $(Q)rm -f $(RENDERTMP)/lfs-{full,html,pdf}.xml
  71. $(Q)rm -f $(RENDERTMP)/lfs-pdf.fo
  72. validxml: tmpdir
  73. @echo "Processing bootscripts..."
  74. $(Q)bash process-scripts.sh
  75. @echo "Validating the book..."
  76. $(Q)xmllint --nonet --noent --xinclude --postvalid \
  77. -o $(RENDERTMP)/lfs-full.xml index.xml
  78. $(Q)rm -f appendices/*.script
  79. $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
  80. maketar:
  81. $(Q)if [ "x$(MAKETAR)" == "x" ]; then \
  82. echo "Making tarballs..."; \
  83. sh make-aux-files.sh; \
  84. fi;
  85. profile-html: validxml
  86. @echo "Generating profiled XML for XHTML..."
  87. $(Q)xsltproc --nonet --stringparam profile.condition html \
  88. --output $(RENDERTMP)/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
  89. $(RENDERTMP)/lfs-full.xml
  90. wget-list:
  91. @echo "Generating wget list..."
  92. $(Q)mkdir -p $(BASEDIR)
  93. $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
  94. stylesheets/wget-list.xsl chapter03/chapter03.xml
  95. md5sums:
  96. @echo "Generating md5sum file..."
  97. $(Q)mkdir -p $(BASEDIR)
  98. $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/md5sums \
  99. stylesheets/md5sum.xsl chapter03/chapter03.xml
  100. $(Q)sed -i -e "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.bz2 | cut -d' ' -f1)/" \
  101. $(BASEDIR)/md5sums
  102. $(Q)sed -i -e "s/UDEV-MD5SUM/$(shell md5sum udev-config*.tar.bz2 | cut -d' ' -f1)/" \
  103. $(BASEDIR)/md5sums
  104. dump-commands: validxml
  105. @echo "Dumping book commands..."
  106. $(Q)xsltproc --output $(DUMPDIR)/ \
  107. stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
  108. validate: maketar validxml
  109. @echo "Validation complete."
  110. all: lfs nochunks pdf dump-commands md5sums
  111. .PHONY : all dump-commands lfs nochunks pdf profile-html tmpdir validate \
  112. validxml wget-list maketar md5sums