Makefile 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. #BASEDIR = ~/lfs-book
  2. #SYSDDIR = ~/lfs-systemd
  3. #DUMPDIR = ~/lfs-commands
  4. RENDERTMP = $(HOME)/tmp
  5. CHUNK_QUIET = 1
  6. ROOT_ID =
  7. SHELL = /bin/bash
  8. ifdef V
  9. Q =
  10. else
  11. Q = @
  12. endif
  13. ifndef REV
  14. REV = sysv
  15. endif
  16. ifneq ($(REV), sysv)
  17. ifneq ($(REV), systemd)
  18. $(error REV must be 'sysv' (default) or 'systemd'.)
  19. endif
  20. endif
  21. ifeq ($(REV), sysv)
  22. BASEDIR ?= ~/lfs-book
  23. PDF_OUTPUT ?= LFS-BOOK.pdf
  24. NOCHUNKS_OUTPUT ?= LFS-BOOK.html
  25. DUMPDIR ?= ~/lfs-commands
  26. else
  27. BASEDIR ?= ~/lfs-systemd
  28. PDF_OUTPUT ?= LFS-SYSD-BOOK.pdf
  29. NOCHUNKS_OUTPUT ?= LFS-SYSD-BOOK.html
  30. DUMPDIR ?= ~/lfs-sysd-commands
  31. endif
  32. book: validate profile-html
  33. @echo "Generating chunked XHTML files at $(BASEDIR)/ ..."
  34. $(Q)xsltproc --nonet \
  35. --stringparam chunk.quietly $(CHUNK_QUIET) \
  36. --stringparam rootid "$(ROOT_ID)" \
  37. --stringparam base.dir $(BASEDIR)/ \
  38. stylesheets/lfs-chunked.xsl \
  39. $(RENDERTMP)/lfs-html.xml
  40. @echo "Copying CSS code and images..."
  41. $(Q)mkdir -p $(BASEDIR)/stylesheets
  42. $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
  43. $(Q)pushd $(BASEDIR)/ > /dev/null; \
  44. sed -i -e "s@../stylesheets@stylesheets@g" *.html; \
  45. popd > /dev/null
  46. $(Q)mkdir -p $(BASEDIR)/images
  47. $(Q)cp images/*.png $(BASEDIR)/images
  48. @echo "Running Tidy and obfuscate.sh..."
  49. $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
  50. tidy -config tidy.conf $$filename; \
  51. true; \
  52. /bin/bash obfuscate.sh $$filename; \
  53. sed -e "s@text/html@application/xhtml+xml@g" \
  54. -e "s/\xa9/\©/ " \
  55. -i $$filename; \
  56. done;
  57. $(Q)$(MAKE) --no-print-directory wget-list md5sums
  58. pdf: validate
  59. @echo "Generating profiled XML for PDF..."
  60. $(Q)xsltproc --nonet \
  61. --stringparam profile.condition pdf \
  62. --output $(RENDERTMP)/lfs-pdf.xml \
  63. stylesheets/lfs-xsl/profile.xsl \
  64. $(RENDERTMP)/lfs-full.xml
  65. @echo "Generating FO file..."
  66. $(Q)xsltproc --nonet \
  67. --stringparam rootid "$(ROOT_ID)" \
  68. --output $(RENDERTMP)/lfs-pdf.fo \
  69. stylesheets/lfs-pdf.xsl \
  70. $(RENDERTMP)/lfs-pdf.xml
  71. $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
  72. $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
  73. @echo "Generating PDF file..."
  74. $(Q)mkdir -p $(RENDERTMP)/images
  75. $(Q)cp images/*.png $(RENDERTMP)/images
  76. $(Q)mkdir -p $(BASEDIR)
  77. $(Q)fop -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
  78. @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
  79. @echo "fop.log created"
  80. nochunks: validate profile-html
  81. @echo "Generating non chunked XHTML file..."
  82. $(Q)xsltproc --nonet \
  83. --stringparam rootid "$(ROOT_ID)" \
  84. --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  85. stylesheets/lfs-nochunks.xsl \
  86. $(RENDERTMP)/lfs-html2.xml
  87. @echo "Running Tidy..."
  88. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  89. @echo "Running obfuscate.sh..."
  90. $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  91. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  92. $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  93. $(Q)sed -i -e "s@../md5sums@md5sums@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  94. $(Q)sed -i -e "s@\xa9@\©@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  95. @echo "Output at $(BASEDIR)/$(NOCHUNKS_OUTPUT)"
  96. tmpdir:
  97. @echo "Creating and cleaning $(RENDERTMP)"
  98. $(Q)mkdir -p $(RENDERTMP)
  99. $(Q)rm -f $(RENDERTMP)/lfs*.xml
  100. $(Q)rm -f $(RENDERTMP)/*wget*
  101. $(Q)rm -f $(RENDERTMP)/*md5sum*
  102. $(Q)rm -f $(RENDERTMP)/*pdf.fo
  103. validate: tmpdir
  104. @echo "Processing bootscripts..."
  105. $(Q)bash process-scripts.sh
  106. @echo "Adjusting for revision $(REV)..."
  107. $(Q)xsltproc --nonet \
  108. --xinclude \
  109. --output $(RENDERTMP)/lfs-html2.xml \
  110. --stringparam profile.revision $(REV) \
  111. stylesheets/lfs-xsl/profile.xsl \
  112. index.xml
  113. @echo "Validating the book..."
  114. $(Q)xmllint --nonet \
  115. --noent \
  116. --postvalid \
  117. -o $(RENDERTMP)/lfs-full.xml \
  118. $(RENDERTMP)/lfs-html2.xml
  119. $(Q)rm -f appendices/*.script
  120. $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
  121. @echo "Validation complete."
  122. profile-html:
  123. @echo "Generating profiled XML for XHTML..."
  124. $(Q)xsltproc --nonet \
  125. --stringparam profile.condition html \
  126. --output $(RENDERTMP)/lfs-html.xml \
  127. stylesheets/lfs-xsl/profile.xsl \
  128. $(RENDERTMP)/lfs-full.xml
  129. wget-list: $(BASEDIR)/wget-list
  130. $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml \
  131. packages.ent patches.ent
  132. @echo "Generating consolidated wget list at $(BASEDIR)/wget-list ..."
  133. $(Q)mkdir -p $(BASEDIR)
  134. # $(Q)xsltproc --nonet --xinclude \
  135. # --stringparam profile.revision $(REV) \
  136. # --output $(RENDERTMP)/sysd-wget.xml \
  137. # stylesheets/lfs-xsl/profile.xsl \
  138. # chapter03/chapter03.xml
  139. $(Q)xsltproc --xinclude --nonet \
  140. --output $(BASEDIR)/wget-list \
  141. stylesheets/wget-list.xsl \
  142. chapter03/chapter03.xml
  143. md5sums: $(BASEDIR)/md5sums
  144. $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
  145. packages.ent patches.ent
  146. @echo "Generating consolidated md5sum file at $(BASEDIR)/md5sums ..."
  147. $(Q)mkdir -p $(BASEDIR)
  148. $(Q)xsltproc --nonet --xinclude \
  149. --stringparam profile.revision $(REV) \
  150. --output $(RENDERTMP)/sysv-md5sum.xml \
  151. stylesheets/lfs-xsl/profile.xsl \
  152. chapter03/chapter03.xml
  153. $(Q)xsltproc --xinclude --nonet \
  154. --output $(BASEDIR)/md5sums \
  155. stylesheets/md5sum.xsl \
  156. $(RENDERTMP)/sysv-md5sum.xml
  157. $(Q)sed -i -e \
  158. "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.xz | cut -d' ' -f1)/" \
  159. $(BASEDIR)/md5sums
  160. #dump-commands: validate
  161. # @echo "Dumping book commands..."
  162. # $(Q)xsltproc --nonet \
  163. # --output $(RENDERTMP)/lfs-html.xml \
  164. # --stringparam profile.revision $(REV) \
  165. # stylesheets/lfs-xsl/profile.xsl \
  166. # $(RENDERTMP)/lfs-full.xml
  167. # $(Q)rm -rf $(DUMPDIR)
  168. # $(Q)xsltproc --output $(DUMPDIR)/ \
  169. # stylesheets/dump-commands.xsl \
  170. # $(RENDERTMP)/lfs-html.xml
  171. # @echo "Dumping book commands complete in $(DUMPDIR)"
  172. all: book nochunks pdf # dump-commands
  173. .PHONY : all book dump-commands nochunks pdf profile-html tmpdir validate md5sums wget-list