Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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) $(BASEDIR)/wget-list $(BASEDIR)/md5sums
  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 -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
  54. @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
  55. @echo "fop.log created"
  56. nochunks: validate profile-html
  57. @echo "Generating non chunked XHTML file..."
  58. $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
  59. --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  60. stylesheets/lfs-nochunks.xsl $(RENDERTMP)/lfs-html.xml
  61. @echo "Running Tidy..."
  62. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  63. @echo "Running obfuscate.sh..."
  64. $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  65. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  66. $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  67. $(Q)$(MAKE) $(BASEDIR)/wget-list $(BASEDIR)/md5sums
  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. $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent
  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. $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent
  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 \
  98. "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.bz2 | cut -d' ' -f1)/" \
  99. $(BASEDIR)/md5sums
  100. dump-commands: validate
  101. @echo "Dumping book commands..."
  102. $(Q)xsltproc --output $(DUMPDIR)/ \
  103. stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
  104. all: lfs nochunks pdf dump-commands
  105. .PHONY : all dump-commands lfs nochunks pdf profile-html tmpdir validate