Makefile 4.0 KB

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