Commit ba6a3f88 authored by Roland Levillain's avatar Roland Levillain
Browse files

Generate the list of split outputs in the documentation.

	* doc/Makefile.am ($(srcdir)/split-outputs.mk): New rule.
	(regen-split-outputs-mk): New (phony) target.
	($(srcdir)/split-outputs.stamp): Remove rule.
	(refman_dependencies)
	(tutorial_dependencies)
	(ref_guide_dependencies)
	(EXTRA_DIST, MAINTAINERCLEANFILES):
	Remove $(srcdir)/split-outputs.stamp
	Add $(SPLIT_OUTPUTS).
	(regen-am): Remake regen-split-outputs-mk.
	* doc/gen-split-outputs-mk: New script.
	Use it to generate...
	* doc/split-outputs.mk: ...this (new) Make helper.
parent a4d6bc84
2010-03-18 Roland Levillain <roland@lrde.epita.fr>
Generate the list of split outputs in the documentation.
* doc/Makefile.am ($(srcdir)/split-outputs.mk): New rule.
(regen-split-outputs-mk): New (phony) target.
($(srcdir)/split-outputs.stamp): Remove rule.
(refman_dependencies)
(tutorial_dependencies)
(ref_guide_dependencies)
(EXTRA_DIST, MAINTAINERCLEANFILES):
Remove $(srcdir)/split-outputs.stamp
Add $(SPLIT_OUTPUTS).
(regen-am): Remake regen-split-outputs-mk.
* doc/gen-split-outputs-mk: New script.
Use it to generate...
* doc/split-outputs.mk: ...this (new) Make helper.
2010-03-18 Roland Levillain <roland@lrde.epita.fr> 2010-03-18 Roland Levillain <roland@lrde.epita.fr>
   
Prepare doc source files for the automation of output splitting. Prepare doc source files for the automation of output splitting.
...@@ -244,7 +244,7 @@ regen-split-examples-mk: ...@@ -244,7 +244,7 @@ regen-split-examples-mk:
# corresponding to a bunch of files. # corresponding to a bunch of files.
refman_dependencies = \ refman_dependencies = \
$(SPLIT_EXAMPLES) \ $(SPLIT_EXAMPLES) \
$(srcdir)/split-outputs.stamp \ $(SPLIT_OUTPUTS) \
$(PNG_FIGURES) \ $(PNG_FIGURES) \
$(srcdir)/tutorial/tutorial.hh \ $(srcdir)/tutorial/tutorial.hh \
$(srcdir)/ref_guide/ref_guide.hh $(srcdir)/ref_guide/ref_guide.hh
...@@ -534,7 +534,7 @@ tutorial_dir = $(doc_dir)/tutorial ...@@ -534,7 +534,7 @@ tutorial_dir = $(doc_dir)/tutorial
# corresponding to a bunch of files. # corresponding to a bunch of files.
tutorial_dependencies = \ tutorial_dependencies = \
$(SPLIT_EXAMPLES) \ $(SPLIT_EXAMPLES) \
$(doc_dir)/split-outputs.stamp \ $(SPLIT_OUTPUTS) \
$(PNG_FIGURES) \ $(PNG_FIGURES) \
$(DOC_PACKAGES) $(DOC_PACKAGES)
...@@ -732,7 +732,7 @@ ref_guide_dir = $(doc_dir)/ref_guide ...@@ -732,7 +732,7 @@ ref_guide_dir = $(doc_dir)/ref_guide
# corresponding to a bunch of files. # corresponding to a bunch of files.
ref_guide_dependencies = \ ref_guide_dependencies = \
$(SPLIT_EXAMPLES) \ $(SPLIT_EXAMPLES) \
$(doc_dir)/split-outputs.stamp \ $(SPLIT_OUTPUTS) \
$(PNG_FIGURES) \ $(PNG_FIGURES) \
$(DOC_PACKAGES) $(DOC_PACKAGES)
...@@ -909,22 +909,21 @@ include $(srcdir)/figures.mk ...@@ -909,22 +909,21 @@ include $(srcdir)/figures.mk
## Split outputs. ## ## Split outputs. ##
## --------------- ## ## --------------- ##
EXTRA_DIST += $(srcdir)/split-outputs.stamp $(srcdir)/split-outputs.mk: $(srcdir)/gen-split-outputs-mk
MAINTAINERCLEANFILES += $(srcdir)/split-outputs.stamp rm -f $@.tmp
# FIXME: Loops are bad, as they prevent parallelism. And we prefer cd $(srcdir) && ./gen-split-outputs-mk >split-outputs.mk.tmp
# data-driven actions anyway. This would imply that we know in mv -f $@.tmp $@
# advance the list out outputs (here, split outputs). Maybe we can chmod -w $@
# infer it from the LaTeX document. include $(srcdir)/split-outputs.mk
$(srcdir)/split-outputs.stamp: $(OUTPUTS) EXTRA_DIST += $(SPLIT_OUTPUTS)
@rm -f $@.tmp MAINTAINERCLEANFILES += $(SPLIT_OUTPUTS)
@touch $@.tmp
failcom='exit 1'; \ .PHONY: regen-split-outputs-mk
for file in $(OUTPUTS); do \ regen-split-outputs-mk:
$(DOC_SRCDIR)/tools/split_sample.sh \ rm -f $(srcdir)/split-outputs.mk.tmp
$$file txt "" $(SPLIT_OUTPUTS_SRCDIR) \ cd $(srcdir) && ./gen-split-outputs-mk >split-outputs.mk.tmp
|| eval $$failcom; \ mv -f $(srcdir)/split-outputs.mk.tmp $(srcdir)/split-outputs.mk
done chmod -w $(srcdir)/split-outputs.mk
@mv -f $@.tmp $@
## -------------- ## ## -------------- ##
...@@ -942,6 +941,7 @@ regen-am: ...@@ -942,6 +941,7 @@ regen-am:
$(MAKE) $(AM_MAKEFLAGS) regen-split-examples-mk $(MAKE) $(AM_MAKEFLAGS) regen-split-examples-mk
$(MAKE) $(AM_MAKEFLAGS) regen-outputs-mk $(MAKE) $(AM_MAKEFLAGS) regen-outputs-mk
$(MAKE) $(AM_MAKEFLAGS) regen-examples-outputs-mk $(MAKE) $(AM_MAKEFLAGS) regen-examples-outputs-mk
$(MAKE) $(AM_MAKEFLAGS) regen-split-outputs-mk
## -------------- ## ## -------------- ##
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
# To be used from milena/doc/'s source directory. # To be used from milena/doc/'s source directory.
# FIXME: Factor gen-split-examples-mk and gen-split-outputs-mk.
me=`basename $0` me=`basename $0`
die () die ()
......
#! /bin/sh
# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
# Olena is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, version 2 of the License.
#
# Olena is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
# To be used from milena/doc/'s source directory.
# FIXME: Factor gen-split-examples-mk and gen-split-outputs-mk.
me=`basename $0`
die ()
{
echo >&2 "$me: $@"
exit 1
}
# backslashify
# ------------
# Read lines from the standard input and write them on the standard
# output with an extra trailing backslash, except for the last line.
backslashify()
{
# Set IFS to nothing to prevent `read' from trimming spaces or tabs.
IFS= read last_line
while IFS= read line; do
echo "$last_line \\"
last_line=$line
done
echo "$last_line"
}
# Get this list as argument?
inputs()
{
# FIXME: Or find examples -name \*.cc -a \! -path examples/trash/\* ?
find examples -name \*.cc
}
output_dir=outputs/split
# Use a temporary file to dump rules at the end of the output.
tempfile=`mktemp`
# Set up automatic cleanup.
cleanup() { rm -f "$tempfile"; exit; }
trap cleanup 0 1 2 3 6 15
# Header.
cat <<EOF
## Generated by $me. Do not edit by hand.
EOF
# Output target names in a variable.
{
echo "SPLIT_OUTPUTS ="
inputs | while read file; do
# Count the number of opening and closing marks.
nopening=`grep -c 'doc::begin_output' "$file"`
nclosing=`grep -c 'doc::end_output' "$file"`
test "$nopening" -eq "$nclosing" \
|| die "Unbalanced marks in $file ($nopening vs $nclosing)"
# If there is no mark, skip this file.
test "$nopening" -eq 0 && continue
# 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 "$file" \
| sed -e 's,examples/,,' \
-e 'y,/,_,' \
-e 's,\.cc$,,'`
# Output file to be split.
output="\$(srcdir)/outputs/$canonical_name.txt"
# Timestamp split outputs depend on.
timestamp="\$(srcdir)/$output_dir/$canonical_name.txt.stamp"
# List of targets associated to FILE.
targets=
{
i=1
while test "$i" -le "$nopening"; do
# i-th part of the split file.
part="\$(srcdir)/$output_dir/$canonical_name-$i.txt"
if test -z "$targets"; then
targets="$part"
else
targets="$targets $part"
fi
echo " $part"
i=`expr $i + 1`
done
# Collect rules in a temporary file...
cat >>"$tempfile" <<EOF
$timestamp: $output
@rm -f \$@.tmp
@touch \$@.tmp
\$(srcdir)/tools/split_sample.sh \$< txt "" \$(srcdir)/$output_dir
@mv -f \$@.tmp \$@
EXTRA_DIST += $timestamp
MAINTAINERCLEANFILES += $timestamp
$targets: $timestamp
## Recover from the removal of \$@
@if test -f \$@; then :; else \\
rm -f \$<; \\
\$(MAKE) \$(AM_MAKEFLAGS) \$<; \\
fi
EOF
}
done
} | backslashify
# ...and output them at the end.
cat "$tempfile"
## Generated by gen-split-outputs-mk. Do not edit by hand.
SPLIT_OUTPUTS = \
$(srcdir)/outputs/split/graph-iter-1.txt \
$(srcdir)/outputs/split/graph-iter-2.txt \
$(srcdir)/outputs/split/graph-iter-3.txt \
$(srcdir)/outputs/split/graph-iter-4.txt \
$(srcdir)/outputs/split/tuto3_println-1.txt \
$(srcdir)/outputs/split/tuto3_println-2.txt \
$(srcdir)/outputs/split/tuto4_site_set_create-1.txt \
$(srcdir)/outputs/split/tuto4_site_set_create-2.txt \
$(srcdir)/outputs/split/tuto4_site_set_create-3.txt
$(srcdir)/outputs/split/graph-iter.txt.stamp: $(srcdir)/outputs/graph-iter.txt
@rm -f $@.tmp
@touch $@.tmp
$(srcdir)/tools/split_sample.sh $< txt "" $(srcdir)/outputs/split
@mv -f $@.tmp $@
EXTRA_DIST += $(srcdir)/outputs/split/graph-iter.txt.stamp
MAINTAINERCLEANFILES += $(srcdir)/outputs/split/graph-iter.txt.stamp
$(srcdir)/outputs/split/graph-iter-1.txt $(srcdir)/outputs/split/graph-iter-2.txt $(srcdir)/outputs/split/graph-iter-3.txt $(srcdir)/outputs/split/graph-iter-4.txt: $(srcdir)/outputs/split/graph-iter.txt.stamp
## Recover from the removal of $@
@if test -f $@; then :; else \
rm -f $<; \
$(MAKE) $(AM_MAKEFLAGS) $<; \
fi
$(srcdir)/outputs/split/tuto3_println.txt.stamp: $(srcdir)/outputs/tuto3_println.txt
@rm -f $@.tmp
@touch $@.tmp
$(srcdir)/tools/split_sample.sh $< txt "" $(srcdir)/outputs/split
@mv -f $@.tmp $@
EXTRA_DIST += $(srcdir)/outputs/split/tuto3_println.txt.stamp
MAINTAINERCLEANFILES += $(srcdir)/outputs/split/tuto3_println.txt.stamp
$(srcdir)/outputs/split/tuto3_println-1.txt $(srcdir)/outputs/split/tuto3_println-2.txt: $(srcdir)/outputs/split/tuto3_println.txt.stamp
## Recover from the removal of $@
@if test -f $@; then :; else \
rm -f $<; \
$(MAKE) $(AM_MAKEFLAGS) $<; \
fi
$(srcdir)/outputs/split/tuto4_site_set_create.txt.stamp: $(srcdir)/outputs/tuto4_site_set_create.txt
@rm -f $@.tmp
@touch $@.tmp
$(srcdir)/tools/split_sample.sh $< txt "" $(srcdir)/outputs/split
@mv -f $@.tmp $@
EXTRA_DIST += $(srcdir)/outputs/split/tuto4_site_set_create.txt.stamp
MAINTAINERCLEANFILES += $(srcdir)/outputs/split/tuto4_site_set_create.txt.stamp
$(srcdir)/outputs/split/tuto4_site_set_create-1.txt $(srcdir)/outputs/split/tuto4_site_set_create-2.txt $(srcdir)/outputs/split/tuto4_site_set_create-3.txt: $(srcdir)/outputs/split/tuto4_site_set_create.txt.stamp
## Recover from the removal of $@
@if test -f $@; then :; else \
rm -f $<; \
$(MAKE) $(AM_MAKEFLAGS) $<; \
fi
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