Makefile 7.0 KB

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