* doc/gen-examples-outputs-mk: Split generated rules in two so
that they produce a timestamp that outputs (and soon generated
figures) depend on.
---
milena/ChangeLog | 8 ++++++
milena/doc/gen-examples-outputs-mk | 48 +++++++++++++++++++++++++++--------
2 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9f7f28b..536253c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2010-03-17 Roland Levillain <roland(a)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(a)lrde.epita.fr>
+
Generate doc/examples-outputs.mk using sources in lieu of programs.
* doc/gen-examples-outputs-mk: Take sources as input instead of
diff --git a/milena/doc/gen-examples-outputs-mk b/milena/doc/gen-examples-outputs-mk
index 2580072..440d960 100755
--- a/milena/doc/gen-examples-outputs-mk
+++ b/milena/doc/gen-examples-outputs-mk
@@ -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
--
1.5.6.5
Show replies by date