Makefile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. SHELL = /bin/bash
  10. ifdef V
  11. Q =
  12. else
  13. Q = @
  14. endif
  15. sysv: validate profile-html
  16. $(Q)xsltproc --nonet \
  17. --output $(RENDERTMP)/lfs-html2.xml \
  18. --stringparam profile.revision sysv \
  19. stylesheets/lfs-xsl/profile.xsl \
  20. $(RENDERTMP)/lfs-html.xml
  21. @echo "Generating chunked XHTML files..."
  22. $(Q)xsltproc --nonet \
  23. --stringparam chunk.quietly $(CHUNK_QUIET) \
  24. --stringparam rootid "$(ROOT_ID)" \
  25. --stringparam base.dir $(BASEDIR)/ \
  26. stylesheets/lfs-chunked.xsl \
  27. $(RENDERTMP)/lfs-html2.xml
  28. @echo "Copying CSS code and images..."
  29. $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
  30. mkdir -p $(BASEDIR)/stylesheets; \
  31. fi;
  32. $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
  33. $(Q)pushd $(BASEDIR)/; sed -i -e "s@../stylesheets@stylesheets@g" *.html; popd
  34. $(Q)if [ ! -e $(BASEDIR)/images ]; then \
  35. mkdir -p $(BASEDIR)/images; \
  36. fi;
  37. $(Q)cp images/*.png $(BASEDIR)/images
  38. # $(Q)pushd $(BASEDIR)/; sed -i -e "s@../images@images@g" *.html; popd
  39. @echo "Running Tidy and obfuscate.sh..."
  40. $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
  41. tidy -config tidy.conf $$filename; \
  42. true; \
  43. /bin/bash obfuscate.sh $$filename; \
  44. sed -e "s@text/html@application/xhtml+xml@g" \
  45. -e "s/\xa9/\©/ " \
  46. -i $$filename; \
  47. done;
  48. $(Q)$(MAKE) $(BASEDIR)/wget-list $(BASEDIR)/md5sums
  49. systemd: validated profile-html
  50. $(Q)xsltproc --nonet \
  51. --output $(RENDERTMP)/lfs-html2.xml \
  52. --stringparam profile.revision systemd \
  53. stylesheets/lfs-xsl/profile.xsl \
  54. $(RENDERTMP)/lfs-html.xml
  55. @echo "Generating chunked XHTML files..."
  56. $(Q)xsltproc --nonet \
  57. --stringparam chunk.quietly $(CHUNK_QUIET) \
  58. --stringparam rootid "$(ROOT_ID)" \
  59. --stringparam base.dir $(SYSDDIR)/ \
  60. stylesheets/lfs-chunked.xsl \
  61. $(RENDERTMP)/lfs-html2.xml
  62. @echo "Copying CSS code and images..."
  63. $(Q)if [ ! -e $(SYSDDIR)/stylesheets ]; then \
  64. mkdir -p $(SYSDDIR)/stylesheets; \
  65. fi;
  66. $(Q)cp stylesheets/lfs-xsl/*.css $(SYSDDIR)/stylesheets
  67. $(Q)if [ ! -e $(SYSDDIR)/images ]; then \
  68. mkdir -p $(SYSDDIR)/images; \
  69. fi;
  70. $(Q)cp images/*.png $(SYSDDIR)/images
  71. @echo "Running Tidy and obfuscate.sh..."
  72. $(Q)for filename in `find $(SYSDDIR) -name "*.html"`; do \
  73. tidy -config tidy.conf $$filename; \
  74. true; \
  75. /bin/bash obfuscate.sh $$filename; \
  76. sed -e "s@text/html@application/xhtml+xml@g" \
  77. -e "s/\xa9/\©/ " \
  78. -i $$filename; \
  79. done;
  80. # $(Q)$(MAKE) $(SYSDDIR)/wget-list $(SYSDDIR)/md5sumsd
  81. pdf: validate
  82. @echo "Generating profiled XML for PDF..."
  83. $(Q)xsltproc --nonet --stringparam profile.condition pdf \
  84. --output $(RENDERTMP)/lfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \
  85. $(RENDERTMP)/lfs-full.xml
  86. @echo "Generating FO file..."
  87. $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
  88. --output $(RENDERTMP)/lfs-pdf.fo stylesheets/lfs-pdf.xsl \
  89. $(RENDERTMP)/lfs-pdf.xml
  90. $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
  91. $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
  92. @echo "Generating PDF file..."
  93. $(Q)if [ ! -e $(BASEDIR) ]; then \
  94. mkdir -p $(BASEDIR); \
  95. fi;
  96. $(Q)fop -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
  97. @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
  98. @echo "fop.log created"
  99. nochunks: validate profile-html
  100. @echo "Generating non chunked XHTML file..."
  101. $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
  102. --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
  103. stylesheets/lfs-nochunks.xsl $(RENDERTMP)/lfs-html.xml
  104. @echo "Running Tidy..."
  105. $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
  106. @echo "Running obfuscate.sh..."
  107. $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  108. $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  109. $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  110. $(Q)sed -i -e "s@../md5sums@md5sums@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
  111. $(Q)$(MAKE) $(BASEDIR)/wget-list $(BASEDIR)/md5sums
  112. tmpdir:
  113. @echo "Creating and cleaning $(RENDERTMP)"
  114. $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
  115. $(Q)rm -f $(RENDERTMP)/lfs-{full,html,pdf}.xml
  116. $(Q)rm -f $(RENDERTMP)/lfs-pdf.fo
  117. validate: tmpdir
  118. @echo "Processing bootscripts..."
  119. $(Q)bash process-scripts.sh
  120. @echo "Validating the book..."
  121. $(Q)xmllint --nonet --noent --xinclude --postvalid \
  122. -o $(RENDERTMP)/lfs-full.xml index.xml
  123. $(Q)rm -f appendices/*.script
  124. $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
  125. @echo "Validation complete."
  126. validated: tmpdir
  127. @echo "Validating the book..."
  128. $(Q)xmllint --nonet --noent --xinclude --postvalid \
  129. -o $(RENDERTMP)/lfs-full.xml indexd.xml
  130. @echo "Validation complete."
  131. profile-html:
  132. @echo "Generating profiled XML for XHTML..."
  133. $(Q)xsltproc --nonet --stringparam profile.condition html \
  134. --output $(RENDERTMP)/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
  135. $(RENDERTMP)/lfs-full.xml
  136. wget-list: $(BASEDIR)/wget-list
  137. $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent patches.ent
  138. @echo "Generating wget list..."
  139. $(Q)mkdir -p $(BASEDIR)
  140. $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
  141. stylesheets/wget-list.xsl chapter03/chapter03.xml
  142. md5sums: $(BASEDIR)/md5sums
  143. $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent patches.ent
  144. @echo "Generating md5sum file..."
  145. $(Q)mkdir -p $(BASEDIR)
  146. $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/md5sums \
  147. stylesheets/md5sum.xsl chapter03/chapter03.xml
  148. $(Q)sed -i -e \
  149. "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.bz2 | cut -d' ' -f1)/" \
  150. $(BASEDIR)/md5sums
  151. md5sumsd: $(SYSDDIR)/md5sumsd
  152. $(SYSDDIR)/md5sumsd: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent patches.ent
  153. @echo "Generating md5sum file..."
  154. $(Q)mkdir -p $(SYSDDIR)
  155. $(Q)xsltproc --xinclude --nonet --output $(SYSDDIR)/md5sums \
  156. stylesheets/md5sum.xsl chapter03/chapter03.xml
  157. dump-commands: validate
  158. @echo "Dumping book commands..."
  159. $(Q)xsltproc --output $(DUMPDIR)/ \
  160. stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
  161. all: lfs nochunks pdf dump-commands
  162. .PHONY : all dump-commands lfs nochunks pdf profile-html tmpdir validate