Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. BASEDIR = ~/lfs-book
  2. SYSDDIR = ~/lfs-systemd
  3. DUMPDIR = ~/lfs-commands
  4. RENDERTMP = $(HOME)/tmp
  5. CHUNK_QUIET = 1
  6. ROOT_ID =
  7. PDF_OUTPUT = LFS-BOOK.pdf
  8. NOCHUNKS_OUTPUT = LFS-BOOK.html
  9. NOCHUNKS_SYSD_FILE = LFS-SYSD-BOOK.html
  10. SHELL = /bin/bash
  11. ifdef V
  12. Q =
  13. else
  14. Q = @
  15. endif
  16. sysv: validate profile-html
  17. $(Q)xsltproc --nonet \
  18. --output $(RENDERTMP)/lfs-html2.xml \
  19. --stringparam profile.revision sysv \
  20. stylesheets/lfs-xsl/profile.xsl \
  21. $(RENDERTMP)/lfs-html.xml
  22. @echo "Generating chunked XHTML files..."
  23. $(Q)xsltproc --nonet \
  24. --stringparam chunk.quietly $(CHUNK_QUIET) \
  25. --stringparam rootid "$(ROOT_ID)" \
  26. --stringparam base.dir $(BASEDIR)/ \
  27. stylesheets/lfs-chunked.xsl \
  28. $(RENDERTMP)/lfs-html2.xml
  29. @echo "Copying CSS code and images..."
  30. $(Q)mkdir -p $(BASEDIR)/stylesheets
  31. $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
  32. $(Q)pushd $(BASEDIR)/ > /dev/null; \
  33. sed -i -e "s@../stylesheets@stylesheets@g" *.html; \
  34. popd > /dev/null
  35. $(Q)mkdir -p $(BASEDIR)/images
  36. $(Q)cp images/*.png $(BASEDIR)/images
  37. @echo "Running Tidy and obfuscate.sh..."
  38. $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
  39. tidy -config tidy.conf $$filename; \
  40. true; \
  41. /bin/bash obfuscate.sh $$filename; \
  42. sed -e "s@text/html@application/xhtml+xml@g" \
  43. -e "s/\xa9/\©/ " \
  44. -i $$filename; \
  45. done;
  46. $(Q)$(MAKE) --no-print-directory wget-list md5sums
  47. systemd: validated profile-html
  48. $(Q)xsltproc --nonet \
  49. --output $(RENDERTMP)/lfs-html2.xml \
  50. --stringparam profile.revision systemd \
  51. stylesheets/lfs-xsl/profile.xsl \
  52. $(RENDERTMP)/lfs-html.xml
  53. @echo "Generating chunked XHTML files..."
  54. $(Q)xsltproc --nonet \
  55. --stringparam chunk.quietly $(CHUNK_QUIET) \
  56. --stringparam rootid "$(ROOT_ID)" \
  57. --stringparam base.dir $(SYSDDIR)/ \
  58. stylesheets/lfs-chunked.xsl \
  59. $(RENDERTMP)/lfs-html2.xml
  60. @echo "Copying CSS code and images..."
  61. $(Q)mkdir -p $(SYSDDIR)/stylesheets
  62. $(Q)cp stylesheets/lfs-xsl/*.css $(SYSDDIR)/stylesheets
  63. $(Q)mkdir -p $(SYSDDIR)/images
  64. $(Q)cp images/*.png $(SYSDDIR)/images
  65. @echo "Running Tidy and obfuscate.sh..."
  66. $(Q)for filename in `find $(SYSDDIR) -name "*.html"`; do \
  67. tidy -config tidy.conf $$filename; \
  68. true; \
  69. /bin/bash obfuscate.sh $$filename; \
  70. sed -e "s@text/html@application/xhtml+xml@g" \
  71. -e "s/\xa9/\©/ " \
  72. -i $$filename; \
  73. done;
  74. $(Q)$(MAKE) --no-print-directory wget-listd md5sumsd
  75. pdf: validate
  76. @echo "Generating profiled XML for PDF..."
  77. $(Q)xsltproc --nonet \
  78. --stringparam profile.condition pdf \
  79. --stringparam profile.revision sysv \
  80. --output $(RENDERTMP)/lfs-pdf.xml \
  81. stylesheets/lfs-xsl/profile.xsl \
  82. $(RENDERTMP)/lfs-full.xml
  83. @echo "Generating FO file..."
  84. $(Q)xsltproc --nonet \
  85. --stringparam rootid "$(ROOT_ID)" \
  86. --output $(RENDERTMP)/lfs-pdf.fo \
  87. stylesheets/lfs-pdf.xsl \
  88. $(RENDERTMP)/lfs-pdf.xml
  89. $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
  90. $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
  91. @echo "Generating PDF file..."
  92. $(Q)mkdir -p $(BASEDIR)
  93. $(Q)fop -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
  94. @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
  95. @echo "fop.log created"
  96. nochunks: validate profile-html
  97. $(Q)xsltproc --nonet \
  98. --output $(RENDERTMP)/lfs-html2.xml \
  99. --stringparam profile.revision sysv \
  100. stylesheets/lfs-xsl/profile.xsl \
  101. $(RENDERTMP)/lfs-html.xml
  102. @echo "Generating non chunked XHTML file..."
  103. $(Q)xsltproc --nonet \
  104. --stringparam rootid "$(ROOT_ID)" \
  105. --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  106. stylesheets/lfs-nochunks.xsl \
  107. $(RENDERTMP)/lfs-html2.xml
  108. @echo "Running Tidy..."
  109. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  110. @echo "Running obfuscate.sh..."
  111. $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  112. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  113. $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  114. $(Q)sed -i -e "s@../md5sums@md5sums@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  115. $(Q)sed -i -e "s@\xa9@\©@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  116. @echo "Output at $(BASEDIR)/$(NOCHUNKS_OUTPUT)"
  117. nochunksd: validated profile-html
  118. $(Q)xsltproc --nonet \
  119. --output $(RENDERTMP)/lfs-html2.xml \
  120. --stringparam profile.revision systemd \
  121. stylesheets/lfs-xsl/profile.xsl \
  122. $(RENDERTMP)/lfs-html.xml
  123. @echo "Generating non chunked XHTML file..."
  124. $(Q)xsltproc --nonet \
  125. --stringparam rootid "$(ROOT_ID)" \
  126. --output $(SYSDDIR)/$(NOCHUNKS_SYSD_FILE) \
  127. stylesheets/lfs-nochunks.xsl \
  128. $(RENDERTMP)/lfs-html2.xml
  129. @echo "Running Tidy..."
  130. $(Q)tidy -config tidy.conf $(SYSDDIR)/$(NOCHUNKS_SYSD_FILE) || true
  131. @echo "Running obfuscate.sh..."
  132. $(Q)bash obfuscate.sh $(SYSDDIR)/$(NOCHUNKS_SYSD_FILE)
  133. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(SYSDDIR)/$(NOCHUNKS_SYSD_FILE)
  134. $(Q)sed -i -e "s@../wget-list@wget-list@" $(SYSDDIR)/$(NOCHUNKS_SYSD_FILE)
  135. $(Q)sed -i -e "s@../md5sums@md5sums@" $(SYSDDIR)/$(NOCHUNKS_SYSD_FILE)
  136. $(Q)sed -i -e "s@\xa9@\©@" $(SYSDDIR)/$(NOCHUNKS_SYSD_FILE)
  137. @echo "Output at $(SYSDDIR)/$(NOCHUNKS_SYSD_FILE)"
  138. tmpdir:
  139. @echo "Creating and cleaning $(RENDERTMP)"
  140. $(Q)mkdir -p $(RENDERTMP)
  141. $(Q)rm -f $(RENDERTMP)/lfs*.xml
  142. $(Q)rm -f $(RENDERTMP)/sysd*.xml
  143. $(Q)rm -f $(RENDERTMP)/*pdf.fo
  144. validate: tmpdir
  145. @echo "Processing bootscripts..."
  146. $(Q)bash process-scripts.sh
  147. @echo "Validating the book..."
  148. $(Q)xmllint --nonet \
  149. --noent \
  150. --xinclude \
  151. --postvalid \
  152. -o $(RENDERTMP)/lfs-full.xml \
  153. index.xml
  154. $(Q)rm -f appendices/*.script
  155. $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
  156. @echo "Validation complete."
  157. validated: tmpdir
  158. @echo "Validating the book..."
  159. $(Q)xmllint --nonet \
  160. --noent \
  161. --xinclude \
  162. --postvalid \
  163. -o $(RENDERTMP)/lfs-full.xml \
  164. indexd.xml
  165. @echo "Validation complete."
  166. profile-html:
  167. @echo "Generating profiled XML for XHTML..."
  168. $(Q)xsltproc --nonet \
  169. --stringparam profile.condition html \
  170. --output $(RENDERTMP)/lfs-html.xml \
  171. stylesheets/lfs-xsl/profile.xsl \
  172. $(RENDERTMP)/lfs-full.xml
  173. wget-list: $(BASEDIR)/wget-list
  174. $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml \
  175. packages.ent patches.ent
  176. @echo "Generating wget list for sysv..."
  177. $(Q)mkdir -p $(BASEDIR)
  178. $(Q)xsltproc --nonet --xinclude \
  179. --stringparam profile.revision sysv \
  180. --output $(RENDERTMP)/sysd-wget.xml \
  181. stylesheets/lfs-xsl/profile.xsl \
  182. chapter03/chapter03.xml
  183. $(Q)xsltproc --xinclude --nonet \
  184. --output $(BASEDIR)/wget-list \
  185. stylesheets/wget-list.xsl \
  186. chapter03/chapter03.xml
  187. wget-listd: $(SYSDDIR)/wget-listd
  188. $(SYSDDIR)/wget-listd: stylesheets/wget-list.xsl chapter03/chapter03.xml \
  189. packages.ent patches.ent
  190. @echo "Generating wget list for systemd..."
  191. $(Q)mkdir -p $(SYSDDIR)
  192. $(Q)xsltproc --xinclude --nonet \
  193. --stringparam profile.revision systemd \
  194. --output $(RENDERTMP)/sysd-wget.xml \
  195. stylesheets/lfs-xsl/profile.xsl \
  196. chapter03/chapter03.xml
  197. $(Q)xsltproc --xinclude --nonet \
  198. --output $(SYSDDIR)/wget-list \
  199. stylesheets/wget-list.xsl \
  200. $(RENDERTMP)/sysd-wget.xml
  201. md5sums: $(BASEDIR)/md5sums
  202. $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
  203. packages.ent patches.ent
  204. @echo "Generating md5sum file for sysv..."
  205. $(Q)mkdir -p $(BASEDIR)
  206. $(Q)xsltproc --nonet --xinclude \
  207. --stringparam profile.revision sysv \
  208. --output $(RENDERTMP)/sysv-md5sum.xml \
  209. stylesheets/lfs-xsl/profile.xsl \
  210. chapter03/chapter03.xml
  211. $(Q)xsltproc --xinclude --nonet \
  212. --output $(BASEDIR)/md5sums \
  213. stylesheets/md5sum.xsl \
  214. $(RENDERTMP)/sysv-md5sum.xml
  215. $(Q)sed -i -e \
  216. "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.bz2 | cut -d' ' -f1)/" \
  217. $(BASEDIR)/md5sums
  218. md5sumsd: $(SYSDDIR)/md5sums
  219. $(SYSDDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
  220. packages.ent patches.ent
  221. @echo "Generating md5sum file for systemd..."
  222. $(Q)mkdir -p $(SYSDDIR)
  223. $(Q)xsltproc --nonet --xinclude \
  224. --stringparam profile.revision systemd \
  225. --output $(RENDERTMP)/sysd-md5sum.xml \
  226. stylesheets/lfs-xsl/profile.xsl \
  227. chapter03/chapter03.xml
  228. $(Q)xsltproc --xinclude --nonet \
  229. --output $(SYSDDIR)/md5sums \
  230. stylesheets/md5sum.xsl \
  231. $(RENDERTMP)/sysd-md5sum.xml
  232. dump-commands: validate
  233. @echo "Dumping book commands..."
  234. $(Q)xsltproc --nonet \
  235. --output $(RENDERTMP)/lfs-html.xml \
  236. --stringparam profile.revision sysv \
  237. stylesheets/lfs-xsl/profile.xsl \
  238. $(RENDERTMP)/lfs-full.xml
  239. $(Q)rm -rf $(DUMPDIR)
  240. $(Q)xsltproc --output $(DUMPDIR)/ \
  241. stylesheets/dump-commands.xsl \
  242. $(RENDERTMP)/lfs-html.xml
  243. @echo "Dumping book commands complete in $(DUMPDIR)"
  244. dump-commandsd: validated
  245. @echo "Dumping book commands..."
  246. $(Q)xsltproc --nonet \
  247. --output $(RENDERTMP)/lfs-html.xml \
  248. --stringparam profile.revision systemd \
  249. stylesheets/lfs-xsl/profile.xsl \
  250. $(RENDERTMP)/lfs-full.xml
  251. $(Q)rm -rf $(DUMPDIR)
  252. $(Q)xsltproc --output $(DUMPDIR)/ \
  253. stylesheets/dump-commands.xsl \
  254. $(RENDERTMP)/lfs-html.xml
  255. @echo "Dumping book commands complete in $(DUMPDIR)"
  256. all: lfs nochunks pdf dump-commands
  257. .PHONY : all sysv systemd dump-commands lfs nochunks pdf profile-html tmpdir validate