Commit 642d87ac authored by Roland Levillain's avatar Roland Levillain
Browse files

Add a script to generate doc/figures.mk.

	* doc/gen-figures-mk: New script.
	* doc/Makefile.am (EXTRA_DIST): Add gen-figures-mk.
parent 2c4e1e1d
2010-03-20 Roland Levillain <roland@lrde.epita.fr>
Add a script to generate doc/figures.mk.
* doc/gen-figures-mk: New script.
* doc/Makefile.am (EXTRA_DIST): Add gen-figures-mk.
2010-03-20 Roland Levillain <roland@lrde.epita.fr>
 
Use a more uniform style in doc/figures.mk.
......@@ -94,6 +94,8 @@ DOC_PACKAGES = doxyfuns.sty milena.sty
## Figures. ##
## --------- ##
EXTRA_DIST += gen-figures-mk
# Generated figures.
include $(srcdir)/figures.mk
# FIXME: $(FIGURES) is not added to EXTRA_DIST (though it is added to
......
#! /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/>.
me=`basename $0`
# Use the C locale to have a deterministic sort.
export LC_ALL=C
# Get this list as argument?
inputs()
{
# Remove the .cc extension before sorting file names.
find examples -name \*.cc -a \! -path examples/trash/\* \
| sed 's/.cc$//' \
| sort \
| sed 's/$/.cc/'
}
# get_outputs FILE
# ----------------
get_outputs()
{
local outputs=
local i=1
# Use Perl instead of sed for portability reasons.
for output in `perl -ne \
"print if s|^\\s*doc::(p.m)save\\s*\\([^;]+,\\s*\"([^\"]+)\"\\);\$|\\2.\\1|" \
"$1"`
do
# Add a number to the file name.
# FIXME: Maybe we should let the Perl script above do this...
num_output=`echo $output | sed "s,\\(.p.m\\),-$i\\1,"`
if test -z "$outputs"; then
outputs="$num_output"
else
outputs="$outputs $num_output"
fi
i=`expr $i + 1`
done
echo "$outputs"
}
# upcase STRING
# -------------
upcase()
{
# Use enumerated sets to be portable.
echo "$1" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
}
# canonicalize STRING
# -------------------
canonicalize()
{
echo "$1" | tr .- _
}
# 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"
}
# Empty FIG_VARS.
fig_vars=
cat<<EOF
## Generated by $me. Do not edit by hand.
## Figures depend on the timestamp associated with their generator.
## See also examples-outputs.mk.
EOF
for file in `inputs`; do
# FIXME: Ugly hack to handle the case of examples/ima-save.cc, since
# this program does not use a `doc::p?msave' routine...
if test "X$file" = "Xexamples/ima-save.cc"; then
# Hard-coded value.
figures="ima_save.pbm"
else
figures=`get_outputs "$file"`
fi
if test -n "$figures"; then
# 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$,,'`
canonical_var=`canonicalize "$canonical_name"`
fig_var="`upcase "$canonical_var"`_FIGURES"
# Populate the list of variables of figures.
if test -z "$fig_vars"; then
fig_vars="$fig_var"
else
fig_vars="$fig_vars $fig_var"
fi
{
echo "$fig_var ="
for figure in $figures; do
echo " \$(srcdir)/figures/$figure"
done
} | backslashify
base=`basename "$file" .cc`
dir=`dirname "$file"`
timestamp="\$(srcdir)/$dir/$base.stamp"
cat <<EOF
\$($fig_var): $timestamp
## Recover from the removal of \$@
@if test -f \$@; then :; else \\
rm -f \$<; \\
\$(MAKE) \$(AM_MAKEFLAGS) \$<; \\
fi
EOF
fi
done
# Output the list of figures.
echo "# The list of all generated figures."
{
echo "FIGURES ="
for v in $fig_vars; do
echo " \$($v)"
done
} | backslashify
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