olena: olena-2.0-876-g450e319 Factor generators used in Milena's doc/ directory.

* doc/gen-examples-outputs-mk, * doc/gen-figures-mk, * doc/gen-make-variable, * doc/gen-split-examples-mk, * doc/gen-split-outputs-mk: Replace with symlinks to the scripts located in Olena's build-aux/ directory. --- milena/ChangeLog | 12 +++ milena/doc/gen-examples-outputs-mk | 72 +------------- milena/doc/gen-figures-mk | 193 +----------------------------------- milena/doc/gen-make-variable | 53 +--------- milena/doc/gen-split-examples-mk | 137 +------------------------ milena/doc/gen-split-outputs-mk | 140 +------------------------- 6 files changed, 17 insertions(+), 590 deletions(-) mode change 100755 => 120000 milena/doc/gen-examples-outputs-mk mode change 100755 => 120000 milena/doc/gen-figures-mk mode change 100755 => 120000 milena/doc/gen-make-variable mode change 100755 => 120000 milena/doc/gen-split-examples-mk mode change 100755 => 120000 milena/doc/gen-split-outputs-mk diff --git a/milena/ChangeLog b/milena/ChangeLog index aa0c433..262513b 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,17 @@ 2014-06-20 Roland Levillain <roland@lrde.epita.fr> + Factor generators used in Milena's doc/ directory. + + * doc/gen-examples-outputs-mk, + * doc/gen-figures-mk, + * doc/gen-make-variable, + * doc/gen-split-examples-mk, + * doc/gen-split-outputs-mk: + Replace with symlinks to the scripts located in Olena's build-aux/ + directory. + +2014-06-20 Roland Levillain <roland@lrde.epita.fr> + Remove mentions to trash/ directories in Milena. * doc/Doxyfile.in (EXCLUDE) diff --git a/milena/doc/gen-examples-outputs-mk b/milena/doc/gen-examples-outputs-mk deleted file mode 100755 index 440d960..0000000 --- a/milena/doc/gen-examples-outputs-mk +++ /dev/null @@ -1,71 +0,0 @@ -#! /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. - -me=`basename $0` - -test $# -ne 0 || { echo "usage: $me SOURCES..."; exit 1; } - -cat<<EOF -## Generated by $me. Do not edit by hand. -EOF - -for source; do - 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 - - -$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 diff --git a/milena/doc/gen-examples-outputs-mk b/milena/doc/gen-examples-outputs-mk new file mode 120000 index 0000000..66a252d --- /dev/null +++ b/milena/doc/gen-examples-outputs-mk @@ -0,0 +1 @@ +../../build-aux/gen-examples-outputs-mk \ No newline at end of file diff --git a/milena/doc/gen-figures-mk b/milena/doc/gen-figures-mk deleted file mode 100755 index 80a55a5..0000000 --- a/milena/doc/gen-figures-mk +++ /dev/null @@ -1,192 +0,0 @@ -#! /bin/sh - -# Copyright (C) 2010, 2014 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 \ - | 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" -} - -# List of generated figures. -fig_vars= - -# gen_var VARIABLE [ITEMS...] -# --------------------------- -# Generate a Make variable named VARIABLE containing ITEMS. -gen_var() -{ - local v - { - echo "$1 =" - shift - for v; do - echo " $v" - done - } | backslashify -} - -# List of paths to PBM figures. -pbm_fig_paths= -# List of paths to PGM figures. -pgg_fig_paths= -# List of paths to PPM figures. -ppm_fig_paths= - -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. - fig_vars="$fig_vars \$($fig_var)" - - # Populate the list of paths to figures of a given format. - for figure in $figures; do - fig_path=" \$(srcdir)/figures/$figure" - case "$figure" in - *.pbm) pbm_fig_paths="$pbm_fig_paths $fig_path";; - *.pgm) pgm_fig_paths="$pgm_fig_paths $fig_path";; - *.ppm) ppm_fig_paths="$ppm_fig_paths $fig_path";; - esac - done - - # Generate a Make variable for the figures produced by FILE. - { - echo "$fig_var =" - for figure in $figures; do - fig_path=" \$(srcdir)/figures/$figure" - echo "$fig_path" - done - } | backslashify - - # Generate a Make rule to regen the figures produced by FILE. - 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 - - -# More Make variables. -echo "# The list of all generated figures." -gen_var FIGURES $fig_vars -echo -echo "# The list of all generated PBM figures." -gen_var PBM_FIGURES $pbm_fig_paths -echo -echo "# The list of all generated PGM figures." -gen_var PGM_FIGURES $pgm_fig_paths -echo -echo "# The list of all generated PPM figures." -gen_var PPM_FIGURES $ppm_fig_paths diff --git a/milena/doc/gen-figures-mk b/milena/doc/gen-figures-mk new file mode 120000 index 0000000..a53b3ed --- /dev/null +++ b/milena/doc/gen-figures-mk @@ -0,0 +1 @@ +../../build-aux/gen-figures-mk \ No newline at end of file diff --git a/milena/doc/gen-make-variable b/milena/doc/gen-make-variable deleted file mode 100755 index 91403ae..0000000 --- a/milena/doc/gen-make-variable +++ /dev/null @@ -1,52 +0,0 @@ -#! /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 - -test $# -gt 1 || { echo "usage: $me VARIABLE FILES..."; 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" -} - -cat<<EOF -## Generated by $me. Do not edit by hand. - -EOF -{ - echo "$1 =" - shift - for var; do - echo "$var" - shift - done | sort | sed 's/\(.*\)/ \1/' -} | backslashify diff --git a/milena/doc/gen-make-variable b/milena/doc/gen-make-variable new file mode 120000 index 0000000..06c3379 --- /dev/null +++ b/milena/doc/gen-make-variable @@ -0,0 +1 @@ +../../build-aux/gen-make-variable \ No newline at end of file diff --git a/milena/doc/gen-split-examples-mk b/milena/doc/gen-split-examples-mk deleted file mode 100755 index b505370..0000000 --- a/milena/doc/gen-split-examples-mk +++ /dev/null @@ -1,136 +0,0 @@ -#! /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` - -# Use the C locale to have a deterministic sort. -export LC_ALL=C - -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() -{ - # Remove the .cc extension before sorting file names. - find examples -name \*.cc \ - | sed 's/.cc$//' \ - | sort \ - | sed 's/$/.cc/' -} - -output_dir=examples/split - -# Use a temporary file to dump rules at the end of the output. -tempfile=`mktemp /tmp/temp.XXXXXX` -# 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_EXAMPLES =" - inputs | while read file; do - # Count the number of opening and closing marks. - nopening=`grep -c '// *\\\{' "$file"` - nclosing=`grep -c '// *\\\}' "$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$,,'` - # Timestamp split examples (outputs) depend on. - timestamp="\$(srcdir)/$output_dir/$canonical_name.cc.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.cc.raw" - - 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: \$(srcdir)/$file - @rm -f \$@.tmp - @touch \$@.tmp - \$(srcdir)/tools/split_sample.sh \$< cc raw \$(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" diff --git a/milena/doc/gen-split-examples-mk b/milena/doc/gen-split-examples-mk new file mode 120000 index 0000000..b0137b2 --- /dev/null +++ b/milena/doc/gen-split-examples-mk @@ -0,0 +1 @@ +../../build-aux/gen-split-examples-mk \ No newline at end of file diff --git a/milena/doc/gen-split-outputs-mk b/milena/doc/gen-split-outputs-mk deleted file mode 100755 index a2313be..0000000 --- a/milena/doc/gen-split-outputs-mk +++ /dev/null @@ -1,139 +0,0 @@ -#! /bin/sh - -# Copyright (C) 2010, 2014 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` - -# Use the C locale to have a deterministic sort. -export LC_ALL=C - -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() -{ - # Remove the .cc extension before sorting file names. - find examples -name \*.cc \ - | sed 's/.cc$//' \ - | sort \ - | sed 's/$/.cc/' -} - -output_dir=outputs/split - -# Use a temporary file to dump rules at the end of the output. -tempfile=`mktemp /tmp/temp.XXXXXX` -# 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" diff --git a/milena/doc/gen-split-outputs-mk b/milena/doc/gen-split-outputs-mk new file mode 120000 index 0000000..9ca6a48 --- /dev/null +++ b/milena/doc/gen-split-outputs-mk @@ -0,0 +1 @@ +../../build-aux/gen-split-outputs-mk \ No newline at end of file -- 1.7.10.4
participants (1)
-
Roland Levillain