Makefile 7.7 KB

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