2004-02-01 11:47:51 +08:00
|
|
|
# Makefile for BLFS Book generation.
|
|
|
|
# By Tushar Teredesai <tushar@linuxfromscratch.org>
|
|
|
|
# 2004-01-31
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2004-02-01 11:47:51 +08:00
|
|
|
# Adjust these to suit your installation
|
2016-06-02 03:02:11 +08:00
|
|
|
RENDERTMP ?= $(HOME)/tmp
|
|
|
|
CHUNK_QUIET = 1
|
|
|
|
ROOT_ID =
|
|
|
|
SHELL = /bin/bash
|
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
|
|
|
|
|
2016-06-02 03:02:11 +08:00
|
|
|
ifndef REV
|
|
|
|
REV = sysv
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(REV), sysv)
|
|
|
|
ifneq ($(REV), systemd)
|
|
|
|
$(error REV must be 'sysv' (default) or 'systemd'.)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(REV), sysv)
|
|
|
|
BASEDIR ?= $(HOME)/public_html/blfs-book
|
|
|
|
NOCHUNKS_OUTPUT ?= blfs-book.html
|
|
|
|
DUMPDIR ?= ~/blfs-commands
|
2016-06-02 13:39:31 +08:00
|
|
|
BLFSHTML ?= blfs-html.xml
|
|
|
|
BLFSHTML2 ?= blfs-html2.xml
|
|
|
|
BLFSFULL ?= blfs-full.xml
|
2016-06-02 03:02:11 +08:00
|
|
|
else
|
|
|
|
BASEDIR ?= $(HOME)/public_html/blfs-systemd
|
|
|
|
NOCHUNKS_OUTPUT ?= blfs-sysd-book.html
|
|
|
|
DUMPDIR ?= ~/blfs-sysd-commands
|
2016-06-02 13:39:31 +08:00
|
|
|
BLFSHTML ?= blfs-systemd-html.xml
|
|
|
|
BLFSHTML2 ?= blfs-systemd-html2.xml
|
|
|
|
BLFSFULL ?= blfs-systemd-full.xml
|
|
|
|
|
2016-06-02 03:02:11 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
blfs: html wget-list
|
2016-06-02 03:02:11 +08:00
|
|
|
|
2021-07-17 19:44:23 +08:00
|
|
|
help:
|
|
|
|
@echo ""
|
|
|
|
@echo "make <parameters> <targets>"
|
|
|
|
@echo ""
|
|
|
|
@echo "Parameters:"
|
|
|
|
@echo " REV=<rev> Build variation of book"
|
|
|
|
@echo " Valid values for REV are:"
|
|
|
|
@echo " * sysv - Build book for SysV"
|
|
|
|
@echo " * systemd - Build book for systemd"
|
|
|
|
@echo " Defaults to 'sysv'"
|
|
|
|
@echo ""
|
|
|
|
@echo " BASEDIR=<dir> Put the output in directory <dir>."
|
|
|
|
@echo " Defaults to"
|
|
|
|
@echo " 'HOME/public_html/blfs-book' if REV=sysv (or unset)"
|
|
|
|
@echo " or to"
|
|
|
|
@echo " 'HOME/public_html/blfs-book-systemd' if REV=systemd"
|
|
|
|
@echo ""
|
|
|
|
@echo " V=<val> If <val> is a non-empty value, all"
|
|
|
|
@echo " steps to produce the output is shown."
|
|
|
|
@echo " Default is unset."
|
|
|
|
@echo ""
|
|
|
|
@echo "Targets:"
|
|
|
|
@echo " help Show this help text."
|
|
|
|
@echo ""
|
|
|
|
@echo " blfs Builds targets 'html' and 'wget-list'."
|
|
|
|
@echo ""
|
|
|
|
@echo " html Builds the HTML pages of the book."
|
|
|
|
@echo ""
|
|
|
|
@echo " wget-list Produces a list of all packages to download."
|
|
|
|
@echo " Output is BASEDIR/wget-list"
|
|
|
|
@echo ""
|
|
|
|
@echo " nochunks Builds the book as a one-pager. The output"
|
|
|
|
@echo " is a large single HTML page containing the"
|
|
|
|
@echo " whole book."
|
|
|
|
@echo ""
|
|
|
|
@echo " Parameter NOCHUNKS_OUTPUT=<filename> controls"
|
|
|
|
@echo " the name of the HTML file."
|
|
|
|
@echo ""
|
|
|
|
@echo " validate Runs validation checks on the XML files."
|
|
|
|
@echo ""
|
|
|
|
@echo " test-links Runs validation checks on URLs in the book."
|
|
|
|
@echo " Produces a file named BASEDIR/bad_urls containing"
|
|
|
|
@echo " URLS which are invalid and a BASEDIR/good_urls"
|
|
|
|
@echo " containing all valid URLs."
|
|
|
|
@echo ""
|
|
|
|
|
2012-08-23 00:33:50 +08:00
|
|
|
all: blfs nochunks
|
2008-04-09 01:32:00 +08:00
|
|
|
world: all blfs-patch-list dump-commands test-links
|
|
|
|
|
|
|
|
html: $(BASEDIR)/index.html
|
2021-04-15 17:31:50 +08:00
|
|
|
$(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML) version
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating chunked XHTML files..."
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)xsltproc --nonet \
|
|
|
|
--stringparam chunk.quietly $(CHUNK_QUIET) \
|
|
|
|
--stringparam rootid "$(ROOT_ID)" \
|
|
|
|
--stringparam base.dir $(BASEDIR)/ \
|
|
|
|
stylesheets/blfs-chunked.xsl \
|
2016-06-02 13:39:31 +08:00
|
|
|
$(RENDERTMP)/$(BLFSHTML)
|
2007-07-07 18:30:37 +08:00
|
|
|
|
|
|
|
@echo "Copying CSS code and images..."
|
|
|
|
$(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
2016-06-02 03:02:11 +08:00
|
|
|
mkdir -p $(BASEDIR)/stylesheets; \
|
|
|
|
fi;
|
|
|
|
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
2021-08-21 16:38:26 +08:00
|
|
|
$(Q)sed -i 's|../stylesheet|stylesheet|' $(BASEDIR)/index.html
|
2016-06-02 03:02:11 +08:00
|
|
|
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
2016-06-02 03:02:11 +08:00
|
|
|
mkdir -p $(BASEDIR)/images; \
|
|
|
|
fi;
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)cp images/*.png $(BASEDIR)/images
|
2016-06-02 03:02:11 +08:00
|
|
|
|
2019-09-14 01:00:08 +08:00
|
|
|
$(Q)cd $(BASEDIR)/; sed -e "s@../images@images@g" \
|
2016-06-02 03:02:11 +08:00
|
|
|
-i *.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..."
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
|
|
|
tidy -config tidy.conf $$filename; \
|
|
|
|
true; \
|
|
|
|
bash obfuscate.sh $$filename; \
|
|
|
|
sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
|
|
|
done;
|
2014-08-07 17:20:13 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
2021-04-15 17:31:50 +08:00
|
|
|
$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML) version
|
2008-04-09 01:32:23 +08:00
|
|
|
@echo "Generating non-chunked XHTML file..."
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)xsltproc --nonet \
|
|
|
|
--stringparam rootid "$(ROOT_ID)" \
|
|
|
|
--output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
|
|
|
stylesheets/blfs-nochunks.xsl \
|
2016-06-02 13:39:31 +08:00
|
|
|
$(RENDERTMP)/$(BLFSHTML)
|
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
|
2008-07-17 03:17:52 +08:00
|
|
|
$(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
2007-07-07 18:30:37 +08:00
|
|
|
|
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)"
|
2016-06-02 13:39:31 +08:00
|
|
|
$(Q)rm -f $(RENDERTMP)/blfs*
|
2007-07-07 23:53:24 +08:00
|
|
|
|
2016-06-02 13:39:31 +08:00
|
|
|
validate: $(RENDERTMP)/$(BLFSFULL)
|
2021-04-15 17:31:50 +08:00
|
|
|
$(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL) version
|
2008-04-09 01:32:00 +08:00
|
|
|
$(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
2016-06-02 03:02:11 +08:00
|
|
|
|
|
|
|
@echo "Adjusting for revision $(REV)..."
|
|
|
|
$(Q)xsltproc --nonet \
|
|
|
|
--xinclude \
|
2016-06-02 13:39:31 +08:00
|
|
|
--output $(RENDERTMP)/$(BLFSHTML2) \
|
2016-06-02 03:02:11 +08:00
|
|
|
--stringparam profile.revision $(REV) \
|
|
|
|
stylesheets/lfs-xsl/profile.xsl \
|
|
|
|
index.xml
|
|
|
|
|
|
|
|
@echo "Validating the book..."
|
|
|
|
$(Q)xmllint --nonet \
|
|
|
|
--noent \
|
|
|
|
--postvalid \
|
2016-06-02 13:39:31 +08:00
|
|
|
--output $(RENDERTMP)/$(BLFSFULL) \
|
|
|
|
$(RENDERTMP)/$(BLFSHTML2)
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2016-06-02 13:39:31 +08:00
|
|
|
profile-html: $(RENDERTMP)/$(BLFSHTML)
|
2021-04-15 17:31:50 +08:00
|
|
|
$(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL) version
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating profiled XML for XHTML..."
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)xsltproc --nonet \
|
|
|
|
--stringparam profile.condition html \
|
2016-06-02 13:39:31 +08:00
|
|
|
--output $(RENDERTMP)/$(BLFSHTML) \
|
2016-06-02 03:02:11 +08:00
|
|
|
stylesheets/lfs-xsl/profile.xsl \
|
2016-06-02 13:39:31 +08:00
|
|
|
$(RENDERTMP)/$(BLFSFULL)
|
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
|
|
|
|
|
2021-04-15 17:31:50 +08:00
|
|
|
blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL) version
|
2008-04-09 01:32:17 +08:00
|
|
|
@echo "Generating blfs patch script..."
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)xsltproc --nonet \
|
|
|
|
--output blfs-patches.sh \
|
|
|
|
stylesheets/patcheslist.xsl \
|
2016-06-02 13:39:31 +08:00
|
|
|
$(RENDERTMP)/$(BLFSFULL)
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
wget-list: $(BASEDIR)/wget-list
|
2021-04-15 17:31:50 +08:00
|
|
|
$(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL) version
|
2016-06-02 03:02:11 +08:00
|
|
|
@echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
|
2007-07-07 18:30:37 +08:00
|
|
|
$(Q)mkdir -p $(BASEDIR)
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)xsltproc --nonet \
|
|
|
|
--output $(BASEDIR)/wget-list \
|
|
|
|
stylesheets/wget-list.xsl \
|
2016-06-02 13:39:31 +08:00
|
|
|
$(RENDERTMP)/$(BLFSFULL)
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2008-05-11 23:42:15 +08:00
|
|
|
test-links: $(BASEDIR)/test-links
|
2021-04-15 17:31:50 +08:00
|
|
|
$(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL) version
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Generating test-links file..."
|
|
|
|
$(Q)mkdir -p $(BASEDIR)
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)xsltproc --nonet \
|
|
|
|
--stringparam list_mode full \
|
|
|
|
--output $(BASEDIR)/test-links \
|
|
|
|
stylesheets/wget-list.xsl \
|
2016-06-02 13:39:31 +08:00
|
|
|
$(RENDERTMP)/$(BLFSFULL)
|
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
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
|
|
|
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..."
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
|
|
|
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
|
2007-01-26 03:55:05 +08:00
|
|
|
|
2014-08-07 17:20:13 +08:00
|
|
|
bootscripts:
|
|
|
|
@VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
|
2016-06-02 03:02:11 +08:00
|
|
|
BOOTSCRIPTS="blfs-bootscripts-$$VERSION"; \
|
|
|
|
if [ ! -e $$BOOTSCRIPTS.tar.xz ]; then \
|
|
|
|
rm -rf $(RENDERTMP)/$$BOOTSCRIPTS; \
|
|
|
|
mkdir $(RENDERTMP)/$$BOOTSCRIPTS; \
|
|
|
|
cp -a ../bootscripts/* $(RENDERTMP)/$$BOOTSCRIPTS; \
|
|
|
|
rm -rf ../bootscripts/archive; \
|
|
|
|
tar -cJhf $$BOOTSCRIPTS.tar.xz -C $(RENDERTMP) $$BOOTSCRIPTS; \
|
2014-08-07 17:20:13 +08:00
|
|
|
fi
|
|
|
|
|
2016-06-02 13:39:31 +08:00
|
|
|
systemd-units:
|
|
|
|
@VERSION=`grep "systemd-units-version " general.ent | cut -d\" -f2`; \
|
|
|
|
UNITS="blfs-systemd-units-$$VERSION"; \
|
|
|
|
if [ ! -e $$UNITS.tar.xz ]; then \
|
|
|
|
rm -rf $(RENDERTMP)/$$UNITS; \
|
|
|
|
mkdir $(RENDERTMP)/$$UNITS; \
|
|
|
|
cp -a ../systemd-units/* $(RENDERTMP)/$$UNITS; \
|
|
|
|
tar -cJhf $$UNITS.tar.xz -C $(RENDERTMP) $$UNITS; \
|
|
|
|
fi
|
|
|
|
|
2008-04-09 01:32:00 +08:00
|
|
|
dump-commands: $(DUMPDIR)
|
2021-04-15 17:31:50 +08:00
|
|
|
$(DUMPDIR): $(RENDERTMP)/$(BLFSFULL) version
|
2007-07-07 18:30:37 +08:00
|
|
|
@echo "Dumping book commands..."
|
2016-06-02 03:02:11 +08:00
|
|
|
$(Q)xsltproc --output $(DUMPDIR)/ \
|
|
|
|
stylesheets/dump-commands.xsl \
|
2016-06-02 13:39:31 +08:00
|
|
|
$(RENDERTMP)/$(BLFSFULL)
|
2008-04-09 01:32:00 +08:00
|
|
|
$(Q)touch $(DUMPDIR)
|
2007-07-07 18:30:37 +08:00
|
|
|
|
2016-06-02 03:02:11 +08:00
|
|
|
.PHONY: blfs all world html nochunks tmpdir clean \
|
|
|
|
validate profile-html blfs-patch-list wget-list test-links \
|
2021-04-15 17:31:50 +08:00
|
|
|
dump-commands bootscripts systemd-units version
|
2014-08-07 17:20:13 +08:00
|
|
|
|
2021-04-15 17:31:50 +08:00
|
|
|
version:
|
|
|
|
$(Q)./git-version.sh
|