2004-02-01 11:47:51 +08:00
|
|
|
# Makefile for BLFS Book generation.
|
|
|
|
# By Tushar Teredesai <tushar@linuxfromscratch.org>
|
|
|
|
# 2004-01-31
|
2004-08-10 12:25:57 +08:00
|
|
|
# $LastChangedBy$
|
|
|
|
# $Date$
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2004-02-01 11:47:51 +08:00
|
|
|
# Adjust these to suit your installation
|
2008-04-09 01:32:06 +08:00
|
|
|
BASEDIR ?= $(HOME)/public_html/blfs-book-xsl
|
|
|
|
DUMPDIR ?= $(HOME)/blfs-commands
|
|
|
|
RENDERTMP ?= tmp
|
2007-07-10 13:06:58 +08:00
|
|
|
CHUNK_QUIET = 1
|
|
|
|
ROOT_ID =
|
|
|
|
PDF_OUTPUT = BLFS-BOOK.pdf
|
|
|
|
NOCHUNKS_OUTPUT = BLFS-BOOK.html
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-04-15 13:06:28 +08:00
|
|
|
ALLXML := $(filter-out $(RENDERTMP)/%, \
|
|
|
|
$(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
|
|
|
|
ALLXSL := $(filter-out $(RENDERTMP)/%, \
|
|
|
|
$(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
|
|
|
|
|
2007-07-07 18:30:37 +08:00
|
|
|
ifdef V
|
|
|
|
Q =
|
|
|
|
else
|
|
|
|
Q = @
|
|
|
|
endif
|
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
blfs: html wget-list
|
|
|
|
all: blfs nochunks pdf
|
|
|
|
world: all blfs-patch-list dump-commands test-links
|
|
|
|
|
|
|
|
html: $(BASEDIR)/index.html
|
|
|
|
$(BASEDIR)/index.html: $(RENDERTMP)/blfs-html.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating chunked XHTML files..."
|
|
|
|
$(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
|
2007-07-10 13:06:58 +08:00
|
|
|
-stringparam rootid "$(ROOT_ID)" -stringparam base.dir $(BASEDIR)/ \
|
2007-07-08 00:12:44 +08:00
|
|
|
stylesheets/blfs-chunked.xsl $(RENDERTMP)/blfs-html.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
|
|
|
|
@echo "Copying CSS code and images..."
|
|
|
|
$(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
2006-04-05 00:11:49 +08:00
|
|
|
mkdir -p $(BASEDIR)/stylesheets; \
|
2004-04-13 09:59:18 +08:00
|
|
|
fi;
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
|
|
|
$(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
2006-04-05 00:11:49 +08:00
|
|
|
mkdir -p $(BASEDIR)/images; \
|
2004-04-13 09:59:18 +08:00
|
|
|
fi;
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)cp images/*.png $(BASEDIR)/images
|
|
|
|
$(Q)cd $(BASEDIR)/; sed -i -e "s@../stylesheets@stylesheets@g" *.html
|
|
|
|
$(Q)cd $(BASEDIR)/; sed -i -e "s@../images@images@g" *.html
|
2005-08-30 05:32:10 +08:00
|
|
|
|
2008-04-09 01:32:23 +08:00
|
|
|
@echo "Running Tidy and obfuscate.sh on chunked XHTML..."
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
2005-08-30 05:32:10 +08:00
|
|
|
tidy -config tidy.conf $$filename; \
|
|
|
|
true; \
|
|
|
|
sh obfuscate.sh $$filename; \
|
|
|
|
sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
|
|
|
done;
|
2004-04-13 09:59:18 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
pdf: $(BASEDIR)/$(PDF_OUTPUT)
|
|
|
|
$(RENDERTMP)/blfs-pdf.xml: $(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating profiled XML for PDF..."
|
|
|
|
$(Q)xsltproc --nonet --stringparam profile.condition pdf \
|
2007-07-08 00:12:44 +08:00
|
|
|
--output $(RENDERTMP)/blfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \
|
|
|
|
$(RENDERTMP)/blfs-full.xml
|
2007-01-15 02:57:13 +08:00
|
|
|
|
2008-05-11 23:42:04 +08:00
|
|
|
$(RENDERTMP)/blfs-pdf.fo: $(RENDERTMP)/blfs-pdf.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating FO file..."
|
2007-07-11 03:10:04 +08:00
|
|
|
$(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
2008-04-09 01:32:00 +08:00
|
|
|
--output $(RENDERTMP)/blfs-pdf.fo stylesheets/blfs-pdf.xsl \
|
|
|
|
$(RENDERTMP)/blfs-pdf.xml
|
2007-07-08 00:12:44 +08:00
|
|
|
$(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/blfs-pdf.fo
|
2006-01-27 00:14:43 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
$(BASEDIR)/$(PDF_OUTPUT): $(RENDERTMP)/blfs-pdf.fo
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating PDF file..."
|
|
|
|
$(Q)if [ ! -e $(BASEDIR) ]; then \
|
|
|
|
mkdir -p $(BASEDIR); \
|
|
|
|
fi;
|
2007-07-08 00:12:44 +08:00
|
|
|
$(Q)fop $(RENDERTMP)/blfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
|
|
|
$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/blfs-html.xml
|
2008-04-09 01:32:23 +08:00
|
|
|
@echo "Generating non-chunked XHTML file..."
|
2007-07-11 03:10:04 +08:00
|
|
|
$(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
2007-07-07 22:53:28 +08:00
|
|
|
--output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
2007-07-08 00:12:44 +08:00
|
|
|
stylesheets/blfs-nochunks.xsl $(RENDERTMP)/blfs-html.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-04-09 01:32:23 +08:00
|
|
|
@echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
|
|
|
$(Q)sh obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
2008-04-09 01:32:23 +08:00
|
|
|
$(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
|
2007-07-07 18:30:37 +08:00
|
|
|
$(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
tmpdir: $(RENDERTMP)
|
|
|
|
$(RENDERTMP):
|
|
|
|
@echo "Creating $(RENDERTMP)"
|
2007-07-08 00:12:44 +08:00
|
|
|
$(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
2008-04-09 01:32:00 +08:00
|
|
|
|
|
|
|
clean:
|
|
|
|
@echo "Cleaning $(RENDERTMP)"
|
2007-07-08 04:19:17 +08:00
|
|
|
$(Q)rm -f $(RENDERTMP)/blfs-{full,html,pdf}.xml
|
|
|
|
$(Q)rm -f $(RENDERTMP)/blfs-pdf.fo
|
2007-07-08 00:12:44 +08:00
|
|
|
$(Q)rm -f $(RENDERTMP)/blfs-{patch-list,patches}
|
2008-04-09 01:32:12 +08:00
|
|
|
$(Q)rmdir $(RENDERTMP) 2>/dev/null || :
|
2007-07-07 23:53:24 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
validxml: $(RENDERTMP)/blfs-full.xml
|
2008-04-15 13:06:28 +08:00
|
|
|
$(RENDERTMP)/blfs-full.xml: general.ent $(ALLXML) $(ALLXSL)
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Validating the book..."
|
2008-04-09 01:32:00 +08:00
|
|
|
$(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)xmllint --nonet --noent --xinclude --postvalid \
|
2007-07-08 00:42:55 +08:00
|
|
|
-o $(RENDERTMP)/blfs-full.xml index.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
profile-html: $(RENDERTMP)/blfs-html.xml
|
|
|
|
$(RENDERTMP)/blfs-html.xml: $(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating profiled XML for XHTML..."
|
|
|
|
$(Q)xsltproc --nonet --stringparam profile.condition html \
|
2007-07-08 00:12:44 +08:00
|
|
|
--output $(RENDERTMP)/blfs-html.xml stylesheets/lfs-xsl/profile.xsl \
|
|
|
|
$(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-04-09 01:32:17 +08:00
|
|
|
blfs-patch-list: blfs-patches.sh
|
|
|
|
@echo "Generating blfs patch list..."
|
|
|
|
$(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
|
|
|
blfs-patches.sh > blfs-patch-list
|
|
|
|
|
|
|
|
blfs-patches.sh: $(RENDERTMP)/blfs-full.xml
|
|
|
|
@echo "Generating blfs patch script..."
|
|
|
|
$(Q)xsltproc --nonet --output blfs-patches.sh \
|
2007-07-08 00:12:44 +08:00
|
|
|
stylesheets/patcheslist.xsl $(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
wget-list: $(BASEDIR)/wget-list
|
|
|
|
$(BASEDIR)/wget-list: $(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating wget list..."
|
|
|
|
$(Q)mkdir -p $(BASEDIR)
|
|
|
|
$(Q)xsltproc --nonet --output $(BASEDIR)/wget-list \
|
2007-07-08 00:12:44 +08:00
|
|
|
stylesheets/wget-list.xsl $(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
test-links: $(RENDERTMP)/blfs-full.xml
|
|
|
|
$(BASEDIR)/test-links: $(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating test-links file..."
|
|
|
|
$(Q)mkdir -p $(BASEDIR)
|
|
|
|
$(Q)xsltproc --nonet --stringparam list_mode full \
|
|
|
|
--output $(BASEDIR)/test-links stylesheets/wget-list.xsl \
|
2007-07-08 00:12:44 +08:00
|
|
|
$(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2007-07-07 21:26:44 +08:00
|
|
|
@echo "Checking URLs, first pass..."
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
|
|
|
|
$(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
2007-01-26 03:55:05 +08:00
|
|
|
wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
|
|
|
|
if test $$? -ne 0 ; then echo $$URL >> $(BASEDIR)/bad_urls ; \
|
|
|
|
else echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
|
|
|
|
fi; \
|
|
|
|
done
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2007-07-07 21:26:44 +08:00
|
|
|
@echo "Checking URLs, second pass..."
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
2007-01-26 03:55:05 +08:00
|
|
|
wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
|
|
|
|
if test $$? -ne 0 ; then echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
|
|
|
|
else echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
|
|
|
|
fi; \
|
|
|
|
done
|
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
dump-commands: $(DUMPDIR)
|
|
|
|
$(DUMPDIR): $(RENDERTMP)/blfs-full.xml
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Dumping book commands..."
|
|
|
|
$(Q)xsltproc --output $(DUMPDIR)/ \
|
2007-07-08 00:12:44 +08:00
|
|
|
stylesheets/dump-commands.xsl $(RENDERTMP)/blfs-full.xml
|
2008-04-09 01:32:00 +08:00
|
|
|
$(Q)touch $(DUMPDIR)
|
2007-07-07 18:30:37 +08:00
|
|
|
|
|
|
|
validate:
|
|
|
|
@echo "Validating the book..."
|
|
|
|
$(Q)xmllint --noout --nonet --xinclude --postvalid index.xml
|
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
.PHONY: blfs all world html pdf nochunks tmpdir clean validxml \
|
|
|
|
profile-html wget-list test-links dump-commands validate
|