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