Makefile 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 ?= ~/cross-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)mkdir -p $(BASEDIR)/images
  56. $(Q)cp images/*.png $(BASEDIR)/images
  57. @echo "Running Tidy and obfuscate.sh..."
  58. $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
  59. tidy -config tidy.conf $$filename; \
  60. true; \
  61. /bin/bash obfuscate.sh $$filename; \
  62. sed -e "s@text/html@application/xhtml+xml@g" \
  63. -e "s/\xa9/\©/ " \
  64. -i $$filename; \
  65. done;
  66. $(Q)$(MAKE) --no-print-directory wget-list md5sums
  67. pdf: validate
  68. @echo "Generating profiled XML for PDF..."
  69. $(Q)xsltproc --nonet \
  70. --stringparam profile.condition pdf \
  71. --output $(RENDERTMP)/lfs-pdf.xml \
  72. stylesheets/lfs-xsl/profile.xsl \
  73. $(RENDERTMP)/lfs-full.xml
  74. @echo "Generating FO file..."
  75. $(Q)xsltproc --nonet \
  76. --stringparam rootid "$(ROOT_ID)" \
  77. --output $(RENDERTMP)/lfs-pdf.fo \
  78. stylesheets/lfs-pdf.xsl \
  79. $(RENDERTMP)/lfs-pdf.xml
  80. $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
  81. $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
  82. @echo "Generating PDF file..."
  83. $(Q)mkdir -p $(RENDERTMP)/images
  84. $(Q)cp images/*.png $(RENDERTMP)/images
  85. $(Q)mkdir -p $(BASEDIR)
  86. $(Q)fop -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
  87. @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
  88. @echo "fop.log created"
  89. nochunks: validate profile-html
  90. @echo "Generating non chunked XHTML file..."
  91. $(Q)xsltproc --nonet \
  92. --stringparam rootid "$(ROOT_ID)" \
  93. --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  94. stylesheets/lfs-nochunks.xsl \
  95. $(RENDERTMP)/lfs-html.xml
  96. # $(RENDERTMP)/lfs-html2.xml
  97. @echo "Running Tidy..."
  98. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  99. @echo "Running obfuscate.sh..."
  100. $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  101. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  102. $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  103. $(Q)sed -i -e "s@../md5sums@md5sums@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  104. $(Q)sed -i -e "s@\xa9@\©@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  105. @echo "Output at $(BASEDIR)/$(NOCHUNKS_OUTPUT)"
  106. tmpdir:
  107. @echo "Creating and cleaning $(RENDERTMP)"
  108. $(Q)mkdir -p $(RENDERTMP)
  109. $(Q)rm -f $(RENDERTMP)/lfs*.xml
  110. $(Q)rm -f $(RENDERTMP)/*wget*
  111. $(Q)rm -f $(RENDERTMP)/*md5sum*
  112. $(Q)rm -f $(RENDERTMP)/*pdf.fo
  113. validate: tmpdir
  114. @echo "Processing bootscripts..."
  115. $(Q)bash process-scripts.sh
  116. @echo "Adjusting for revision $(REV)..."
  117. $(Q)xsltproc --nonet \
  118. --xinclude \
  119. --output $(RENDERTMP)/lfs-html2.xml \
  120. --stringparam profile.revision $(REV) \
  121. --stringparam profile.arch $(ARCH) \
  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. --stringparam profile.arch $(ARCH) \
  162. --output $(RENDERTMP)/sysv-md5sum.xml \
  163. stylesheets/lfs-xsl/profile.xsl \
  164. chapter03/chapter03.xml
  165. $(Q)xsltproc --xinclude --nonet \
  166. --output $(BASEDIR)/md5sums \
  167. stylesheets/md5sum.xsl \
  168. $(RENDERTMP)/sysv-md5sum.xml
  169. $(Q)sed -i -e \
  170. "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.xz | cut -d' ' -f1)/" \
  171. $(BASEDIR)/md5sums
  172. #dump-commands: validate
  173. # @echo "Dumping book commands..."
  174. # $(Q)xsltproc --nonet \
  175. # --output $(RENDERTMP)/lfs-html.xml \
  176. # --stringparam profile.revision $(REV) \
  177. # stylesheets/lfs-xsl/profile.xsl \
  178. # $(RENDERTMP)/lfs-full.xml
  179. # $(Q)rm -rf $(DUMPDIR)
  180. # $(Q)xsltproc --output $(DUMPDIR)/ \
  181. # stylesheets/dump-commands.xsl \
  182. # $(RENDERTMP)/lfs-html.xml
  183. # @echo "Dumping book commands complete in $(DUMPDIR)"
  184. all: book nochunks pdf # dump-commands
  185. .PHONY : all book dump-commands nochunks pdf profile-html tmpdir validate md5sums wget-list