mirror of https://github.com/tLDP/LDP
initial commit of some tools for building entire LDP output tree
This commit is contained in:
parent
538ccf9083
commit
c1dc81cc1a
|
@ -0,0 +1,272 @@
|
|||
# -- Makefile for handling TLDP documentation
|
||||
#
|
||||
#
|
||||
|
||||
default: all
|
||||
|
||||
DESTDIR := output
|
||||
NODESTDIR := $(shell stat 2>/dev/null -t $(DESTDIR))
|
||||
ifeq ($(NODESTDIR),)
|
||||
$(error ENOENT (2): $(DESTDIR); please create or specify alternate DESTDIR directory)
|
||||
endif
|
||||
|
||||
WORKING := working
|
||||
NOWORKING := $(shell stat 2>/dev/null -t $(WORKING))
|
||||
ifeq ($(NOWORKING),)
|
||||
$(error ENOENT (2): $(WORKING); please create or specify alternate WORKING directory)
|
||||
endif
|
||||
|
||||
ifeq ($(OBJ),)
|
||||
$(error OBJ not specified, please supply a DocBook SGML source file)
|
||||
endif
|
||||
|
||||
FLAVOR=$(shell awk -F= '/^ID=/{print $$2}' /etc/os-release)
|
||||
ifeq ($(FLAVOR),ubuntu)
|
||||
# -- Ubuntu:
|
||||
# -- for DocBook SGML (DSSSL) processing
|
||||
LDPDSL := /usr/share/sgml/docbook/stylesheet/dsssl/ldp/ldp.dsl
|
||||
DBDSL := /usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl
|
||||
COLLATE := /usr/bin/collateindex.pl
|
||||
# -- for DocBook XML (XSLT layer) processing
|
||||
XSLCHUNK := /usr/share/xml/docbook/stylesheet/ldp/html/tldp-sections.xsl
|
||||
XSLSINGLE := /usr/share/xml/docbook/stylesheet/ldp/html/tldp-one-page.xsl
|
||||
XSLPRINT := /usr/share/xml/docbook/stylesheet/ldp/fo/tldp-print.xsl
|
||||
else ifeq ($(FLAVOR),opensuse)
|
||||
# -- OpenSUSE-13.2
|
||||
# -- for DocBook SGML (DSSSL) processing
|
||||
DBDSL := /usr/share/sgml/docbook/dsssl-stylesheets-1.79/html/docbook.dsl
|
||||
COLLATE := /usr/share/sgml/docbook/dsssl-stylesheets-1.79/bin/collateindex.pl
|
||||
LDPDSL := /home/mabrown/vcs/LDP/LDP/builder/dsssl/ldp.dsl
|
||||
# -- for DocBook XML (XSLT layer) processing
|
||||
XSLCHUNK := /home/mabrown/vcs/LDP/LDP/builder/xsl/ldp-html-chunk.xsl
|
||||
XSLSINGLE := /home/mabrown/vcs/LDP/LDP/builder/xsl/ldp-html.xsl
|
||||
XSLPRINT := /home/mabrown/vcs/LDP/LDP/builder/xsl/ldp-print.xsl
|
||||
else
|
||||
$(error Sorry, unknown/untested flavor of Linux, $(FLAVOR))
|
||||
endif
|
||||
|
||||
# -- standard definitions and other little tools
|
||||
#
|
||||
XML_CATALOG_FILES := /etc/xml/catalog
|
||||
PERL := $(shell which perl 2>/dev/null)
|
||||
VERBOSE :=
|
||||
|
||||
OBJDIR := $(dir $(OBJ))
|
||||
OBJFORMAT := $(lastword $(subst ., ,$(suffix $(OBJ))))
|
||||
OBJFILE := $(notdir $(OBJ))
|
||||
OBJSTEM := $(OBJFILE:.$(OBJFORMAT)=)
|
||||
OBJINDEX := $(abspath $(OBJDIR)/index.sgml)
|
||||
|
||||
ifeq ($(OBJFORMAT),sgml)
|
||||
LINUXDOC := $(shell head -n 5 "$(OBJ)" | tr A-Z a-z | awk '/doctype linuxdoc system/{ print $$2}')
|
||||
ifeq ($(LINUXDOC),linuxdoc)
|
||||
OBJFORMAT = linuxdoc
|
||||
endif
|
||||
endif
|
||||
|
||||
OUTDIR = $(abspath $(abspath $(WORKING))/$(OBJSTEM))
|
||||
|
||||
FO = $(abspath $(OUTDIR)/$(OBJSTEM).fo)
|
||||
PDF = $(abspath $(OUTDIR)/$(OBJSTEM).pdf)
|
||||
HTML = $(abspath $(OUTDIR)/$(OBJSTEM).html)
|
||||
HTMLS = $(abspath $(OUTDIR)/$(OBJSTEM)-single.html)
|
||||
TEXT = $(abspath $(OUTDIR)/$(OBJSTEM).txt)
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# generic targets
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
all: clear_$(OUTDIR) $(OBJFORMAT)-all
|
||||
rsync $(VERBOSE) --archive --delay-updates --delete-after --partial $(OUTDIR)/ $(DESTDIR)/$(OBJSTEM)/
|
||||
|
||||
clear_$(OUTDIR):
|
||||
(test ! -d $(OUTDIR) || ( cd $(dir $(OUTDIR)) && rm -rf $(VERBOSE) -- $(notdir $(OUTDIR))))
|
||||
|
||||
$(OUTDIR): $(WORKING)
|
||||
mkdir $(OUTDIR)
|
||||
|
||||
$(OUTDIR)/images $(OUTDIR)/resources: $(OUTDIR)
|
||||
(cd $(OBJDIR) && test ! -d $(notdir $@) || rsync -aL $(VERBOSE) ./$(notdir $@) $(OUTDIR))
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# specific handling for DocBook SGML documents
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
.PHONY: sgml-all
|
||||
sgml-all: sgml-$(OBJINDEX) sgml-$(HTMLS) sgml-$(TEXT) sgml-$(PDF) sgml-$(HTML)
|
||||
rm -f -- "$(OBJINDEX)"
|
||||
|
||||
.PHONY: sgml-$(OBJINDEX)
|
||||
sgml-$(OBJINDEX): $(OUTDIR)/images $(OUTDIR)/resources
|
||||
(cd $(OUTDIR) \
|
||||
&& $(PERL) $(COLLATE) -N -o "$(OBJINDEX)" \
|
||||
&& openjade -t sgml -V html-index -d "$(DBDSL)" "$(OBJ)" \
|
||||
&& $(PERL) $(COLLATE) -g -t Index -i doc-index -o "$(notdir $(OBJINDEX))" HTML.index "$(OBJ)" \
|
||||
&& mv -f $(VERBOSE) -- $(notdir $(OBJINDEX)) $(dir $(OBJINDEX)) \
|
||||
&& find . -mindepth 1 -maxdepth 1 -type f -print0 | xargs --null --no-run-if-empty -- rm -f --)
|
||||
|
||||
.PHONY: sgml-$(HTMLS)
|
||||
sgml-$(HTMLS): $(OUTDIR)/resources $(OUTDIR)/images $(INDEX)
|
||||
# -- note the mv -vu $(notdir $(HTML)) $(notdir $(HTMLS))
|
||||
# the docbook2html processor will create a single-page
|
||||
# HTML file called $(OBJSTEM).html. We want to name it
|
||||
# $(OBJSTEM)-single.html, so that, later, $(OBJSTEM).html
|
||||
# can be the main output for chunked HTML
|
||||
#
|
||||
(cd $(OUTDIR) \
|
||||
&& jw -f docbook -b html \
|
||||
--dsl "$(LDPDSL)#html" \
|
||||
-V nochunks \
|
||||
-V '%callout-graphics-path%=images/callouts/' \
|
||||
-V '%stock-graphics-extension%=.png' \
|
||||
-V '%stylsheet-type%=freddie.css' \
|
||||
--output . \
|
||||
$(OBJ) \
|
||||
&& mv --update $(VERBOSE) -- $(notdir $(HTML)) $(notdir $(HTMLS)))
|
||||
|
||||
.PHONY: sgml-$(TEXT)
|
||||
sgml-$(TEXT): sgml-$(HTMLS)
|
||||
(cd $(OUTDIR) && html2text -style pretty -nobs $(notdir $(HTMLS)) > $(notdir $@))
|
||||
|
||||
.PHONY: sgml-$(PDF)
|
||||
sgml-$(PDF): $(OUTDIR)
|
||||
( cd $(OUTDIR) \
|
||||
&& jw -f docbook -b pdf --output . $(OBJ) \
|
||||
|| dblatex -F sgml -t pdf -o sgml-$(PDF) $(OBJ))
|
||||
|
||||
.PHONY: sgml-$(HTML)
|
||||
sgml-$(HTML): $(OUTDIR)
|
||||
# -- the jade DocBook processing toolchain produces an HTML output
|
||||
# file called index.html in the chunked output; therefore, we want
|
||||
# to create a link from Some-Name.html to index.html; if TLDP
|
||||
# wishes to do something else with index.html, this is the place
|
||||
# to change it (for SGML DocBook inputs, anyway).
|
||||
#
|
||||
( cd $(OUTDIR) \
|
||||
&& jw -f docbook -b html \
|
||||
--dsl "$(LDPDSL)#html" \
|
||||
-V '%admon-graphics-path%=images/' \
|
||||
-V '%callout-graphics-path%=images/callouts/' \
|
||||
-V '%stock-graphics-extension%=.png' \
|
||||
--output . \
|
||||
$(OBJ) \
|
||||
&& ln -snf $(VERBOSE) -- index.html $(notdir $(HTML)))
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# specific handling for DocBook XML documents
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
.PHONY: xml-all
|
||||
xml-all: xml-$(HTMLS) xml-$(TEXT) xml-$(PDF) xml-$(HTML)
|
||||
|
||||
.PHONY: xml-$(HTMLS)
|
||||
xml-$(HTMLS): $(OUTDIR) $(OUTDIR)/images $(OUTDIR)/resources
|
||||
# -- note the mv -vu $(notdir $(HTML)) $(notdir $(HTMLS))
|
||||
# the docbook2html processor will create a single-page
|
||||
# HTML file called $(OBJSTEM).html, which we will want
|
||||
# to create as a symlink, later
|
||||
(cd $(OUTDIR) \
|
||||
&& XML_CATALOG_FILES="$(XML_CATALOG_FILES)" \
|
||||
xsltproc > "$(notdir $(HTMLS))" \
|
||||
--nonet \
|
||||
--stringparam admon.graphics.path images/ \
|
||||
--stringparam base.dir . \
|
||||
"$(XSLSINGLE)" "$(OBJ)")
|
||||
# -- what about images and other resources?
|
||||
|
||||
.PHONY: xml-$(TEXT)
|
||||
xml-$(TEXT): xml-$(HTMLS)
|
||||
(cd $(OUTDIR) && html2text -style pretty -nobs $(notdir $(HTMLS)) > $(notdir $@))
|
||||
|
||||
.PHONY: xml-$(FO)
|
||||
xml-$(FO): $(OUTDIR)
|
||||
( cd $(OUTDIR) \
|
||||
&& XML_CATALOG_FILES=/etc/xml/catalog \
|
||||
xsltproc > "$(notdir $(FO))" \
|
||||
--nonet \
|
||||
"$(XSLPRINT)" "$(OBJ)")
|
||||
|
||||
.PHONY: xml-$(PDF)
|
||||
xml-$(PDF): xml-$(FO)
|
||||
(fop -fo $(FO) -pdf $(PDF) && rm -f $(FO) \
|
||||
|| dblatex -F xml -t pdf -o $(PDF) $(OBJ))
|
||||
|
||||
xml-$(HTML): xml-$(HTMLS)
|
||||
( cd $(OUTDIR) \
|
||||
&& XML_CATALOG_FILES=/etc/xml/catalog \
|
||||
xsltproc \
|
||||
--nonet \
|
||||
--stringparam admon.graphics.path images/ \
|
||||
--stringparam base.dir . \
|
||||
"$(XSLCHUNK)" "$(OBJ)" \
|
||||
&& ln -snf $(VERBOSE) -- index.html $(notdir $(HTML)))
|
||||
# -- what about images and other resources?
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# specific handling for LinuxDoc documents
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
.PHONY: linuxdoc-all
|
||||
linuxdoc-all: linuxdoc-$(HTMLS) linuxdoc-$(TEXT) linuxdoc-$(PDF) linuxdoc-$(HTML)
|
||||
|
||||
.PHONY: linuxdoc-$(HTMLS)
|
||||
linuxdoc-$(HTMLS): $(OUTDIR)/images
|
||||
# -- note the mv -vu $(notdir $(HTML)) $(notdir $(HTMLS))
|
||||
# the docbook2html processor will create a single-page
|
||||
# HTML file called $(OBJSTEM).html, which we will want
|
||||
# to create as a symlink, later
|
||||
(cd $(OUTDIR) \
|
||||
&& sgml2html --split=0 $(OBJ) \
|
||||
&& mv --update $(VERBOSE) -- $(notdir $(HTML)) $(notdir $(HTMLS)))
|
||||
# -- what about images and other resources?
|
||||
|
||||
.PHONY: linuxdoc-$(TEXT)
|
||||
linuxdoc-$(TEXT): linuxdoc-$(HTMLS)
|
||||
(cd $(OUTDIR) && html2text -style pretty -nobs $(notdir $(HTMLS)) > $(notdir $(TEXT)))
|
||||
|
||||
.PHONY: linuxdoc-$(PDF)
|
||||
linuxdoc-$(PDF): linuxdoc-$(HTMLS)
|
||||
( cd $(OUTDIR) \
|
||||
&& htmldoc --size universal -t pdf --firstpage p1 --outfile $(notdir $(PDF)) $(notdir $(HTMLS)))
|
||||
|
||||
.PHONY: linuxdoc-$(HTML)
|
||||
linuxdoc-$(HTML): $(OUTDIR)
|
||||
# -- LinuxDoc processing tools create the output document file as
|
||||
# Some-Name.html (and Some-Name-1.html, Some-Name-2.html), so we
|
||||
# should create a symlink from index.html to the Some-Name.html.
|
||||
( cd $(OUTDIR) \
|
||||
&& sgml2html $(OBJ) \
|
||||
&& ln -snf $(VERBOSE) -- $(notdir $(HTML)) index.html)
|
||||
# -- what about images and other resources?
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# more general fragments for Makefile degubbing
|
||||
# - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
vars:
|
||||
@printf "%s\n" \
|
||||
"OBJ = $(OBJ)" \
|
||||
"OBJDIR = $(OBJDIR)" \
|
||||
"OBJINDEX = $(OBJINDEX)" \
|
||||
"OBJFORMAT = $(OBJFORMAT)" \
|
||||
"OBJFILE = $(OBJFILE)" \
|
||||
"OBJSTEM = $(OBJSTEM)" \
|
||||
"OUTDIR = $(OUTDIR)" \
|
||||
"PDF = $(PDF)" \
|
||||
"HTML = $(HTML)" \
|
||||
"HTMLS = $(HTMLS)" \
|
||||
"TEXT = $(TEXT)" \
|
||||
"DESTDIR = $(DESTDIR)" \
|
||||
|
||||
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@printf "%s\n" \
|
||||
"There will be help here in the future."
|
||||
|
||||
#
|
||||
# -- end of file
|
|
@ -0,0 +1,277 @@
|
|||
#! /bin/bash
|
||||
#
|
||||
#
|
||||
|
||||
ME="${0##*/}"
|
||||
VCSBASE="${1:-$HOME/vcs/LDP/LDP}" && shift
|
||||
DESTDIR="${1:-$PWD/output}" && shift
|
||||
|
||||
SOURCES=""
|
||||
SOURCES="${SOURCES} ${VCSBASE}/faq/linuxdoc"
|
||||
SOURCES="${SOURCES} ${VCSBASE}/guide/linuxdoc"
|
||||
SOURCES="${SOURCES} ${VCSBASE}/howto/linuxdoc"
|
||||
|
||||
SOURCES="${SOURCES} ${VCSBASE}/faq/docbook"
|
||||
SOURCES="${SOURCES} ${VCSBASE}/guide/docbook"
|
||||
SOURCES="${SOURCES} ${VCSBASE}/howto/docbook"
|
||||
SOURCES="${SOURCES} ${VCSBASE}/ref/docbook"
|
||||
|
||||
# -- my favorite shell functions (and their offspring)
|
||||
#
|
||||
gripe () { printf >&2 "%s\n" "$@"; }
|
||||
debug () { : ; } # -- NOOP for now
|
||||
notice () { gripe "${ME}[$$]: $@"; }
|
||||
abort () {
|
||||
EXIT_CODE="${1}" && shift;
|
||||
gripe "E: $@";
|
||||
exit $EXIT_CODE;
|
||||
}
|
||||
|
||||
# -- defaults for logging output; override these in environment
|
||||
# if you care
|
||||
#
|
||||
: "${LOG_FACILITY:=daemon}"
|
||||
: "${LOG_PRIO:=err}"
|
||||
: "${LOGGER_OPTS:=-t ${ME}[$$] -p ${LOG_FACILITY}.${LOG_PRIO}}"
|
||||
|
||||
# -- if we are connected to a terminal, then send logging output
|
||||
# to STDERR, as well
|
||||
|
||||
# -- create logger as a shell function
|
||||
#
|
||||
logger () {
|
||||
tty -s && LOGGER_OPTS="-s $LOGGER_OPTS"
|
||||
command logger $LOGGER_OPTS -- "$@" ;
|
||||
}
|
||||
|
||||
usage () {
|
||||
gripe "usage: ${ME} [<ldp_checkout> [<destdir>]]" \
|
||||
" default ldp_checkout=${VCSBASE}" \
|
||||
" default destdir=${DESTDIR}" \
|
||||
""
|
||||
abort 1 "$@";
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - -
|
||||
function select_source_files () {
|
||||
# - - - - - - - - - - - -
|
||||
#
|
||||
# -- return a list of filenames in any directory which are (likely)
|
||||
# to be documents for TLDP
|
||||
# args 1: file extension sought
|
||||
# args +2: base directories in which to seek
|
||||
|
||||
local ext=${1} && shift
|
||||
|
||||
for d in $@; do
|
||||
|
||||
test -e "$d" || abort 2 "ENOENT (2): No such file or directory: ${d}"
|
||||
test -d "$d" || abort 20 "ENOTDIR (20): Not a directory: ${d}";
|
||||
|
||||
# -- locate each solo text document, e.g. XWindow-User-HOWTO.xml
|
||||
#
|
||||
find "$d" -mindepth 1 -maxdepth 1 -type f -name \*."${ext}" -printf "%p\n"
|
||||
|
||||
# -- locate each document owning a directory, e.g. 8021X-HOWTO/8021X-HOWTO.sgml
|
||||
#
|
||||
{
|
||||
find "$d" -mindepth 1 -maxdepth 1 -type d -printf "%p\n" | while read DIR; do
|
||||
|
||||
# -- get just the stem of the document name from the directory, e.g. 8021X-HOWTO
|
||||
stem=${DIR##*/}
|
||||
|
||||
# -- construct an abspath, e.g. /full/path/to/8021X-HOWTO/8021X-HOWTO.sgml
|
||||
doc="${DIR}/${stem}.${ext}"
|
||||
|
||||
# -- see if file exists, and if so, print its name
|
||||
test -e "${doc}" && printf "%s\n" "${doc}"
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - -
|
||||
get_stem () {
|
||||
# - - - - - - - - - - - -
|
||||
#
|
||||
local fn="${1##*/}"
|
||||
printf "%s\n" "${fn%.*}";
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - -
|
||||
sort_by_stem () {
|
||||
# - - - - - - - - - - - -
|
||||
#
|
||||
# -- typical decorate, sort, undecorate pattern, though,
|
||||
# admittedly, not common in shell
|
||||
# - no args
|
||||
# - STDIN: stream of strings with full path
|
||||
# - STDOUT: stem-sorted stream of strings with full path
|
||||
#
|
||||
{
|
||||
{
|
||||
while read OBJ; do
|
||||
stem=$( get_stem "$OBJ" )
|
||||
printf "%s %s\n" "${stem}" "$OBJ"
|
||||
done;
|
||||
} | sort;
|
||||
} | awk '{print $2}';
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - -
|
||||
list_all_documents () {
|
||||
# - - - - - - - - - - - -
|
||||
#
|
||||
{
|
||||
select_source_files xml "$@";
|
||||
select_source_files sgml "$@";
|
||||
} | sort_by_stem;
|
||||
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - -
|
||||
find_sort_by_mtime () {
|
||||
# - - - - - - - - - - - -
|
||||
#
|
||||
local SOURCE="${1}" && shift
|
||||
local OUTPUT="${1}" && shift
|
||||
{
|
||||
# -- directory age does not count, only file age!
|
||||
#
|
||||
test -e "${SOURCE}" \
|
||||
|| abort 2 "ENOENT (2): we thought this directory just existed: ${SOURCE}"
|
||||
find "$SOURCE" -type f -printf "%T@ SOURCE %p\n";
|
||||
|
||||
test -d "${OUTPUT}" \
|
||||
&& find "$OUTPUT" -type f -printf "%T@ OUTPUT %p\n";
|
||||
|
||||
} | sort -gr;
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - -
|
||||
function is_source_tree_newer () {
|
||||
# - - - - - - - - - - - -
|
||||
#
|
||||
# -- return a list of filenames in any directory which are (likely)
|
||||
# to be documents for TLDP
|
||||
# args 1: input file name
|
||||
# args 2: DESTDIR
|
||||
#
|
||||
# -- there are two (probable) cases for the input, A) a single standalone
|
||||
# file or B) the main document source file in a dedicated directory;
|
||||
# below is a description of the logic....
|
||||
#
|
||||
# Case A) single standalone file; we don't want to find all files from
|
||||
# the parent directory
|
||||
#
|
||||
# OBJ=/home/fred/vcs/LDP/LDP/howto/docbook/Software-Release-Practice-HOWTO.xml
|
||||
# DESTDIR=/home/fred/wip/tldp/output
|
||||
# fn=Software-Release-Practice-HOWTO.xml
|
||||
# stem=Software-Release-Practice-HOWTO
|
||||
# parentdir=/home/fred/vcs/LDP/LDP/howto/docbook
|
||||
# parentstem=docbook
|
||||
#
|
||||
# Case B) main document source file in a dedicated directory; we do want
|
||||
# to look for all files starting from the parent directory
|
||||
#
|
||||
# OBJ=/home/fred/vcs/LDP/LDP/howto/docbook/Jabber-Server-Farming-HOWTO/Jabber-Server-Farming-HOWTO.xml
|
||||
# DESTDIR=/home/fred/wip/tldp/output
|
||||
# fn=Jabber-Server-Farming-HOWTO.xml
|
||||
# stem=Jabber-Server-Farming-HOWTO
|
||||
# parentdir=/home/fred/vcs/LDP/LDP/howto/docbook/Jabber-Server-Farming-HOWTO
|
||||
# parentstem=Jabber-Server-Farming-HOWTO
|
||||
#
|
||||
local stem="${1}" && shift
|
||||
local OBJ="${1}" && shift
|
||||
local DESTDIR="${1}" && shift
|
||||
|
||||
local parentdir="${OBJ%/*}"
|
||||
local parentstem="${parentdir##*/}"
|
||||
|
||||
startloc="$OBJ"
|
||||
test "${stem}" == "${parentstem}" \
|
||||
&& startloc="${parentdir}"
|
||||
|
||||
local outdir="${DESTDIR}/${stem}"
|
||||
|
||||
result=$( find_sort_by_mtime "$startloc" "$outdir" ) \
|
||||
|| abort 1 "Could not retrieve files for $stem sorted by mtime."
|
||||
newest=$( head -n 1 <<<"$result" ) \
|
||||
|| abort 1 "Could not get first result for $stem files."
|
||||
|
||||
DECISION=$( sed -e '/ OUTPUT /,$d' <<<"$newest" ) \
|
||||
|| abort 1 "Could not check if the SOURCE files are newest...."
|
||||
|
||||
if test -z "$DECISION" ; then
|
||||
debug "${stem} No new source files"
|
||||
return 1
|
||||
else
|
||||
|
||||
# -- squawk about it, to the user
|
||||
#
|
||||
while read TS SOURCE FNAME ; do
|
||||
ts=$( date +%F-%T --date @"$TS" )
|
||||
notice "${stem} updated file found ($ts): $FNAME"
|
||||
done <<< "$DECISION"
|
||||
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - -
|
||||
generate_new_content () {
|
||||
# - - - - - - - - - - - -
|
||||
#
|
||||
local stem="${1}" && shift
|
||||
local OBJ="${1}" && shift
|
||||
local DESTDIR="${1}" && shift
|
||||
#local makefile="${1}" && shift
|
||||
|
||||
# -- make a stab at processing the document, but don't let the driver
|
||||
# stop just because a single document has an error
|
||||
#
|
||||
{
|
||||
{
|
||||
exec 2>&1;
|
||||
make OBJ="${OBJ}" DESTDIR="${DESTDIR}";
|
||||
test $? -eq 0 \
|
||||
|| gripe "FAILURE" "FAILURE producing all outputs from $OBJ" "FAILURE";
|
||||
} | sed -ue "s/^/${stem} /";
|
||||
} | command logger -s ${LOGGER_OPTS} --
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - -
|
||||
main () {
|
||||
# - - - - - - - - - - - -
|
||||
#
|
||||
local SOURCES="$@"
|
||||
list_all_documents "$SOURCES" | while read OBJ; do
|
||||
|
||||
stem=$( get_stem "$OBJ" )
|
||||
|
||||
notice "${stem} checking if rebuild required for $OBJ"
|
||||
|
||||
# -- N.B. there's a dangerous looking ||: at the end of the line
|
||||
# calling the Makefile. This is intentional. The Makefile
|
||||
# may not be able to process the input successfully, but we
|
||||
# would like to continue, if possible, and process the next
|
||||
# available document.
|
||||
#
|
||||
is_source_tree_newer "${stem}" "$OBJ" "$DESTDIR" \
|
||||
&& (generate_new_content "${stem}" "${OBJ}" "${DESTDIR}" || :)
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# main
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
test -d "${DESTDIR}" \
|
||||
|| usage "Output directory must already exist, quitting."
|
||||
|
||||
main "$SOURCES"
|
||||
|
||||
# -- end of file
|
Loading…
Reference in New Issue