Commit 365cdb48 authored by Roland Levillain's avatar Roland Levillain
Browse files

Prepare for the generation of multiple outputs from doc/ programs.

	* doc/gen-examples-outputs-mk: Split generated rules in two so
	that they produce a timestamp that outputs (and soon generated
	figures) depend on.
parent 1d9cee32
2010-03-17 Roland Levillain <roland@lrde.epita.fr>
Prepare for the generation of multiple outputs from doc/ programs.
* doc/gen-examples-outputs-mk: Split generated rules in two so
that they produce a timestamp that outputs (and soon generated
figures) depend on.
2010-03-17 Roland Levillain <roland@lrde.epita.fr>
 
Generate doc/examples-outputs.mk using sources in lieu of programs.
......@@ -24,22 +24,48 @@ test $# -ne 0 || { echo "usage: $me SOURCES..."; exit 1; }
cat<<EOF
## Generated by $me. Do not edit by hand.
EOF
for source; do
program=`basename "$source" .cc`
# Have outputs depend on sources rather than programs, and recompile
# the latter to regen the former only when needed. This way, we can
# ship generated outputs without forcing the user of the
base=`basename "$source" .cc`
source_dir=`dirname "$source"`
timestamp="\$(srcdir)/$source_dir/$base.stamp"
# FIXME: Programs of which sources are located in a subdirectory of
# examples/ take the path as prefix of their name. This is a pain.
# It'd be much simpler to have all sources in the same directory.
canonical_name=`echo "$source" \
| sed -e 's,examples/,,' \
-e 'y,/,_,' \
-e 's,\.cc$,,'`
program="$canonical_name\$(EXEEXT)"
output="\$(srcdir)/outputs/$canonical_name.txt"
# Programs generate a textual output, and possibly one or several
# images (as a ``side effect''). Use a timestamp to keep track of
# these multiple outputs.
#
# Also, have outputs depend on sources rather than programs, and
# recompile the latter to regen the former only when needed. This
# way, we can ship generated outputs without forcing the user of the
# distribution to recompile the programs.
cat<<EOF
\$(srcdir)/outputs/$program.txt: $source
rm -f \$@.tmp
\$(MAKE) \$(AM_MAKEFLAGS) $program\$(EXEEXT)
./\$< >\$@.tmp
cp -f \$@.tmp \$@
rm -f \$@.tmp
$timestamp: $source
@rm -f \$@.tmp
@touch \$@.tmp
\$(MAKE) \$(AM_MAKEFLAGS) $program
./$program >$output.tmp
mv $output.tmp $output
@mv -f \$@.tmp \$@
EXTRA_DIST += $timestamp
MAINTAINERCLEANFILES += $timestamp
$output: $timestamp
## Recover from the removal of \$@
@if test -f \$@; then :; else \\
rm -f \$<; \\
\$(MAKE) \$(AM_MAKEFLAGS) \$<; \\
fi
EOF
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment