Makefile 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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-html.xml
  99. # $(RENDERTMP)/lfs-html2.xml
  100. @echo "Running Tidy..."
  101. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  102. @echo "Running obfuscate.sh..."
  103. $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  104. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  105. $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  106. $(Q)sed -i -e "s@../md5sums@md5sums@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  107. $(Q)sed -i -e "s@\xa9@\©@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  108. @echo "Output at $(BASEDIR)/$(NOCHUNKS_OUTPUT)"
  109. tmpdir:
  110. @echo "Creating and cleaning $(RENDERTMP)"
  111. $(Q)mkdir -p $(RENDERTMP)
  112. $(Q)rm -f $(RENDERTMP)/lfs*.xml
  113. $(Q)rm -f $(RENDERTMP)/*wget*
  114. $(Q)rm -f $(RENDERTMP)/*md5sum*
  115. $(Q)rm -f $(RENDERTMP)/*pdf.fo
  116. validate: tmpdir
  117. @echo "Processing bootscripts..."
  118. $(Q)bash process-scripts.sh
  119. @echo "Adjusting for revision $(REV)..."
  120. $(Q)xsltproc --nonet \
  121. --xinclude \
  122. --output $(RENDERTMP)/lfs-html2.xml \
  123. --stringparam profile.revision $(REV) \
  124. --stringparam profile.arch $(ARCH) \
  125. stylesheets/lfs-xsl/profile.xsl \
  126. index.xml
  127. @echo "Validating the book..."
  128. $(Q)xmllint --nonet \
  129. --noent \
  130. --postvalid \
  131. -o $(RENDERTMP)/lfs-full.xml \
  132. $(RENDERTMP)/lfs-html2.xml
  133. $(Q)rm -f appendices/*.script
  134. $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
  135. @echo "Validation complete."
  136. profile-html:
  137. @echo "Generating profiled XML for XHTML..."
  138. $(Q)xsltproc --nonet \
  139. --stringparam profile.condition html \
  140. --output $(RENDERTMP)/lfs-html.xml \
  141. stylesheets/lfs-xsl/profile.xsl \
  142. $(RENDERTMP)/lfs-full.xml
  143. wget-list: $(BASEDIR)/wget-list
  144. $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml \
  145. packages.ent patches.ent
  146. @echo "Generating consolidated wget list at $(BASEDIR)/wget-list ..."
  147. $(Q)mkdir -p $(BASEDIR)
  148. # $(Q)xsltproc --nonet --xinclude \
  149. # --stringparam profile.revision $(REV) \
  150. # --stringparam profile.arch $(ARCH) \
  151. # --output $(RENDERTMP)/sysd-wget.xml \
  152. # stylesheets/lfs-xsl/profile.xsl \
  153. # chapter03/chapter03.xml
  154. $(Q)xsltproc --xinclude --nonet \
  155. --output $(BASEDIR)/wget-list \
  156. stylesheets/wget-list.xsl \
  157. chapter03/chapter03.xml
  158. md5sums: $(BASEDIR)/md5sums
  159. $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
  160. packages.ent patches.ent
  161. @echo "Generating consolidated md5sum file at $(BASEDIR)/md5sums ..."
  162. $(Q)mkdir -p $(BASEDIR)
  163. $(Q)xsltproc --nonet --xinclude \
  164. --stringparam profile.revision $(REV) \
  165. --stringparam profile.arch $(ARCH) \
  166. --output $(RENDERTMP)/sysv-md5sum.xml \
  167. stylesheets/lfs-xsl/profile.xsl \
  168. chapter03/chapter03.xml
  169. $(Q)xsltproc --xinclude --nonet \
  170. --output $(BASEDIR)/md5sums \
  171. stylesheets/md5sum.xsl \
  172. $(RENDERTMP)/sysv-md5sum.xml
  173. $(Q)sed -i -e \
  174. "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.xz | cut -d' ' -f1)/" \
  175. $(BASEDIR)/md5sums
  176. #dump-commands: validate
  177. # @echo "Dumping book commands..."
  178. # $(Q)xsltproc --nonet \
  179. # --output $(RENDERTMP)/lfs-html.xml \
  180. # --stringparam profile.revision $(REV) \
  181. # --stringparam profile.arch $(ARCH) \
  182. # stylesheets/lfs-xsl/profile.xsl \
  183. # $(RENDERTMP)/lfs-full.xml
  184. # $(Q)rm -rf $(DUMPDIR)
  185. # $(Q)xsltproc --output $(DUMPDIR)/ \
  186. # stylesheets/dump-commands.xsl \
  187. # $(RENDERTMP)/lfs-html.xml
  188. # @echo "Dumping book commands complete in $(DUMPDIR)"
  189. all: book nochunks pdf # dump-commands
  190. .PHONY : all book dump-commands nochunks pdf profile-html tmpdir validate md5sums wget-list