Makefile 7.6 KB

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