* autoheader.in, autoreconf.in, autoupdate.in: Move to...
* bin: here, new directory.
* lib/Autoconf: Rename as...
* lib/Autom4te: this, to please case insensitive junkie OSes.
+2001-08-01 Akim Demaille <akim@epita.fr>
+
+ * autoconf.in, autom4te.in, autoscan.in, ifnames.in,
+ * autoheader.in, autoreconf.in, autoupdate.in: Move to...
+ * bin: here, new directory.
+ * lib/Autoconf: Rename as...
+ * lib/Autom4te: this, to please case insensitive junkie OSes.
+
2001-08-01 Akim Demaille <akim@epita.fr>
* autom4te.in ($m4): Handle the --nesting-limit.
AUTOMAKE_OPTIONS = check-news 1.4 readme-alpha
-SUBDIRS = . lib config m4 man doc tests
+SUBDIRS = . lib bin config m4 man doc tests
## There is currently no means with Automake not to run aclocal.
ACLOCAL_AMFLAGS = --version >/dev/null && touch aclocal.m4
WGET = wget
-bin_SCRIPTS = autom4te \
- autoconf autoheader autoreconf ifnames autoscan autoupdate
-
# FIXME:
# s/distpackageDATA/dist_pkgdata_DATA/
# s/nodistpackageDATA/nodist_pkgdata_DATA/
# and adapt dependencies once we use a more recent Automake
-m4sources = lib/m4sugar/m4sugar.m4 lib/m4sugar/m4sh.m4 \
- $(srcdir)/lib/autoconf/version.m4 \
- lib/autoconf/autoconf.m4 \
- lib/autoconf/general.m4 lib/autoconf/oldnames.m4 \
- lib/autoconf/specific.m4 lib/autoconf/lang.m4 \
- lib/autoconf/functions.m4 lib/autoconf/headers.m4 \
- lib/autoconf/types.m4
-
EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 \
BUGS INSTALL.txt \
- autoconf.in autoheader.in autoreconf.in autoupdate.in ifnames.in \
- autoscan.in autom4te.in \
GNUmakefile Makefile.maint
-# Files that should be removed, but which Automake does not know.
-CLEANFILES = $(bin_SCRIPTS)
-
## ------------------ ##
## Maintainer rules. ##
done
-## ------------- ##
-## The scripts. ##
-## ------------- ##
-
-edit = sed \
- -e 's,@SHELL\@,$(SHELL),g' \
- -e 's,@PERL\@,$(PERL),g' \
- -e 's,@bindir\@,$(bindir),g' \
- -e 's,@datadir\@,$(pkgdatadir),g' \
- -e 's,@prefix\@,$(prefix),g' \
- -e 's,@autoconf-name\@,'`echo autoconf | sed '$(transform)'`',g' \
- -e 's,@autoheader-name\@,'`echo autoheader | sed '$(transform)'`',g' \
- -e 's,@autom4te-name\@,'`echo autom4te | sed '$(transform)'`',g' \
- -e 's,@M4\@,$(M4),g' \
- -e 's,@AWK\@,$(AWK),g' \
- -e 's,@VERSION\@,$(VERSION),g' \
- -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g'
-
-## All the scripts below depend on configure.ac so that they are rebuilt
-## when the Autoconf version changes. Unfortunately, suffix rules cannot
-## have additional dependencies, so we have to use explicit rules for
-## every script.
-
-autoconf: $(srcdir)/autoconf.in $(srcdir)/configure.ac
- rm -f autoconf autoconf.tmp
- $(edit) $(srcdir)/autoconf.in >autoconf.tmp
- chmod +x autoconf.tmp
- mv autoconf.tmp autoconf
-
-autoheader: $(srcdir)/autoheader.in $(srcdir)/configure.ac
- rm -f autoheader autoheader.tmp
- $(edit) $(srcdir)/autoheader.in >autoheader.tmp
- chmod +x autoheader.tmp
- mv autoheader.tmp autoheader
-
-autoreconf: $(srcdir)/autoreconf.in $(srcdir)/configure.ac
- rm -f autoreconf autoreconf.tmp
- $(edit) $(srcdir)/autoreconf.in >autoreconf.tmp
- chmod +x autoreconf.tmp
- mv autoreconf.tmp autoreconf
-
-autoupdate: $(srcdir)/autoupdate.in $(srcdir)/configure.ac
- rm -f autoupdate autoupdate.tmp
- $(edit) $(srcdir)/autoupdate.in >autoupdate.tmp
- chmod +x autoupdate.tmp
- mv autoupdate.tmp autoupdate
-
-ifnames: $(srcdir)/ifnames.in $(srcdir)/configure.ac
- rm -f ifnames ifnames.tmp
- $(edit) $(srcdir)/ifnames.in >ifnames.tmp
- chmod +x ifnames.tmp
- mv ifnames.tmp ifnames
-
-autoscan: $(srcdir)/autoscan.in $(srcdir)/configure.ac
- rm -f autoscan autoscan.tmp
- $(edit) $(srcdir)/autoscan.in >autoscan.tmp
- chmod +x autoscan.tmp
- mv autoscan.tmp autoscan
-
-autom4te: $(srcdir)/autom4te.in $(srcdir)/configure.ac
- rm -f autom4te autom4te.tmp
- $(edit) $(srcdir)/autom4te.in >autom4te.tmp
- chmod +x autom4te.tmp
- mv autom4te.tmp autom4te
-
-
## ---------------------------- ##
## Customizing Makefile.maint. ##
## ---------------------------- ##
AUTOMAKE_OPTIONS = check-news 1.4 readme-alpha
-SUBDIRS = . lib config m4 man doc tests
+SUBDIRS = . lib bin config m4 man doc tests
ACLOCAL_AMFLAGS = --version >/dev/null && touch aclocal.m4
WGET = wget
-bin_SCRIPTS = autom4te autoconf autoheader autoreconf ifnames autoscan autoupdate
-
-
# FIXME:
# s/distpackageDATA/dist_pkgdata_DATA/
# s/nodistpackageDATA/nodist_pkgdata_DATA/
# and adapt dependencies once we use a more recent Automake
-m4sources = lib/m4sugar/m4sugar.m4 lib/m4sugar/m4sh.m4 $(srcdir)/lib/autoconf/version.m4 lib/autoconf/autoconf.m4 lib/autoconf/general.m4 lib/autoconf/oldnames.m4 lib/autoconf/specific.m4 lib/autoconf/lang.m4 lib/autoconf/functions.m4 lib/autoconf/headers.m4 lib/autoconf/types.m4
-
-
-EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 BUGS INSTALL.txt autoconf.in autoheader.in autoreconf.in autoupdate.in ifnames.in autoscan.in autom4te.in GNUmakefile Makefile.maint
+EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 BUGS INSTALL.txt GNUmakefile Makefile.maint
-# Files that should be removed, but which Automake does not know.
-CLEANFILES = $(bin_SCRIPTS)
-
# INSTALL is a special case. Automake seems to have a single name space
# for both targets and variables. If we just use INSTALL, then the var
# $(INSTALL) is not defined, and the install target fails.
MAINTAINERCLEANFILES = INSTALL.txt
-edit = sed -e 's,@SHELL\@,$(SHELL),g' -e 's,@PERL\@,$(PERL),g' -e 's,@bindir\@,$(bindir),g' -e 's,@datadir\@,$(pkgdatadir),g' -e 's,@prefix\@,$(prefix),g' -e 's,@autoconf-name\@,'`echo autoconf | sed '$(transform)'`',g' -e 's,@autoheader-name\@,'`echo autoheader | sed '$(transform)'`',g' -e 's,@autom4te-name\@,'`echo autom4te | sed '$(transform)'`',g' -e 's,@M4\@,$(M4),g' -e 's,@AWK\@,$(AWK),g' -e 's,@VERSION\@,$(VERSION),g' -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g'
-
-
prev_version_file = $(srcdir)/config/prev-version.txt
release_archive_dir = releases
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
CONFIG_CLEAN_FILES =
-SCRIPTS = $(bin_SCRIPTS)
-
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
Makefile.in NEWS README-alpha THANKS TODO aclocal.m4 configure \
configure.ac
$(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
-install-binSCRIPTS: $(bin_SCRIPTS)
- @$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(bindir)
- @list='$(bin_SCRIPTS)'; for p in $$list; do \
- if test -f $$p; then \
- echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
- $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
- else if test -f $(srcdir)/$$p; then \
- echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
- $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
- else :; fi; fi; \
- done
-
-uninstall-binSCRIPTS:
- @$(NORMAL_UNINSTALL)
- list='$(bin_SCRIPTS)'; for p in $$list; do \
- rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
- done
-
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
check: check-recursive
installcheck-am:
installcheck: installcheck-recursive
-install-exec-am: install-binSCRIPTS
+install-exec-am:
install-exec: install-exec-recursive
install-data-am:
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-recursive
-uninstall-am: uninstall-binSCRIPTS
+uninstall-am:
uninstall: uninstall-recursive
-all-am: Makefile $(SCRIPTS)
+all-am: Makefile
all-redirect: all-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs-recursive
installdirs-am:
- $(mkinstalldirs) $(DESTDIR)$(bindir)
mostlyclean-generic:
clean-generic:
- -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean: maintainer-clean-recursive
-rm -f config.status
-.PHONY: uninstall-binSCRIPTS install-binSCRIPTS install-data-recursive \
-uninstall-data-recursive install-exec-recursive \
-uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
-all-recursive check-recursive installcheck-recursive info-recursive \
-dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
+.PHONY: install-data-recursive uninstall-data-recursive \
+install-exec-recursive uninstall-exec-recursive installdirs-recursive \
+uninstalldirs-recursive all-recursive check-recursive \
+installcheck-recursive info-recursive dvi-recursive \
+mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
$(INSTALL_DATA) $$d$$p.txt $(DESTDIR)$(pkgdatadir)/$$f; \
done
-autoconf: $(srcdir)/autoconf.in $(srcdir)/configure.ac
- rm -f autoconf autoconf.tmp
- $(edit) $(srcdir)/autoconf.in >autoconf.tmp
- chmod +x autoconf.tmp
- mv autoconf.tmp autoconf
-
-autoheader: $(srcdir)/autoheader.in $(srcdir)/configure.ac
- rm -f autoheader autoheader.tmp
- $(edit) $(srcdir)/autoheader.in >autoheader.tmp
- chmod +x autoheader.tmp
- mv autoheader.tmp autoheader
-
-autoreconf: $(srcdir)/autoreconf.in $(srcdir)/configure.ac
- rm -f autoreconf autoreconf.tmp
- $(edit) $(srcdir)/autoreconf.in >autoreconf.tmp
- chmod +x autoreconf.tmp
- mv autoreconf.tmp autoreconf
-
-autoupdate: $(srcdir)/autoupdate.in $(srcdir)/configure.ac
- rm -f autoupdate autoupdate.tmp
- $(edit) $(srcdir)/autoupdate.in >autoupdate.tmp
- chmod +x autoupdate.tmp
- mv autoupdate.tmp autoupdate
-
-ifnames: $(srcdir)/ifnames.in $(srcdir)/configure.ac
- rm -f ifnames ifnames.tmp
- $(edit) $(srcdir)/ifnames.in >ifnames.tmp
- chmod +x ifnames.tmp
- mv ifnames.tmp ifnames
-
-autoscan: $(srcdir)/autoscan.in $(srcdir)/configure.ac
- rm -f autoscan autoscan.tmp
- $(edit) $(srcdir)/autoscan.in >autoscan.tmp
- chmod +x autoscan.tmp
- mv autoscan.tmp autoscan
-
-autom4te: $(srcdir)/autom4te.in $(srcdir)/configure.ac
- rm -f autom4te autom4te.tmp
- $(edit) $(srcdir)/autom4te.in >autom4te.tmp
- chmod +x autom4te.tmp
- mv autom4te.tmp autom4te
-
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+++ /dev/null
-#! @SHELL@
-# -*- shell-script -*-
-# autoconf -- create `configure' using m4 macros
-# Copyright 1992, 1993, 1994, 1996, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-
-# This program 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; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-me=`echo "$0" | sed -e 's,.*[\\/],,'`
-
-usage="\
-Usage: $0 [OPTION] ... [TEMPLATE-FILE]
-
-Generate a configuration script from a TEMPLATE-FILE if given, or
-\`configure.ac' if present, or else \`configure.in'. Output is sent
-to the standard output if TEMPLATE-FILE is given, else into
-\`configure'.
-
-Operation modes:
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
- -d, --debug don't remove temporary files
- -o, --output=FILE save output in FILE (stdout is the default)
- -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
-
-Warning categories include:
- \`cross' cross compilation issues
- \`obsolete' obsolete constructs
- \`syntax' dubious syntactic constructs
- \`all' all the warnings
- \`no-CATEGORY' turn off the warnings on CATEGORY
- \`none' turn off all the warnings
- \`error' warnings are error
-
-The environment variable \`WARNINGS' is honored.
-
-Library directories:
- -A, --autoconf-dir=ACDIR Autoconf's macro files location (rarely needed)
- -l, --localdir=DIR location of the \`aclocal.m4' file
-
-Tracing:
- -t, --trace=MACRO report the list of calls to MACRO
- -i, --initialization also trace Autoconf's initialization process
-
-In tracing mode, no configuration script is created.
-
-Report bugs to <bug-autoconf@gnu.org>."
-
-version="\
-autoconf (@PACKAGE_NAME@) @VERSION@
-Written by David J. MacKenzie.
-
-Copyright 1992, 1993, 1994, 1996, 1999, 2000, 2001
-Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="\
-Try \`$me --help' for more information."
-
-exit_missing_arg="\
-echo \"$me: option \\\`\$1' requires an argument\" >&2
-echo \"\$help\" >&2
-exit 1"
-
-# NLS nuisances.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-
-# Variables.
-: ${autoconf_dir=${AC_MACRODIR=@datadir@}}
-debug=false
-dir=`echo "$0" | sed -e 's,[^\\/]*$,,'`
-# Trace Autoconf's initialization?
-initialization=false
-localdir=.
-outfile=
-# Exit status.
-status=0
-verbose=:
-
-# We test "$dir/autom4te" in case we are in the build tree, in which case
-# the names are not transformed yet.
-for autom4te in "$AUTOM4TE" \
- "$dir/@autom4te-name@" \
- "$dir/autom4te" \
- "@bindir@/@autom4te-name@"; do
- test -f "$autom4te" && break
-done
-
-
-# Parse command line.
-while test $# -gt 0 ; do
- optarg=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
- "x$1" : 'x-.\(.*\)'`
- case $1 in
- --version | -V )
- echo "$version" ; exit 0 ;;
- --help | -h )
- echo "$usage"; exit 0 ;;
-
- --debug | -d )
- debug=:; shift ;;
- --verbose | -v )
- verbose=echo
- shift;;
-
- --localdir=* | -l?* )
- localdir=$optarg
- shift ;;
- --localdir | -l )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- localdir=$1
- shift ;;
-
- --autoconf-dir=* | -A?* )
- autoconf_dir=$optarg
- shift ;;
- --autoconf-dir | -A )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- autoconf_dir=$1
- shift ;;
- --macrodir=* | -m?* )
- echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
- autoconf_dir=$optarg
- shift ;;
- --macrodir | -m )
- echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
- test $# = 1 && eval "$exit_missing_arg"
- shift
- autoconf_dir=$1
- shift ;;
-
- --trace=* | -t?* )
- traces="$traces --trace='"`echo "$optarg" | sed "s/'/'\\\\\\\\''/g"`"'"
- shift ;;
- --trace | -t )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- traces="$traces --trace='"`echo "$1" | sed "s/'/'\\\\\\\\''/g"`"'"
- shift ;;
- --initialization | -i )
- initialization=:
- shift;;
-
- --output=* | -o?* )
- outfile=$optarg
- shift ;;
- --output | -o )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- outfile=$1
- shift ;;
-
- --warnings=* | -W?* )
- warnings=$warnings,$optarg
- shift ;;
- --warnings | -W )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- warnings=$warnings,$1
- shift ;;
-
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- exec >&2
- echo "$me: invalid option $1"
- echo "$help"
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-# Find the input file.
-case $# in
- 0)
- case `ls configure.ac configure.in 2>/dev/null` in
- *ac*in )
- echo "$me: warning: both \`configure.ac' and \`configure.in' are present." >&2
- echo "$me: warning: proceeding with \`configure.ac'." >&2
- infile=configure.ac;;
- *ac ) infile=configure.ac;;
- *in ) infile=configure.in;;
- * )
- echo "$me: no input file" >&2
- exit 1;;
- esac
- test -z "$traces" && test -z "$outfile" && outfile=configure;;
- 1) # autom4te doesn't like `-'.
- test "x$1" != "x-" && infile=$1 ;;
- *) exec >&2
- echo "$me: invalid number of arguments."
- echo "$help"
- (exit 1); exit 1 ;;
-esac
-
-# Unless specified, the output is stdout.
-test -z "$outfile" && outfile=-
-
-# Running autom4te.
-run_autom4te="$autom4te "\
-`$verbose "--verbose "`\
-`$debug && echo "--debug "`\
-"--include $autoconf_dir --include $localdir "\
-"--warning syntax,$warnings "\
-"autoconf/autoconf.m4"`$initialization || echo f`" "\
-`test -f "$autoconf_dir/acsite.m4" && echo "$autoconf_dir/acsite.m4"`" "\
-`test -f "$localdir/aclocal.m4" && echo "$localdir/aclocal.m4"`
-
-# Autom4te expansion.
-eval set dummy "$traces"
-shift
-$verbose "$me: running $run_autom4te ""$@"" $infile --output $outfile" >&2
-$run_autom4te "$@" $infile --output $outfile ||
- { (exit 1); exit 1; }
-
-if test -z "$traces" && test "x$outfile" != x-; then
- chmod +x $outfile
-fi
-
-(exit $status); exit $status
+++ /dev/null
-#! @SHELL@
-# -*- shell-script -*-
-# autoheader -- create `config.h.in' from `configure.ac'
-# Copyright 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-
-# This program 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; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# Written by Roland McGrath.
-
-me=`echo "$0" | sed -e 's,.*[/\\],,'`
-
-usage="\
-Usage: $0 [OPTION] ... [TEMPLATE-FILE]
-
-Create a template file of C \`#define' statements for \`configure' to
-use. To this end, scan TEMPLATE-FILE, or \`configure.ac' if present,
-or else \`configure.in'.
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
- -d, --debug don't remove temporary files
- -W, --warnings=CATEGORY report the warnings falling in CATEGORY
-
-Warning categories include:
- \`obsolete' obsolete constructs
- \`all' all the warnings
- \`no-CATEGORY' turn off the warnings on CATEGORY
- \`none' turn off all the warnings
- \`error' warnings are error
-
-Library directories:
- -A, --autoconf-dir=ACDIR Autoconf's macro files location (rarely needed)
- -l, --localdir=DIR location of \`aclocal.m4' and \`acconfig.h'
-
-Report bugs to <bug-autoconf@gnu.org>."
-
-version="\
-autoheader (@PACKAGE_NAME@) @VERSION@
-Written by Roland McGrath.
-
-Copyright 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2001
-Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="\
-Try \`$me --help' for more information."
-
-exit_missing_arg="\
-echo \"$me: option \\\`\$1' requires an argument\" >&2
-echo \"\$help\" >&2
-exit 1"
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# Variables.
-: ${autoconf_dir=${AC_MACRODIR=@datadir@}}
-dir=`echo "$0" | sed -e 's,[^/]*$,,'`
-# We test "$dir/autoconf" in case we are in the build tree, in which case
-# the names are not transformed yet.
-for autoconf in "$AUTOCONF" \
- "$dir/@autoconf-name@" \
- "$dir/autoconf" \
- "@bindir@/@autoconf-name@"; do
- test -f "$autoconf" && break
-done
-debug=false
-localdir=.
-status=0
-tmp=
-verbose=:
-warning_all=false
-warning_error=false
-warning_obsolete=false
-
-# Parse command line.
-while test $# -gt 0 ; do
- optarg=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
- "x$1" : 'x-.\(.*\)'`
- case $1 in
- --version | -V )
- echo "$version" ; exit 0 ;;
- --help | -h )
- echo "$usage"; exit 0 ;;
-
- --debug | -d )
- debug=:; shift ;;
- --verbose | -v )
- verbose=echo
- shift;;
-
- --localdir=* | -l?* )
- localdir=$optarg
- shift ;;
- --localdir | -l )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- localdir=$1
- shift ;;
-
- --autoconf-dir=* | -A?* )
- autoconf_dir=$optarg
- shift ;;
- --autoconf-dir | -A )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- autoconf_dir=$1
- shift ;;
- --macrodir=* | -m?* )
- echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
- autoconf_dir=$optarg
- shift ;;
- --macrodir | -m )
- echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
- test $# = 1 && eval "$exit_missing_arg"
- shift
- autoconf_dir=$1
- shift ;;
-
- --warnings=* | -W?* )
- warnings=$warnings,$optarg
- shift ;;
- --warnings | -W )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- warnings=$warnings,$1
- shift ;;
-
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- exec >&2
- echo "$me: invalid option $1"
- echo "$help"
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-# The warnings are the concatenation of 1. application's defaults
-# (here, none), 2. $WARNINGS, $3 command line options, in that order.
-alphabet='abcdefghijklmnopqrstuvwxyz'
-ALPHABET='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-_ac_warnings=
-for warning in `IFS=,; echo $WARNINGS,$warnings | tr $ALPHABET $alphabet`
-do
- case $warning in
- '' | ,) continue;;
- no-*) eval warning_`expr x$warning : 'xno-\(.*\)'`=false;;
- *) eval warning_$warning=:;;
- esac
-done
-
-# Trap on 0 to stop playing with `rm'.
-$debug ||
-{
- trap 'status=$?; rm -rf $tmp && exit $status' 0
- trap '(exit 1); exit 1' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-: ${TMPDIR=/tmp}
-{
- tmp=`(umask 077 && mktemp -d -q "$TMPDIR/ahXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=$TMPDIR/ah$$
- (umask 077 && mkdir $tmp)
-} ||
-{
- echo "$me: cannot create a temporary directory in $TMPDIR" >&2
- (exit 1); exit 1
-}
-
-# Preach.
-if ($warning_all || $warning_obsolete) &&
- (test -f $config_h.top ||
- test -f $config_h.bot ||
- test -f $localdir/acconfig.h); then
- sed -e "s/^ /$me: WARNING: /" >&2 <<\EOF
- Using auxiliary files such as `acconfig.h', `config.h.bot'
- and `config.h.top', to define templates for `config.h.in'
- is deprecated and discouraged.
-
- Using the third argument of `AC_DEFINE' and
- `AC_DEFINE_UNQUOTED' allows to define a template without
- `acconfig.h':
-
- AC_DEFINE([NEED_MAIN], 1,
- [Define if a function `main' is needed.])
-
- More sophisticated templates can also be produced, see the
- documentation.
-EOF
- $warning_error && { (exit 1); exit 1; }
-fi
-
-acconfigs=
-test -r $localdir/acconfig.h && acconfigs="$acconfigs $localdir/acconfig.h"
-
-# Find the input file.
-case $# in
- 0)
- case `ls configure.ac configure.in 2>/dev/null` in
- *ac*in )
- echo "$me: warning: both \`configure.ac' and \`configure.in' are present." >&2
- echo "$me: warning: proceeding with \`configure.ac'." >&2
- infile=configure.ac;;
- *ac ) infile=configure.ac;;
- *in ) infile=configure.in;;
- * )
- echo "$me: no input file" >&2
- (exit 1); exit 1;;
- esac
- infilename=$infile
- ;;
- 1) if test "x$1" = "x-"; then
- cat >$tmp/stdin
- infile=$tmp/stdin
- else
- infile=$1
- fi
- infilename="Standard input"
- ;;
- *) exec >&2
- echo "$me: invalid number of arguments."
- echo "$help"
- (exit 1); exit 1;;
-esac
-
-# Set up autoconf.
-autoconf="$autoconf -l $localdir "\
-`$verbose "--verbose "`\
-`$debug && echo "--debug "`
-export autoconf_dir
-
-# ----------------------- #
-# Real work starts here. #
-# ----------------------- #
-
-# Source what the traces are trying to tell us.
-$verbose $me: running $autoconf to trace from $infile >&2
-$autoconf \
- --trace AC_CONFIG_HEADERS:': $${config_h="$1"}' \
- --trace AH_OUTPUT:'ac_verbatim_$1="\
-$2"' \
- --trace AC_DEFINE_TRACE_LITERAL:'syms="$$syms $1"' \
- $infile >$tmp/traces.sh || { (exit 1); exit 1; }
-
-$verbose $me: sourcing $tmp/traces.sh >&2
-if (set -e && . $tmp/traces.sh) >/dev/null 2>&1; then
- . $tmp/traces.sh
-else
- echo "$me: error: shell error while sourcing $tmp/traces.sh" >&2
- (exit 1); exit 1
-fi
-
-
-# Make SYMS newline-separated rather than blank-separated, and remove dups.
-# Start each symbol with a blank (to match the blank after "#undef")
-# to reduce the possibility of mistakenly matching another symbol that
-# is a substring of it.
-# Beware that some of the symbols might actually be macro with arguments:
-# keep only their name.
-syms=`for sym in $syms; do echo $sym; done |
- sed -e 's/(.*//' |
- sort |
- uniq |
- sed -e 's@^@ @'`
-
-
-# We template only the first CONFIG_HEADER.
-config_h=`set X $config_h; echo $2`
-# Support "outfile[:infile]", defaulting infile="outfile.in".
-case "$config_h" in
-"") echo "$me: error: AC_CONFIG_HEADERS not found in $infile" >&2
- (exit 1); exit 1 ;;
-*:*) config_h_in=`echo "$config_h" | sed 's/.*://'`
- config_h=`echo "$config_h" | sed 's/:.*//'` ;;
-*) config_h_in="$config_h.in" ;;
-esac
-
-# Don't write "do not edit" -- it will get copied into the
-# config.h, which it's ok to edit.
-cat <<EOF >$tmp/config.hin
-/* $config_h_in. Generated automatically from $infilename by autoheader. */
-EOF
-
-# Dump the top.
-test -r $config_h.top && cat $config_h.top >>$tmp/config.hin
-
-# Dump `acconfig.h' but its bottom.
-test -r $localdir/acconfig.h &&
- sed '/@BOTTOM@/,$d;s/@TOP@//' $localdir/acconfig.h >>$tmp/config.hin
-
-# Dump the templates from `configure.ac'.
-for verb in `(set) 2>&1 | sed -n -e '/^ac_verbatim/s/^\([^=]*\)=.*$/\1/p' | sort`; do
- eval value=\$$verb
- cat >>$tmp/config.hin <<EOF
-
-$value
-EOF
-done
-
-# Handle the case where @BOTTOM@ is the first line of acconfig.h.
-test -r $localdir/acconfig.h &&
- grep @BOTTOM@ $localdir/acconfig.h >/dev/null &&
- sed -n '/@BOTTOM@/,${/@BOTTOM@/!p;}' $localdir/acconfig.h >>$tmp/config.hin
-test -f $config_h.bot && cat $config_h.bot >>$tmp/config.hin
-
-
-# Check that all the symbols have a template.
-$verbose $me: checking completeness of the template >&2
-# Regexp for a white space.
-w='[ ]'
-if test -n "$syms"; then
- for sym in $syms; do
- if egrep "^#$w*[a-z]*$w$w*$sym($w*|$w.*)$" $tmp/config.hin >/dev/null; then
- : # All is well.
- else
- echo "$me: No template for symbol \`$sym'" >&2
- status=1
- fi
- done
-fi
-
-
-# If the run was successful, output the result.
-if test $status = 0; then
- if test $# = 0; then
- # Output is a file
- if test -f $config_h_in && cmp -s $tmp/config.hin $config_h_in; then
- # File didn't change, so don't update its mod time.
- echo "$me: $config_h_in is unchanged" >&2
- else
- mv -f $tmp/config.hin $config_h_in
- fi
- else
- # Output is stdout
- cat $tmp/config.hin
- fi
-fi
-
-(exit $status); exit $status
+++ /dev/null
-#! @PERL@ -w
-# -*- perl -*-
-# @configure_input@
-
-eval 'exec @PERL@ -S $0 ${1+"$@"}'
- if 0;
-
-# autom4te - Wrapper around M4 libraries.
-# Copyright 2001 Free Software Foundation, Inc.
-
-# This program 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; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-require 5.005;
-use File::Basename;
-
-my $me = basename ($0);
-
-## --------- ##
-## Request. ##
-## --------- ##
-
-package Request;
-
-BEGIN
-{
- my $prefix = "@prefix@";
- # FIXME: Import Struct into Autoconf.
- my $perllibdir = $ENV{'autom4te_perllibdir'} || "@datadir@";
- unshift @INC, "$perllibdir";
-}
-
-use Data::Dumper;
-use Autoconf::Struct;
-use Carp;
-use Getopt::Long;
-use IO::File;
-use File::Spec;
-use strict;
-
-# List of requests.
-# We can't declare it `my' as the loading, performed via `do',
-# would refer to another scope, and @request would not be updated.
-# It used to work with `my' vars, and I don't know whether the current
-# behavior (5.6) is wanted or not.
-use vars qw(@request);
-
-struct
- (
- # The key of the cache file.
- 'cache' => "\$",
- # True if the cache file is up to date.
- 'valid' => "\$",
- # The include path.
- 'path' => '@',
- # The set of source files.
- 'source' => '@',
- # The set of included files.
- 'includes' => '@',
- # The set of macros currently traced.
- 'macro' => '%',
- );
-
-
-# Find a request with the same path and source.
-sub retrieve
-{
- my ($self, %attr) = @_;
-
- foreach (@request)
- {
- # Same path.
- next
- if join ("\n", @{$_->path}) ne join ("\n", @{$attr{path}});
-
- # Same sources.
- next
- if join ("\n", @{$_->source}) ne join ("\n", @{$attr{source}});
-
- # Found it.
- return $_;
- }
-
- return undef;
-}
-
-# NEW should not be called directly.
-sub register
-{
- my ($self, %attr) = @_;
-
- # path and source are the only ID for a request object.
- my $obj = $self->new ('path' => $attr{path},
- 'source' => $attr{source});
- push @request, $obj;
-
- # Assign a cache file.
- $obj->cache ("traces.$#request");
-
- return $obj;
-}
-
-
-# request(%REQUEST)
-# -----------------
-# Return a request corresponding to $REQUEST{path} and $REQUEST{source},
-# using a cache value if it exists.
-sub request
-{
- my ($self, %request) = @_;
-
- my $obj = Request->retrieve (%request) || Request->register (%request);
-
- # If there are new traces to produce, then we are not valid.
- foreach (@{$request{'macro'}})
- {
- if (! exists ${$obj->macro}{$_})
- {
- # FIXME: This is too rough an approximation: we should have
- # a means to select only M4 builtins, but @m4_builtins is not
- # visible here.
- s/^m4_//;
- ${$obj->macro}{$_} = 1;
- ${$obj->macro}{"m4_$_"} = 1;
- $obj->valid (0);
- }
- }
-
- return $obj;
-}
-
-# Serialize a request or all the current requests.
-sub marshall
-{
- my ($caller) = @_;
- my $res = '';
-
- if (ref ($caller))
- {
- # CALLER is an object: instance method.
- my $marshall = Data::Dumper->new ([$caller]);
- $marshall->Indent(2)->Terse(0);
- $res = $marshall->Dump . "\n";
- }
- else
- {
- # CALLER is the package: class method.
- my $marshall = Data::Dumper->new ([\@request], [qw (*request)]);
- $marshall->Indent(2)->Terse(0);
- $res = $marshall->Dump . "\n";
- }
-
- return $res;
-}
-
-
-# includes_p (@MACRO)
-# -------------------
-# Does this request covers all the @MACRO.
-sub includes_p
-{
- my ($self, @macro) = @_;
-
- foreach (@macro)
- {
- return 0
- if ! exists ${$self->macro}{$_};
- }
- return 1;
-}
-
-
-# SAVE ($FILENAME)
-# ----------------
-sub save
-{
- my ($self, $filename) = @_;
-
- croak "$me: cannot save a single request\n"
- if ref ($self);
-
- my $requests = new IO::File ("> $filename")
- or die "$me: cannot create $filename: $!\n";
- print $requests
- "# This file was created by $me.\n",
- "# It contains the lists of macros which have been traced.\n",
- "# It can be safely removed.\n",
- "\n",
- $self->marshall;
-}
-
-
-# LOAD ($FILENAME)
-# ----------------
-sub load
-{
- my ($self, $filename) = @_;
-
- croak "$me: cannot load a single request\n"
- if ref ($self);
-
- (my $return) = do "$filename";
-
- croak "$me: cannot parse $filename: $@\n" if $@;
- croak "$me: cannot do $filename: $!\n" if $!;
- croak "$me: cannot run $filename\n" unless $return;
-}
-
-
-## ---------- ##
-## Autom4te. ##
-## ---------- ##
-
-package Autom4te;
-
-use Getopt::Long;
-use File::Basename;
-use IO::File;
-use strict;
-
-# Our tmp dir.
-my $tmp;
-
-# The macros we always trace.
-my @required_trace =
- (
- # We need `include' to find the dependencies.
- 'include', 'm4_include',
- # These are wanted by autoheader.
- 'AC_CONFIG_HEADERS',
- 'AH_OUTPUT',
- 'AC_DEFINE_TRACE_LITERAL',
- # These will be traced by Automake.
- 'AC_SUBST',
- 'AC_LIBSOURCE',
- );
-
-# The macros to trace mapped to their format, as specified by the
-# user.
-my %trace;
-
-my $verbose = 0;
-my $debug = 0;
-my $output = '-';
-my @warning;
-
-# M4 include path.
-my @include;
-
-# 0 for EXIT_SUCCESS.
-my $exit_status = 0;
-
-# $M4.
-my $m4 = $ENV{"M4"} || '@M4@';
-# Some non-GNU m4's don't reject the --help option, so give them /dev/null.
-die "$me: need GNU m4 1.4 or later: $m4\n"
- if system "$m4 --help </dev/null 2>&1 | fgrep reload-state >/dev/null";
-
-# Set some high recursion limit as the default limit, 250, has already
-# been hit with AC_OUTPUT. Don't override the user's choice.
-$m4 .= ' --nesting-limit=1024'
- if " $m4 " !~ / (--nesting-limit|-L) /;
-
-# @M4_BUILTINS -- M4 builtins and a useful comment.
-my @m4_builtins = `echo dumpdef | $m4 2>&1 >/dev/null`;
-map { s/:.*//;s/\W// } @m4_builtins;
-
-
-## ---------- ##
-## Routines. ##
-## ---------- ##
-
-
-# mktmpdir ($SIGNATURE)
-# ---------------------
-# Create a temporary directory which name is based on $SIGNATURE.
-sub mktmpdir ($)
-{
- my ($signature) = @_;
- my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
-
- # If mktemp supports dirs, use it.
- $tmp = `(umask 077 &&
- mktemp -d -q "$TMPDIR/${signature}XXXXXX") 2>/dev/null`;
- chomp $tmp;
-
- if (!$tmp || ! -d $tmp)
- {
- $tmp = "$TMPDIR/$signature" . int (rand 10000) . ".$$";
- mkdir $tmp, 0700
- or die "$me: cannot create $tmp: $!\n";
- }
-
- print STDERR "$me:$$: working in $tmp\n"
- if $debug;
-}
-
-
-# verbose
-# -------
-sub verbose (@)
-{
- print STDERR "$me: ", @_, "\n"
- if $verbose;
-}
-
-
-# END
-# ---
-# Exit nonzero whenever closing STDOUT fails.
-sub END
-{
- use POSIX qw (_exit);
-
- my ($q) = ($?);
-
- # FIXME: Heelp! Can't find a means to properly catch system's
- # exit status (without hair I mean).
- # my $status = $? >> 8;
-
- if (!$debug && defined $tmp && -d $tmp)
- {
- if (<$tmp/*>)
- {
- unlink <$tmp/*>
- or warn ("$me: cannot empty $tmp: $!\n"), _exit (1);
- }
- rmdir $tmp
- or warn ("$me: cannot remove $tmp: $!\n"), _exit (1);
- }
-
- # This is required if the code might send any output to stdout
- # E.g., even --version or --help. So it's best to do it unconditionally.
- close STDOUT
- or (warn "$me: closing standard output: $!\n"), _exit (1);
-
- ($!, $?) = (0, $q);
-}
-
-
-# xsystem ($COMMAND)
-# ------------------
-sub xsystem ($)
-{
- my ($command) = @_;
-
- verbose "running: $command";
-
- (system $command) == 0
- or die ("$me: "
- . (split (' ', $command))[0]
- . " failed with exit status: "
- . ($? >> 8)
- . "\n");
-}
-
-
-# $FILENAME
-# find_file ($FILENAME)
-# ---------------------
-# We match exactly the behavior of GNU m4: first look in the current
-# directory (which includes the case of absolute file names), and, if
-# the file is not absolute, just fail. Otherwise, look in the path.
-sub find_file ($)
-{
- my ($filename) = @_;
-
- return File::Spec->canonpath ($filename)
- if -f $filename;
-
- die "$me: no such file or directory: $filename\n"
- if File::Spec->file_name_is_absolute ($filename);
-
- foreach my $path (@include)
- {
- return File::Spec->canonpath (File::Spec->catfile ($path, $filename))
- if -f File::Spec->catfile ($path, $filename)
- }
-
- die "$me: no such file or directory: $filename\n";
-}
-
-
-# print_usage ()
-# --------------
-# Display usage (--help).
-sub print_usage ()
-{
- print <<EOF;
-Usage: $0 [OPTION] ... [TEMPLATE-FILE]
-
-Generate a configuration script from a TEMPLATE-FILE if given, or
-`configure.ac' if present, or else `configure.in'. Output is sent
-to the standard output if TEMPLATE-FILE is given, else into
-`configure'.
-
-Operation modes:
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
- -d, --debug don't remove temporary files
- -o, --output=FILE save output in FILE (stdout is the default)
- -W, --warnings=CATEGORY report the warnings falling in CATEGORY
-
-Warning categories include:
- `cross' cross compilation issues
- `obsolete' obsolete constructs
- `syntax' dubious syntactic constructs
- `all' all the warnings
- `no-CATEGORY' turn off the warnings on CATEGORY
- `none' turn off all the warnings
- `error' warnings are error
-
-The environment variable `WARNINGS' is honored.
-
-Library directories:
- -I, --include=DIR look in DIR. Several invocations accumulate
-
-Tracing:
- -t, --trace=MACRO report the MACRO invocations
-
-Report bugs to <bug-autoconf\@gnu.org>.
-EOF
- # Help font-lock-mode find an closing back quote: `
- exit 0;
-}
-
-
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print <<EOF;
-autom4te (@PACKAGE_NAME@) @VERSION@
-Written by Akim Demaille.
-
-Copyright 2001 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-EOF
-
- exit 0;
-}
-
-
-# parse_args ()
-# -------------
-# Process any command line arguments.
-sub parse_args ()
-{
- my @trace;
-
- Getopt::Long::config ("bundling");
- GetOptions
- (
- # Operation modes:
- "h|help" => \&print_usage,
- "V|version" => \&print_version,
- "v|verbose" => \$verbose,
- "d|debug" => \$debug,
- "o|output=s" => \$output,
- "W|warnings=s" => \@warning,
-
- # Library directories:
- "I|include=s" => \@include,
-
- # Tracing:
- # Using a hash for traces is seducing. Unfortunately, upon `-t FOO',
- # instead of mapping `FOO' to undef, Getopt maps it to `1', preventing
- # us from distinguishing `-t FOO' from `-t FOO=1'. So let's do it
- # by hand.
- "t|trace=s" => \@trace,
- )
- or exit 1;
-
- die "$me: too few arguments
-Try `$me --help' for more information.\n"
- unless @ARGV;
-
- # Convert @trace to %trace.
- # The default format is `$f:$l:$n:$%'.
- foreach (@trace)
- {
- /^([^:]+)(?::(.*))?$/ms;
- $trace{$1} = defined $2 ? $2 : '$f:$l:$n:$%';
- }
-
- # We don't want to depend upon m4's --include to find the top level
- # files. Try to get a canonical name, as it's a key for caching.
- for (my $i = 0; $i < $#ARGV; ++$i)
- {
- $ARGV[$i] = find_file ($ARGV[$i]);
- }
-}
-
-
-# handle_m4 ($REQ, @TRACE)
-# ------------------------
-# Run m4 on the input files, and save the traces on the @TRACE macros.
-sub handle_m4 ($@)
-{
- my ($req, @trace) = @_;
-
- # Find the files. We don't want to depend upon m4's --include.
- # *.m4f files have to be reloaded.
- my $files;
- foreach (@ARGV)
- {
- $files .= ' ';
- $files .= '--reload-state='
- if /\.m4f$/;
- $files .= "$_";
- }
-
- # The warnings are the concatenation of 1. application's defaults,
- # 2. $WARNINGS, $3 command line options, in that order.
- # Set them in the order expected by the M4 macros: the converse.
- my $m4_warnings =
- lc join (',', reverse (split (',', ($ENV{'WARNINGS'} || '')),
- map { split /,/ } @warning));
-
- # GNU m4 appends when using --error-output.
- unlink ("$me.cache/" . $req->cache);
-
- # Run m4.
- my $command = ("$m4"
- . " --define m4_tmpdir=$tmp"
- . " --define m4_warnings=$m4_warnings"
- . ' --debug=aflq'
- . " --error-output=$me.cache/" . $req->cache
- . join (' --trace=', '', @trace)
- . join (' --include=', '', @include)
- . $files
- . " >$tmp/output");
- verbose "running: $command";
- system $command;
- if ($?)
- {
- verbose "$m4: failed with exit status: " . ($? >> 8) . "\n";
- exit $? >> 8;
- }
-}
-
-
-# handle_output ($OUTPUT)
-# -----------------------
-# Run m4 on the input files, perform quadrigraphs substitution, check for
-# forbidden tokens, and save into $OUTPUT.
-sub handle_output ($)
-{
- my ($output) = @_;
-
- verbose "creating $output";
-
- # Load the forbidden/allowed patterns.
- my $forbidden = "^\$";
- if (-f "$tmp/forbidden.rx")
- {
- my $fh = new IO::File ("$tmp/forbidden.rx");
- $forbidden = join ('|', grep { chop } $fh->getlines);
- }
- my $allowed = "^\$";
- if (-f "$tmp/allowed.rx")
- {
- my $fh = new IO::File ("$tmp/allowed.rx");
- $allowed = join ('|', grep { chop } $fh->getlines);
- }
-
- my $out = new IO::File (">$output")
- or die "$me: cannot open $output: $!\n";
- my $in = new IO::File ("$tmp/output")
- or die "$me: cannot read $tmp/output: $!\n";
-
- my $separate = 0;
- my $oline = 0;
- my %prohibited;
- while ($_ = $in->getline)
- {
- s/\s+$//;
- if (/^$/)
- {
- $separate = 1;
- next;
- }
-
- if ($separate)
- {
- $oline++;
- print $out "\n";
- }
- $separate = 0;
-
- $oline++;
- s/__oline__/$oline/g;
- s/\@<:\@/[/g;
- s/\@:>\@/]/g;
- s/\@\$\|\@/\$/g;
- s/\@%:\@/#/g;
-
- print $out "$_\n";
-
- # Don't complain in comments. Well, until we have something
- # better, don't consider `#include' etc. are comments.
- s/\#.*//
- unless /^\#(if|include|endif|ifdef|ifndef|define)\b/;
- foreach (split (/\W+/))
- {
- $prohibited{$_} = $oline
- if /$forbidden/ && !/$allowed/;
- }
- }
-
- # If no forbidden words, we're done.
- return
- if ! %prohibited;
-
- # Locate the forbidden words in the last source file.
- # This is unsatisfying but...
- my $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b';
- my $file = new IO::File ($ARGV[$#ARGV])
- or die "$me: cannot open $ARGV[$#ARGV]: $!\n";
- $exit_status = 1;
-
- while ($_ = $file->getline)
- {
- # Don't complain in comments. Well, until we have something
- # better, don't consider `#include' etc. are comments.
- s/\#.*//
- unless /^\#(if|include|endif|ifdef|ifndef|define)\b/;
-
- # Complain once per word, but possibly several times per line.
- while (/$prohibited/)
- {
- warn "$ARGV[$#ARGV]:$.: error: possibly undefined macro: $1\n";
- delete $prohibited{$1};
- # If we're done, exit.
- return
- if ! %prohibited;
- $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b';
- }
- }
- warn "$output:$prohibited{$_}: error: possibly undefined macro: $_\n"
- foreach (keys %prohibited);
-}
-
-
-## --------------------- ##
-## Handling the traces. ##
-## --------------------- ##
-
-
-# %REQUEST
-# trace_requests (%TRACE)
-# -----------------------
-sub trace_requests
-{
- my (%trace) = @_;
- my %res;
-
- for my $macro (keys %trace)
- {
- $res{$macro} = 1;
- $macro =~ s/^m4_//;
- # See &handle_traces for an explanation for this paragraph.
- if (grep /^$macro$/, @m4_builtins)
- {
- $res{$macro} = 1;
- $res{"m4_$macro"} = 1;
- }
- }
-
- return %res;
-}
-
-
-# $M4_MACRO
-# trace_format_to_m4 ($FORMAT)
-# ----------------------------
-# Convert a trace $FORMAT into a M4 trace processing macro's body.
-sub trace_format_to_m4 ($)
-{
- my ($format) = @_;
- my ($underscore) = $_;
- my %escape = (# File name.
- 'f' => '$1',
- # Line number.
- 'l' => '$2',
- # Depth.
- 'd' => '$3',
- # Name (also available as $0).
- 'n' => '$4',
- # Escaped dollar.
- '$' => '$');
-
- my $res = '';
- $_ = $format;
- while ($_)
- {
- # $n -> $(n + 4)
- if (s/^\$(\d+)//)
- {
- $res .= "\$" . ($1 + 4);
- }
- # $x, no separator given.
- elsif (s/^\$([fldn\$])//)
- {
- $res .= $escape{$1};
- }
- # $.x or ${sep}x.
- elsif (s/^\$\{([^}]*)\}([@*%])//
- || s/^\$(.?)([@*%])//)
- {
- # $@, list of quoted effective arguments.
- if ($2 eq '@')
- {
- $res .= ']at_at([' . ($1 ? $1 : ',') . '], $@)[';
- }
- # $*, list of unquoted effective arguments.
- elsif ($2 eq '*')
- {
- $res .= ']at_star([' . ($1 ? $1 : ',') . '], $@)[';
- }
- # $%, list of flattened unquoted effective arguments.
- elsif ($2 eq '%')
- {
- $res .= ']at_percent([' . ($1 ? $1 : ':') . '], $@)[';
- }
- }
- elsif (/^(\$.)/)
- {
- die "$me: invalid escape: $1\n";
- }
- else
- {
- s/^([^\$]+)//;
- $res .= $1;
- }
- }
-
- $_ = $underscore;
- return '[[' . $res . ']]';
-}
-
-
-# handle_traces($REQ, $OUTPUT, %TRACE)
-# ------------------------------------
-# We use M4 itself to process the traces. But to avoid name clashes when
-# processing the traces, the builtins are disabled, and moved into `at_'.
-# Actually, all the low level processing macros are in `at_' (and `_at_').
-# To avoid clashes between user macros and `at_' macros, the macros which
-# implement tracing are in `AT_'.
-#
-# Having $REQ is needed to neutralize the macros which have been traced,
-# but are not wanted now.
-sub handle_traces ($$%)
-{
- my ($req, $output, %trace) = @_;
-
- # GNU M4 1.4's tracing of builtins is buggy. When run on this input:
- #
- # | divert(-1)
- # | changequote([, ])
- # | define([m4_eval], defn([eval]))
- # | eval(1)
- # | m4_eval(2)
- # | undefine([eval])
- # | m4_eval(3)
- #
- # it behaves this way:
- #
- # | % m4 input.m4 -da -t eval
- # | m4trace: -1- eval(1)
- # | m4trace: -1- m4_eval(2)
- # | m4trace: -1- m4_eval(3)
- # | %
- #
- # Conversely:
- #
- # | % m4 input.m4 -da -t m4_eval
- # | %
- #
- # So we will merge them, i.e. tracing `BUILTIN' or tracing
- # `m4_BUILTIN' will be the same: tracing both, but honoring the
- # *last* trace specification.
- # FIXME: This is not enough: in the output `$0' will be `BUILTIN'
- # sometimes and `m4_BUILTIN' at others. We should return a unique name,
- # the one specified by the user.
- foreach my $macro (keys %trace)
- {
- my $format = $trace{$macro};
- $macro =~ s/^m4_//;
- if (grep /^$macro$/, @m4_builtins)
- {
- $trace{$macro} = $format;
- $trace{"m4_$macro"} = $format;
- }
- }
-
- verbose "formatting traces for `$output': ", join (', ', sort keys %trace);
-
- # Processing the traces.
- my $trace_m4 = new IO::File (">$tmp/traces.m4")
- or die "$me: cannot create $tmp/traces.m4: $!\n";
-
- $_ = <<'EOF';
- divert(-1)
- changequote([, ])
- # _at_MODE(SEPARATOR, ELT1, ELT2...)
- # ----------------------------------
- # List the elements, separating then with SEPARATOR.
- # MODE can be:
- # `at' -- the elements are enclosed in brackets.
- # `star' -- the elements are listed as are.
- # `percent' -- the elements are `flattened': spaces are singled out,
- # and no new line remains.
- define([_at_at],
- [at_ifelse([$#], [1], [],
- [$#], [2], [[[$2]]],
- [[[$2]][$1]$0([$1], at_shift(at_shift($@)))])])
-
- define([_at_percent],
- [at_ifelse([$#], [1], [],
- [$#], [2], [at_flatten([$2])],
- [at_flatten([$2])[$1]$0([$1], at_shift(at_shift($@)))])])
-
- define([_at_star],
- [at_ifelse([$#], [1], [],
- [$#], [2], [[$2]],
- [[$2][$1]$0([$1], at_shift(at_shift($@)))])])
-
- # FLATTEN quotes its result.
- # Note that the second pattern is `newline, tab or space'. Don't lose
- # the tab!
- define([at_flatten],
- [at_patsubst(at_patsubst(at_patsubst([[[$1]]], [\\\n]),
- [[\n\t ]+], [ ]),
- [^ *\(.*\) *$], [[\1]])])
-
- define([at_args], [at_shift(at_shift(at_shift(at_shift(at_shift($@)))))])
- define([at_at], [_$0([$1], at_args($@))])
- define([at_percent], [_$0([$1], at_args($@))])
- define([at_star], [_$0([$1], at_args($@))])
-
-EOF
- s/^ //mg;s/\\t/\t/mg;s/\\n/\n/mg;
- print $trace_m4 $_;
-
- # If you trace `define', then on `define([m4_exit], defn([m4exit])' you
- # will produce
- #
- # AT_define([m4sugar.m4], [115], [1], [define], [m4_exit], <m4exit>)
- #
- # Since `<m4exit>' is not quoted, the outer m4, when processing
- # `trace.m4' will exit prematurely. Hence, move all the builtins to
- # the `at_' name space.
-
- print $trace_m4 "# Copy the builtins.\n";
- map { print $trace_m4 "define([at_$_], defn([$_]))\n" } @m4_builtins;
- print $trace_m4 "\n";
-
- print $trace_m4 "# Disable them.\n";
- map { print $trace_m4 "at_undefine([$_])\n" } @m4_builtins;
- print $trace_m4 "\n";
-
-
- # Neutralize traces: we don't want traces of cached requests (%REQUEST).
- print $trace_m4
- "## -------------------------------------- ##\n",
- "## By default neutralize all the traces. ##\n",
- "## -------------------------------------- ##\n",
- "\n";
- print $trace_m4 "at_define([AT_$_], [at_dnl])\n"
- foreach (sort keys %{$req->macro});
- print $trace_m4 "\n";
-
- # Implement traces for current requests (%TRACE).
- print $trace_m4
- "## ------------------------- ##\n",
- "## Trace processing macros. ##\n",
- "## ------------------------- ##\n",
- "\n";
- foreach (sort keys %trace)
- {
- # Trace request can be embed \n.
- (my $comment = "Trace $_:$trace{$_}") =~ s/^/\# /;
- print $trace_m4 "$comment\n";
- print $trace_m4 "at_define([AT_$_],\n";
- print $trace_m4 trace_format_to_m4 ($trace{$_}) . ")\n\n";
- }
- print $trace_m4 "\n";
-
- # Reenable output.
- print $trace_m4 "at_divert(0)at_dnl\n";
-
- # Transform the traces from m4 into an m4 input file.
- # Typically, transform:
- #
- # | m4trace:configure.ac:3: -1- AC_SUBST([exec_prefix], [NONE])
- #
- # into
- #
- # | AT_AC_SUBST([configure.ac], [3], [1], [AC_SUBST], [exec_prefix], [NONE])
- #
- # Pay attention that the file name might include colons, if under DOS
- # for instance, so we don't use `[^:]+'.
- my $traces = new IO::File ("$me.cache/" . $req->cache)
- or die "$me: cannot open $me.cache/" . $req->cache . ": $!\n";
- while ($_ = $traces->getline)
- {
- # Multiline traces.
- s{^m4trace:(.+):(\d+): -(\d+)- ([^(]+)\((.*)$}
- {AT_$4([$1], [$2], [$3], [$4], $5};
- # Single line traces, as the example above.
- s{^m4trace:(.+):(\d+): -(\d+)- (.*)$}
- {AT_$4([$1], [$2], [$3], [$4]};
- print $trace_m4 "$_";
- }
- $trace_m4->close;
-
- my $in = new IO::File ("$m4 $tmp/traces.m4 |")
- or die "$me: cannot run $m4: $!\n";
- my $out = new IO::File (">$output")
- or die "$me: cannot run open $output: $!\n";
- while ($_ = $in->getline)
- {
- # It makes no sense to try to transform __oline__.
- s/\@<:\@/[/g;
- s/\@:>\@/]/g;
- s/\@\$\|\@/\$/g;
- s/\@%:\@/#/g;
- print $out $_;
- }
-}
-
-
-# $BOOL
-# up_to_date_p ($REQ, $FILE)
-# --------------------------
-# If $FILE up to date?
-# We need $REQ since we check $FILE against all its dependencies,
-# and we use the traces on `include' to find them.
-sub up_to_date_p ($$)
-{
- my ($req, $file) = @_;
-
- # If STDOUT or doesn't exist, it sure is outdated!
- return 0
- if $file eq '-' || ! -f $file;
-
- # We can't answer properly if the traces are not computed since we
- # need to know what other files were included.
- return 0
- if ! -f "$me.cache/" . $req->cache;
-
- # We depend at least upon the arguments.
- my @dep = @ARGV;
-
- # Files may include others. We can use traces since we just checked
- # if they are available.
- # If $FILE is younger than one of its dependencies, it is outdated.
- handle_traces ($req, "$tmp/dependencies",('include' => '$1'));
- my $mtime = (stat ($file))[9];
- my $deps = new IO::File ("$tmp/dependencies");
- push @dep, map { chomp; find_file ($_) } $deps->getlines;
- foreach (@dep)
- {
- verbose "$file depends on $_";
- if ($mtime < (stat ($_))[9])
- {
- verbose "$file depends on $_ which is more recent";
- return 0;
- }
- }
-
- # Well, really, it's fine!
- return 1;
-}
-
-
-## -------------- ##
-## Main program. ##
-## -------------- ##
-
-mktmpdir ('t4');
-parse_args;
-
-# We need our cache directory.
-if (! -d "$me.cache")
- {
- mkdir "$me.cache", 0755
- or die "$me: cannot create $me.cache: $!\n";
- }
-
-Request->load ("$me.cache/requests")
- if -f "$me.cache/requests";
-
-# Add the new trace requests.
-my $req = Request->request ('source' => \@ARGV,
- 'path' => \@include,
- 'macro' => [keys %trace, @required_trace]);
-
-if ($verbose)
- {
- print STDERR "$me: the trace request object is:\n";
- print STDERR $req->marshall;
- }
-
-# We need to run M4 if
-# - for traces
-# + there is no cache, or
-# + it does not include the traces we need, or
-# + it exists but is outdated
-# - for output if it is not /dev/null and
-# + it doesn't exist, or
-# + it is outdated
-handle_m4 ($req, keys %{$req->macro})
- if (! $req->valid
- || ! up_to_date_p ($req, "$me.cache/" . $req->cache)
- || (! %trace && ! up_to_date_p ($req, "$output")));
-
-if (%trace)
- {
- # Producing traces.
- # Trying to produce the output only when needed is very
- # error prone here, as you'd have to check that the trace
- # requests have not changed etc.
- handle_traces ($req, $output, %trace);
- }
-else
- {
- # Actual M4 expansion.
- handle_output ($output)
- if ! up_to_date_p ($req, $output);
- }
-
-# All went fine, the cache is valid.
-$req->valid (1);
-
-Request->save ("$me.cache/requests");
-
-exit $exit_status;
+++ /dev/null
-#! @SHELL@
-# -*- shell-script -*-
-# autoreconf - remake all Autoconf configure scripts in a directory tree
-# Copyright 1994, 1999, 2000 Free Software Foundation, Inc.
-
-# This program 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; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-me=`echo "$0" | sed -e 's,.*[\\/],,'`
-
-usage="\
-Usage: $0 [OPTION] ... [TEMPLATE-FILE]
-
-Run \`autoconf' (and \`autoheader', \`aclocal' and \`automake', where
-appropriate) repeatedly to remake the Autoconf \`configure' scripts
-and configuration header templates in the directory tree rooted at the
-current directory. By default, it only remakes those files that are
-older than their predecessors. If you install a new version of
-Autoconf, running \`autoreconf' remakes all of the files by giving it
-the \`--force' option.
-
-Operation modes:
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
- -d, --debug don't remove temporary files
- -f, --force consider every files are obsolete
- -i, --install copy missing auxiliary files
- -s, --symlink instead of copying, install symbolic links
-
-The option \`--install' is similar to the option \`--add-missing' in
-other tools.
-
-Library directories:
- -A, --autoconf-dir=ACDIR Autoconf's macro files location (rarely needed)
- -l, --localdir=DIR location of \`aclocal.m4' and \`acconfig.h'
- -M, --m4dir=M4DIR this package's Autoconf extensions
-
-Unless specified, heuristics try to compute \`M4DIR' from the \`Makefile.am',
-or defaults to \`m4' if it exists.
-
-The following options are passed to \`automake':
- --cygnus assume program is part of Cygnus-style tree
- --foreign set strictness to foreign
- --gnits set strictness to gnits
- --gnu set strictness to gnu
- --include-deps include generated dependencies in Makefile.in
-
-The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, and ACLOCAL
-are honored.
-
-Report bugs to <bug-autoconf@gnu.org>."
-
-version="\
-autoreconf (@PACKAGE_NAME@) @VERSION@
-Written by David J. MacKenzie.
-
-Copyright 1994, 1999, 2000 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="\
-Try \`$me --help' for more information."
-
-exit_missing_arg="\
-echo \"$me: option \\\`\$1' requires an argument\" >&2
-echo \"\$help\" >&2
-exit 1"
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# Variables.
-: ${autoconf_dir=${AC_MACRODIR=@datadir@}}
-debug=false
-dir=`echo "$0" | sed -e 's,[^\\/]*$,,'`
-force=false
-# --install -- as --add-missing in other tools.
-install=false
-localdir=.
-# m4dir -- local Autoconf extensions. Typically `m4'.
-m4dir=
-status=0
-# symlink -- when --install, use symlinks instead.
-symlink=false
-verbose=:
-
-# Looking for autoconf.
-# We test "$dir/autoconf" in case we are in the build tree, in which case
-# the names are not transformed yet.
-for autoconf in "$AUTOCONF" \
- "$dir/@autoconf-name@" \
- "$dir/autoconf" \
- "@bindir@/@autoconf-name@"; do
- test -f "$autoconf" && break
-done
-
-# Looking for autoheader.
-for autoheader in "$AUTOHEADER" \
- "$dir/@autoheader-name@" \
- "$dir/autoheader" \
- "@bindir@/@autoheader-name@"; do
- test -f "$autoheader" && break
-done
-# Looking for automake.
-: ${automake=${AUTOMAKE=automake}}
-# Looking for aclocal.
-: ${aclocal=${ACLOCAL=aclocal}}
-
-# Parse command line.
-while test $# -gt 0; do
- optarg=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
- "x$1" : 'x-.\(.*\)'`
- case "$1" in
- --version | -V )
- echo "$version" ; exit 0 ;;
- --help | -h )
- echo "$usage"; exit 0 ;;
-
- --verbose | -v )
- verbose=echo
- shift;;
- --debug | -d )
- debug=:; shift ;;
-
- --localdir=* | -l?* )
- localdir=$optarg
- shift ;;
- --localdir | -l )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- localdir=$1
- shift ;;
-
- --autoconf-dir=* | -A?* )
- autoconf_dir=$optarg
- shift ;;
- --autoconf-dir | -A )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- autoconf_dir=$1
- shift ;;
- --macrodir=* | -m?* )
- echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
- autoconf_dir=$optarg
- shift ;;
- --macrodir | -m )
- echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
- test $# = 1 && eval "$exit_missing_arg"
- shift
- autoconf_dir=$1
- shift ;;
-
- --m4dir=* | -M?* )
- m4dir=$optarg
- shift ;;
- --m4dir | -M )
- test $# = 1 && eval "$exit_missing_arg"
- shift
- m4dir=$1
- shift ;;
-
- --force | -f )
- force=:; shift ;;
-
- --install | -i )
- install=:; shift ;;
- --symlink | -s )
- symlink=:; shift ;;
-
- # Options of Automake.
- --cygnus | --foreign | --gnits | --gnu | --include-deps | -i )
- automake="$automake $1"; shift ;;
-
- -- ) # Stop option processing.
- shift; break ;;
- -* )
- exec >&2
- echo "$me: invalid option $1"
- echo "$help"
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-# Find the input file.
-if test $# -ne 0; then
- exec >&2
- echo "$me: invalid number of arguments"
- echo "$help"
- exit 1
-fi
-
-# If verbose, say what you are going to use.
-if test $verbose = echo; then
- $autoconf --version |
- sed "s,.*)\(.*\)$,$me: using autoconf\1: $autoconf,;1q" >&2
- $autoheader --version |
- sed "s,.*)\(.*\)$,$me: using autoheader\1: $autoheader,;1q" >&2
- $automake --version |
- sed "s,.*)\(.*\)$,$me: using automake\1: $automake,;1q" >&2
- $aclocal --version |
- sed "s,.*)\(.*\)$,$me: using aclocal\1: $aclocal,;1q" >&2
-fi
-
-# Dispatch autoreconf's option to the tools.
-# --localdir
-autoconf="$autoconf -l $localdir"
-autoheader="$autoheader -l $localdir"
-# --force
-$force || automake="$automake --no-force"
-# --verbose
-autoconf="$autoconf `$verbose --verbose`"
-autoheader="$autoheader `$verbose --verbose`"
-automake="$automake `$verbose --verbose`"
-aclocal="$aclocal `$verbose --verbose`"
-# --debug
-$debug &&
-{
- autoconf="$autoconf --debug"
- autoheader="$autoheader --debug"
-}
-# --macrodir
-export autoconf_dir
-# --install and --symlink
-if $install; then
- automake="$automake --add-missing `$symlink || echo --copy`"
-fi
-
-# Trap on 0 to stop playing with `rm'.
-$debug ||
-{
- trap 'status=$?; rm -rf $tmp && exit $status' 0
- trap '(exit 1); exit 1' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-: ${TMPDIR=/tmp}
-{
- tmp=`(umask 077 && mktemp -d -q "$TMPDIR/arXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=$TMPDIR/ar$$
- (umask 077 && mkdir $tmp)
-} ||
-{
- echo "$me: cannot create a temporary directory in $TMPDIR" >&2
- (exit 1); exit 1
-}
-
-# When debugging, it is convenient that all the related temporary
-# files be at the same place.
-TMPDIR=$tmp
-export TMPDIR
-
-# alflags.sed -- Fetch the aclocal flags.
-cat >$tmp/alflags.sed <<EOF
-#n
-/^ACLOCAL_[A-Z_]*FLAGS/{
- s/.*=//
- p
- q
-}
-EOF
-
-# update.sh --
-# Exit 0 if the first argument is not the most recent of all or is missing.
-cat >$tmp/update.sh <<\EOF
-test -f "$1" || { :; exit; }
-test x`ls -1dt "$@" 2>/dev/null | sed 1q` != x"$1"
-EOF
-update="@SHELL@ $tmp/update.sh"
-
-
-# ----------------------- #
-# Real work starts here. #
-# ----------------------- #
-
-# Make a list of directories to process.
-# The xargs grep filters out Cygnus configure.in files.
-find . '(' -name configure.ac -o -name configure.in ')' -print |
-xargs grep -l AC_INIT |
-sed 's,/configure\.ac$,,;s,/configure\.in$,,;s,^./,,' |
-while read dir; do
- (
- cd $dir || continue
-
-
- # ----------------- #
- # Running aclocal. #
- # ----------------- #
-
- # uses_aclocal -- is this package using aclocal?
- uses_aclocal=false
- grep 'generated .* by aclocal' $localdir/aclocal.m4 >/dev/null 2>&1 &&
- uses_aclocal=:
- test -f "$localdir/aclocal.m4" ||
- uses_aclocal=:
- if $uses_aclocal &&
- { $force ||
- $update $localdir/aclocal.m4 $localdir/acinclude.m4; } then
- # If there are flags for aclocal in Makefile.am, use them.
- aclocal_flags=`sed -f $tmp/alflags.sed Makefile.am 2>/dev/null`
-
- # If m4dir no specified and these flags do not specify the
- # location of the local Autoconf extensions, default to `m4'.
- case $m4dir,$aclocal_flags in
- ,*"-I "* ) ;; # Not overriden and specified.
- ,*) # Not specified at all.
- test -d "m4" && aclocal_flags="$aclocal_flags -I m4";;
- * ) # Specified by the user.
- aclocal_flags="$aclocal_flags -I $m4dir";;
- esac
-
- $verbose $me: running $aclocal $aclocal_flags --output=$localdir/aclocal.m4 in $dir >&2
- $aclocal $aclocal_flags --output=$localdir/aclocal.m4
- fi
-
-
- # ------------------ #
- # Running automake. #
- # ------------------ #
-
- # Assumes that there is a Makefile.am in the topmost directory.
- uses_automake=false
- test -f "Makefile.am" &&
- uses_automake=:
- # We should always run automake, and let it decide whether it shall
- # update the file or not. In fact, the effect of `$force' is already
- # included in `$automake' via `--no-force'.
- if $uses_automake; then
- $verbose $me: running $automake in $dir >&2
- $automake
- fi
-
-
- # ------------------ #
- # Running autoconf. #
- # ------------------ #
-
- if $force ||
- $update configure configure.ac $localdir/aclocal.m4 ||
- $update configure configure.in $localdir/aclocal.m4; then
- $verbose $me: running $autoconf in $dir >&2
- $autoconf
- fi
-
-
- # -------------------- #
- # Running autoheader. #
- # -------------------- #
-
- # templates -- arguments of AC_CONFIG_HEADERS.
- $verbose $me: running $autoconf -t 'AC_CONFIG_HEADERS:$1' >&2
- templates=`$autoconf -t 'AC_CONFIG_HEADERS:$1'`
- if test -n "$templates"; then
- tcount=`set -- $templates; echo $#`
- template=`set -- $templates; echo $1 | sed '
- s/.*://
- t colon
- s/$/.in/
- : colon
- s/:.*//
- '`
- template_dir=`echo $template | sed -e 's,[\\/]*[^\\/]*$,,;s,^$,.,'`
- stamp_num=`test "$tcount" -gt 1 && echo "$tcount"`
- stamp=$template_dir/stamp-h$stamp_num.in
- # If config.hin exists, don't override it unless it was really
- # created by autoheader (users are allowed to write them by hand!).
- uses_autoheader=false
- grep autoheader "$template" >/dev/null 2>&1 &&
- uses_autoheader=:
- test -f "$template" ||
- uses_autoheader=:
- if $uses_autoheader &&
- { $force ||
- $update $template \
- configure.ac $localdir/aclocal.m4 $localdir/acconfig.h ||
- $update $template \
- configure.in $localdir/aclocal.m4 $localdir/acconfig.h ||
- $update $stamp \
- configure.ac $localdir/aclocal.m4 $localdir/acconfig.h ||
- $update $stamp \
- configure.in $localdir/aclocal.m4 $localdir/acconfig.h; } then
- $verbose $me: running $autoheader in $dir >&2
- $autoheader &&
- $verbose "touching $stamp" >&2 &&
- touch $stamp
- fi
- fi
- )
-done
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# End:
+++ /dev/null
-#! @PERL@ -w
-# -*- perl -*-
-# autoscan - Create configure.scan (a preliminary configure.ac) for a package.
-# Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
-
-# This program 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; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# Written by David MacKenzie <djm@gnu.ai.mit.edu>.
-
-use 5.005;
-use File::Basename;
-use File::Find;
-use Getopt::Long;
-use IO::File;
-use strict;
-
-use vars qw(@cfiles @makefiles @shfiles %c_keywords %printed);
-
-my $me = basename ($0);
-my $verbose = 0;
-
-# $USED{KIND}{ITEM} is set if ITEM is used in the program.
-# It is set to its list of locations.
-my %used = ();
-
-# $MACRO{KIND}{ITEM} is the list of macros to use to test ITEM.
-my %macro = ();
-
-# $NEEDED_MACROS{MACRO} is an array of locations requiring MACRO.
-my %needed_macros = ();
-
-my @kinds = qw (functions headers identifiers programs makevars libraries);
-
-# For each kind, the default macro.
-my %generic_macro =
- (
- 'functions' => 'AC_CHECK_FUNCS',
- 'headers' => 'AC_CHECK_HEADERS',
- 'identifiers' => 'AC_CHECK_TYPES',
- 'programs' => 'AC_CHECK_PROGS',
- 'libraries' => 'AC_CHECK_LIB'
- );
-
-my %kind_comment =
- (
- 'functions' => 'Checks for library functions.',
- 'headers' => 'Checks for header files.',
- 'identifiers' => 'Checks for typedefs, structures, and compiler characteristics.',
- 'programs' => 'Checks for programs.',
- );
-
-my $configure_scan = 'configure.scan';
-my $log = new IO::File ">$me.log"
- or die "$me: cannot open $me.log: $!\n";
-
-# Autoconf and lib files.
-my $autoconf;
-my $datadir = $ENV{"AC_MACRODIR"} || "@datadir@";
-
-# Exit nonzero whenever closing STDOUT fails.
-sub END
-{
- use POSIX qw (_exit);
- # This is required if the code might send any output to stdout
- # E.g., even --version or --help. So it's best to do it unconditionally.
- close STDOUT
- or (warn "$me: closing standard output: $!\n"), _exit (1);
-}
-
-
-## ------------------------ ##
-## Command line interface. ##
-## ------------------------ ##
-
-
-# print_usage ()
-# --------------
-# Display usage (--help).
-sub print_usage ()
-{
- print "Usage: $0 [OPTION] ... [SRCDIR]
-
-Examine source files in the directory tree rooted at SRCDIR, or the
-current directory if none is given. Search the source files for
-common portability problems, check for incompleteness of
-`configure.ac', and create a file `$configure_scan' which is a
-preliminary `configure.ac' for that package.
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
-
-Library directories:
- -A, --autoconf-dir=ACDIR Autoconf's files location (rarely needed)
- -l, --localdir=DIR location of `aclocal.m4' and `acconfig.h'
-
-Report bugs to <bug-autoconf\@gnu.org>.\n";
- exit 0;
-}
-
-
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print "autoscan (@PACKAGE_NAME@) @VERSION@
-Written by David J. MacKenzie.
-
-Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
- exit 0;
-}
-
-
-# parse_args ()
-# -------------
-# Process any command line arguments.
-sub parse_args ()
-{
- my $srcdir;
- Getopt::Long::config ("bundling");
- Getopt::Long::GetOptions ("A|autoconf-dir|m|macrodir=s" => \$datadir,
- "h|help" => \&print_usage,
- "V|version" => \&print_version,
- "v|verbose" => \$verbose)
- or exit 1;
-
- die "$me: too many arguments
-Try `$me --help' for more information.\n"
- if (@ARGV > 1);
- ($srcdir) = @ARGV;
- $srcdir = "."
- if !defined $srcdir;
-
- print "srcdir=$srcdir\n" if $verbose;
- chdir $srcdir || die "$me: cannot cd to $srcdir: $!\n";
-}
-
-
-# find_autoconf
-# -------------
-# Find the lib files and autoconf.
-sub find_autoconf
-{
- my $dir = dirname ($0);
- # We test "$dir/autoconf" in case we are in the build tree, in which case
- # the names are not transformed yet.
- foreach my $file ($ENV{"AUTOCONF"} || '',
- "$dir/@autoconf-name@",
- "$dir/autoconf",
- "@bindir@/@autoconf-name@")
- {
- if (-x $file)
- {
- $autoconf = $file;
- last;
- }
- }
-}
-
-
-# $CONFIGURE_AC
-# &find_configure_ac ()
-# ---------------------
-sub find_configure_ac ()
-{
- if (-f 'configure.ac')
- {
- if (-f 'configure.in')
- {
- warn "warning: `configure.ac' and `configure.in' both present.\n";
- warn "warning: proceeding with `configure.ac'.\n";
- }
- return 'configure.ac';
- }
- elsif (-f 'configure.in')
- {
- return 'configure.in';
- }
- return;
-}
-
-
-# init_tables ()
-# --------------
-# Put values in the tables of what to do with each token.
-sub init_tables ()
-{
- # Initialize a table of C keywords (to ignore).
- # Taken from K&R 1st edition p. 180.
- # ANSI C, GNU C, and C++ keywords can introduce portability problems,
- # so don't ignore them.
-
- foreach (qw (int char float double struct union long short unsigned
- auto extern register typedef static goto return sizeof break
- continue if else for do while switch case default))
- {
- $c_keywords{$_} = 0;
- }
-
- # The data file format supports only one line of macros per function.
- # If more than that is required for a common portability problem,
- # a new Autoconf macro should probably be written for that case,
- # instead of duplicating the code in lots of configure.ac files.
- my $tables_are_consistent = 1;
- foreach my $kind (@kinds)
- {
- my $file = "$datadir/autoscan/$kind";
- my $table = new IO::File $file
- or die "$me: cannot open $file: $!\n";
- while ($_ = $table->getline)
- {
- # Ignore blank lines and comments.
- next
- if /^\s*$/ || /^\s*\#/;
- unless (/^(\S+)\s+(\S.*)$/ || /^(\S+)\s*$/)
- {
- die "$me: cannot parse definition in $file:\n$_\n";
- }
- my $word = $1;
- my $macro = $2 || $generic_macro{$kind};
- # The default macro must be explicitly listed for words
- # which have a specific macros. This allows to enforce
- # consistency checks.
- if (!defined $2 && exists $macro{$kind}{$word})
- {
- warn ("$datadir/autoscan/$kind:$.: "
- . "ignoring implicit call to the generic macro for $word\n");
- $tables_are_consistent = 0;
- }
- else
- {
- push @{$macro{$kind}{$word}}, $macro;
- }
- }
- $table->close
- or die "$me: cannot close $file: $!\n";
- }
-
- die "$me: some tables are inconsistent\n"
- if !$tables_are_consistent;
-}
-
-
-
-## ----------------------- ##
-## Scanning source files. ##
-## ----------------------- ##
-
-
-# scan_c_file(FILENAME)
-# ---------------------
-sub scan_c_file ($)
-{
- my ($filename) = @_;
-
- push (@cfiles, $File::Find::name);
-
- # Nonzero if in a multiline comment.
- my $in_comment = 0;
-
- my $file = new IO::File "<$filename"
- or die "$me: cannot open $filename: $!\n";
-
- while ($_ = $file->getline)
- {
- # Strip out comments, approximately.
- # Ending on this line.
- if ($in_comment && m,\*/,)
- {
- s,.*\*/,,;
- $in_comment = 0;
- }
- # All on one line.
- s,/\*.*\*/,,g;
- # Starting on this line.
- if (m,/\*,)
- {
- $in_comment = 1;
- }
- # Continuing on this line.
- next if $in_comment;
-
- # Preprocessor directives.
- if (/^\s*\#\s*include\s*<([^>]*)>/)
- {
- push (@{$used{'headers'}{$1}}, "$File::Find::name:$.");
- }
- # Ignore other preprocessor directives.
- next if /^\s*\#/;
-
- # Remove string and character constants.
- s,\"[^\"]*\",,g;
- s,\'[^\']*\',,g;
-
- # Tokens in the code.
- # Maybe we should ignore function definitions (in column 0)?
- while (s/\b([a-zA-Z_]\w*)\s*\(/ /)
- {
- push (@{$used{'functions'}{$1}}, "$File::Find::name:$.")
- if !defined $c_keywords{$1};
- }
- while (s/\b([a-zA-Z_]\w*)\b/ /)
- {
- push (@{$used{'identifiers'}{$1}}, "$File::Find::name:$.")
- if !defined $c_keywords{$1};
- }
- }
-
- $file->close
- or die "$me: cannot close $filename: $!\n";
-}
-
-
-# scan_makefile(MAKEFILE-NAME)
-# ----------------------------
-sub scan_makefile ($)
-{
- my ($filename) = @_;
- push (@makefiles, $File::Find::name);
-
- my $file = new IO::File "<$filename"
- or die "$me: cannot open $filename: $!\n";
-
- while ($_ = $file->getline)
- {
- # Strip out comments and variable references.
- s/#.*//;
- s/\$\([^\)]*\)//g;
- s/\${[^\}]*}//g;
- s/@[^@]*@//g;
-
- # Variable assignments.
- while (s/\b([a-zA-Z_]\w*)\s*=/ /)
- {
- push (@{$used{'makevars'}{$1}}, "$File::Find::name:$.");
- }
- # Libraries.
- while (s/\B-l([a-zA-Z_]\w*)\b/ /)
- {
- push (@{$used{'libraries'}{$1}}, "$File::Find::name:$.");
- }
- # Tokens in the code.
- while (s/(?<![-\w.])([a-zA-Z_][\w+.-]+)/ /)
- {
- push (@{$used{'programs'}{$1}}, "$File::Find::name:$.");
- }
- }
-
- $file->close
- or die "$me: cannot close $filename: $!\n";
-}
-
-
-# scan_sh_file(SHELL-SCRIPT-NAME)
-# -------------------------------
-sub scan_sh_file ($)
-{
- my ($filename) = @_;
- push (@shfiles, $File::Find::name);
-
- my $file = new IO::File "<$filename"
- or die "$me: cannot open $filename: $!\n";
-
- while ($_ = $file->getline)
- {
- # Strip out comments and variable references.
- s/#.*//;
- s/#.*//;
- s/\${[^\}]*}//g;
- s/@[^@]*@//g;
-
- # Tokens in the code.
- while (s/\b([a-zA-Z_]\w*)\b/ /)
- {
- push (@{$used{'programs'}{$1}}, "$File::Find::name:$.");
- }
- }
-
- $file->close
- or die "$me: cannot close $filename: $!\n";
-}
-
-
-# scan_file ()
-# ------------
-# Called by &find on each file. $_ contains the current filename with
-# the current directory of the walk through.
-sub scan_file ()
-{
- # Wanted only if there is no corresponding FILE.in.
- return
- if -f "$_.in";
-
- # Save $_ as Find::File requires it to be preserved.
- my $underscore = $_;
-
- # Strip a useless leading `./'.
- $File::Find::name =~ s,^\./,,;
-
- if (/\.[chlym](\.in)?$/)
- {
- push (@{$used{'programs'}{"cc"}}, $File::Find::name);
- scan_c_file ($_);
- }
- elsif (/\.(cc|cpp|cxx|CC|C|hh|hpp|hxx|HH|H|yy|ypp|ll|lpp)(\.in)?$/)
- {
- push (@{$used{'programs'}{"c++"}}, $File::Find::name);
- scan_c_file ($_);
- }
- elsif (/^[Mm]akefile(\.in)?$/ || /^GNUmakefile(\.in)?$/)
- {
- scan_makefile ($_);
- }
- elsif (/\.sh(\.in)?$/)
- {
- scan_sh_file ($_);
- }
-
- $_ = $underscore;
-}
-
-
-# scan_files ()
-# -------------
-# Read through the files and collect lists of tokens in them
-# that might create nonportabilities.
-sub scan_files ()
-{
- find (\&scan_file, '.');
-
- if ($verbose)
- {
- print "cfiles:", join(" ", @cfiles), "\n";
- print "makefiles:", join(" ", @makefiles), "\n";
- print "shfiles:", join(" ", @shfiles), "\n";
-
- foreach my $kind (@kinds)
- {
- print "\n$kind:\n";
- foreach my $word (sort keys %{$used{$kind}})
- {
- print "$word: @{$used{$kind}{$word}}\n";
- }
- }
- }
-}
-
-
-## ----------------------- ##
-## Output configure.scan. ##
-## ----------------------- ##
-
-
-# output_kind ($FILE, $KIND)
-# --------------------------
-sub output_kind ($$)
-{
- my ($file, $kind) = @_;
- # Lists of words to be checked with the generic macro.
- my @have;
-
- print $file "\n# $kind_comment{$kind}\n"
- if exists $kind_comment{$kind};
- foreach my $word (sort keys %{$used{$kind}})
- {
- # Words that were caught, but not to be checked according to
- # the autoscan library files.
- next
- if ! exists $macro{$kind}{$word};
-
- # Output the needed macro invocations in $configure_scan if not
- # already printed, and remember these macros are needed.
- foreach my $macro (@{$macro{$kind}{$word}})
- {
- if (exists $generic_macro{$kind}
- && $macro eq $generic_macro{$kind})
- {
- push (@have, $word);
- push (@{$needed_macros{"$generic_macro{$kind}([$word])"}},
- @{$used{$kind}{$word}});
- }
- else
- {
- if (! $printed{$macro})
- {
- print $file "$macro\n";
- $printed{$macro} = 1;
- }
- push (@{$needed_macros{$macro}},
- @{$used{$kind}{$word}});
- }
- }
- }
- print $file "$generic_macro{$kind}([" . join(' ', sort(@have)) . "])\n"
- if @have;
-}
-
-
-# output_libraries ($FILE)
-# ------------------------
-sub output_libraries ($)
-{
- my ($file) = @_;
-
- print $file "\n# Checks for libraries.\n";
- foreach my $word (sort keys %{$used{'libraries'}})
- {
- print $file "# FIXME: Replace `main' with a function in `-l$word':\n";
- print $file "AC_CHECK_LIB([$word], [main])\n";
- }
-}
-
-
-# output (CONFIGURE_SCAN)
-# -----------------------
-# Print a proto configure.ac.
-sub output ($)
-{
- my $configure_scan = shift;
- my %unique_makefiles;
-
- my $file = new IO::File ">$configure_scan"
- or die "$me: cannot create $configure_scan: $!\n";
-
- print $file "# Process this file with autoconf to produce a configure script.\n";
- print $file "AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)\n";
- if (defined $cfiles[0])
- {
- print $file "AC_CONFIG_SRCDIR([$cfiles[0]])\n";
- print $file "AC_CONFIG_HEADER([config.h])\n";
- }
-
- output_kind ($file, 'programs');
- output_kind ($file, 'makevars');
- output_libraries ($file);
- output_kind ($file, 'headers');
- output_kind ($file, 'identifiers');
- output_kind ($file, 'functions');
-
- # Change DIR/Makefile.in to DIR/Makefile.
- foreach my $m (@makefiles)
- {
- $m =~ s/\.in$//;
- $unique_makefiles{$m}++;
- }
- print $file "\nAC_CONFIG_FILES([",
- join ("\n ", sort keys %unique_makefiles), "])\n";
- print $file "AC_OUTPUT\n";
-
- $file->close
- or die "$me: cannot close $configure_scan: $!\n";
-}
-
-
-
-## --------------------------------------- ##
-## Checking the accuracy of configure.ac. ##
-## --------------------------------------- ##
-
-
-# check_configure_ac (CONFIGURE_AC)
-# ---------------------------------
-# Use autoconf to check if all the suggested macros are included
-# in CONFIGURE_AC.
-sub check_configure_ac ($)
-{
- my ($configure_ac) = @_;
- my ($trace_option) = '';
-
- # Find what needed macros are invoked in CONFIGURE_AC.
- foreach my $macro (sort keys %needed_macros)
- {
- $macro =~ s/\(.*//;
- $trace_option .= " -t $macro";
- }
-
- my $traces =
- new IO::File "$autoconf -A $datadir $trace_option $configure_ac|"
- or die "$me: cannot create read traces: $!\n";
-
- while ($_ = $traces->getline)
- {
- chomp;
- my ($file, $line, $macro, @args) = split (/:/, $_);
- if ($macro =~ /^AC_CHECK_(HEADER|FUNC|TYPE|MEMBER)S$/)
- {
- # To be rigorous, we should distinguish between space and comma
- # separated macros. But there is no point.
- foreach my $word (split (/\s|,/, $args[0]))
- {
- # AC_CHECK_MEMBERS wants `struct' or `union'.
- if ($macro eq "AC_CHECK_MEMBERS"
- && $word =~ /^stat.st_/)
- {
- $word = "struct " . $word;
- }
- delete ($needed_macros{"$macro([$word])"});
- }
- }
- else
- {
- delete ($needed_macros{$macro});
- }
- }
-
- $traces->close
- or die "$me: cannot close: $!\n";
-
- # Report the missing macros.
- foreach my $macro (sort keys %needed_macros)
- {
- warn ("$configure_ac: warning: missing $macro wanted by: "
- . (${$needed_macros{$macro}}[0])
- . "\n");
- print $log "$me: warning: missing $macro wanted by: \n";
- foreach my $need (@{$needed_macros{$macro}})
- {
- print $log "\t$need\n";
- }
- }
-}
-
-
-## -------------- ##
-## Main program. ##
-## -------------- ##
-
-parse_args;
-# Find the lib files and autoconf.
-find_autoconf;
-my $configure_ac = find_configure_ac;
-init_tables;
-scan_files;
-output ('configure.scan');
-if ($configure_ac)
- {
- check_configure_ac ($configure_ac);
- }
-
-$log->close
- or die "$me: cannot close $me.log: $!\n";
-
-exit 0;
+++ /dev/null
-#! @PERL@ -w
-# -*- perl -*-
-# autoupdate - modernize an Autoconf file.
-# Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
-
-# This program 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; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# Originally written by David MacKenzie <djm@gnu.ai.mit.edu>.
-# Rewritten by Akim Demaille <akim@freefriends.org>.
-
-use 5.005;
-use Getopt::Long;
-use File::Basename;
-use strict;
-
-(my $me = $0) =~ s,.*[\\/],,;
-
-# Lib files.
-my $autoconf_dir = $ENV{"AC_MACRODIR"} || "@datadir@";
-my $autoconf = '';
-my $debug = 0;
-my $localdir = '.';
-# m4.
-my $m4 = $ENV{"M4"} || "@M4@";
-my $verbose = 0;
-my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
-my $tmp = '';
-
-
-## ---------- ##
-## Routines. ##
-## ---------- ##
-
-
-# &mktmpdir ()
-# ------------
-sub mktmpdir ()
-{
- my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
-
- # If mktemp supports dirs, use it to please Marc E.
- $tmp = `(umask 077 && mktemp -d -q "$TMPDIR/auXXXXXX") 2>/dev/null`;
- chomp $tmp;
-
- if (!$tmp || !-d $tmp)
- {
- $tmp = "$TMPDIR/au" . int (rand 10000) . ".$$";
- mkdir $tmp, 0700
- or die "$me: cannot create $tmp: $!\n";
- }
-
- print STDERR "$me:$$: working in $tmp\n"
- if $debug;
-}
-
-
-# verbose
-# -------
-sub verbose (@)
-{
- print STDERR "$me: ", @_, "\n"
- if $verbose;
-}
-
-
-# END
-# ---
-# Exit nonzero whenever closing STDOUT fails.
-sub END
-{
- use POSIX qw (_exit);
-
- my ($q) = ($?);
-
- # FIXME: Heelp! Can't find a means to properly catch system's
- # exit status (without hair I mean).
- # my $status = $? >> 8;
-
- if (!$debug && -d $tmp)
- {
- unlink <$tmp/*>
- or warn ("$me: cannot empty $tmp: $!\n"), _exit (1);
- rmdir $tmp
- or warn ("$me: cannot remove $tmp: $!\n"), _exit (1);
- }
-
- # This is required if the code might send any output to stdout
- # E.g., even --version or --help. So it's best to do it unconditionally.
- close STDOUT
- or (warn "$me: closing standard output: $!\n"), _exit (1);
-
- ($!, $?) = (0, $q);
-}
-
-
-# xsystem ($COMMAND)
-# ------------------
-sub xsystem ($)
-{
- my ($command) = @_;
-
- verbose "running: $command";
-
- (system $command) == 0
- or die ("$me: "
- . (split (' ', $command))[0]
- . " failed with exit status: "
- . ($? >> 8)
- . "\n");
-}
-
-
-# print_usage ()
-# --------------
-# Display usage (--help).
-sub print_usage ()
-{
- print <<"END";
-Usage: $0 [OPTION] ... [TEMPLATE-FILE...]
-
-Update the TEMPLATE-FILE... if given, or \`configure.ac\' if present,
-or else \`configure.in\', to the syntax of the current version of
-Autoconf. The original files are backed up.
-
-Operation modes:
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
- -d, --debug don\'t remove temporary files
-
-Library directories:
- -A, --autoconf-dir=ACDIR Autoconf\'s macro files location (rarely needed)
- -l, --localdir=DIR location of \`aclocal.m4\'
-
-Environment variables:
- M4 GNU M4 1.4 or above
- AUTOCONF autoconf @VERSION@
-
-Report bugs to <bug-autoconf\@gnu.org>.
-END
- exit 0;
-}
-
-
-# print_version ()
-# ----------------
-# Display version (--version).
-sub print_version
-{
- print <<END;
-autoupdate (@PACKAGE_NAME@) @VERSION@
-Written by David J. MacKenzie and Akim Demaille.
-
-Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-END
- exit 0;
-}
-
-
-# $CONFIGURE_AC
-# &find_configure_ac ()
-# ---------------------
-sub find_configure_ac ()
-{
- if (-f 'configure.ac')
- {
- if (-f 'configure.in')
- {
- warn "warning: `configure.ac' and `configure.in' both present.\n";
- warn "warning: proceeding with `configure.ac'.\n";
- }
- return 'configure.ac';
- }
- elsif (-f 'configure.in')
- {
- return 'configure.in';
- }
- return;
-}
-
-
-# parse_args ()
-# -------------
-# Process any command line arguments.
-sub parse_args ()
-{
- my $srcdir;
- # F*k. Getopt seems bogus and dies when given `-' with `bundling'.
- # If fixed some day, use this: '' => sub { push @ARGV, "-" }
- my $update_stdin = grep /^-$/, @ARGV;
- @ARGV = grep !/^-$/, @ARGV;
- Getopt::Long::config ("bundling");
- Getopt::Long::GetOptions ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
- 'l|localdir=s' => \$localdir,
- 'd|debug' => \$debug,
- 'h|help' => \&print_usage,
- 'V|version' => \&print_version,
- 'v|verbose' => \$verbose)
- or exit 1;
-
- push @ARGV, '-'
- if $update_stdin;
-
- if (! @ARGV)
- {
- my $configure_ac = find_configure_ac;
- die 'no input file'
- unless $configure_ac;
- push @ARGV, $configure_ac;
- }
-}
-
-
-# find_slaves
-# -----------
-# Find the lib files and autoconf.
-sub find_slaves ()
-{
- # Some non-GNU m4's don't reject the --help option, so give them /dev/null.
- die "Autoconf requires GNU m4 1.4 or later\n"
- if system "$m4 --help </dev/null 2>&1 | fgrep reload-state >/dev/null";
-
- # autoconf.
- (my $dir = $0) =~ s,[^\\/]*$,,;
-
- # We test "$dir/autoconf" in case we are in the build tree, in which case
- # the names are not transformed yet.
- foreach my $file ($ENV{"AUTOCONF"} || '',
- "$dir/@autoconf-name@",
- "$dir/autoconf",
- "@bindir@/@autoconf-name@")
- {
- if (-x $file)
- {
- $autoconf = $file;
- last;
- }
- }
-
- # This is needed because perl's '-x' isn't a smart as bash's; that
- # is, it won't find autoconf.sh.
- $autoconf = 'autoconf'
- if !$autoconf;
-}
-
-
-## -------------- ##
-## Main program. ##
-## -------------- ##
-find_slaves;
-parse_args;
-mktmpdir;
-$autoconf .= " --autoconf-dir $autoconf_dir --localdir $localdir ";
-$autoconf .= "--debug " if $debug;
-$autoconf .= "--verbose " if $verbose;
-
-# @M4_BUILTINS -- M4 builtins and a useful comment.
-my @m4_builtins = `echo dumpdef | $m4 2>&1 >/dev/null`;
-map { s/:.*//;s/\W// } @m4_builtins;
-
-
-# m4.m4 -- enable the m4 builtins.
-# unm4.m4 -- disable the m4 builtins.
-# savem4.m4 -- save the m4 builtins.
-open M4_M4, ">$tmp/m4.m4"
- or die "$me: cannot open: $!\n";
-open UNM4_M4, ">$tmp/unm4.m4"
- or die "$me: cannot open: $!\n";
-open M4SAVE_M4, ">$tmp/m4save.m4"
- or die "$me: cannot open: $!\n";
-foreach (@m4_builtins)
- {
- print M4_M4 "_au_define([$_], _au_defn([_au_$_]))\n";
- print UNM4_M4 "_au_undefine([$_])\n";
- print M4SAVE_M4 "define([_au_$_], defn([$_]))\n";
- }
-close M4SAVE_M4
- or die "$me: cannot close: $!\n";
-close UNM4_M4
- or die "$me: cannot close: $!\n";
-close M4_M4
- or die "$me: cannot close: $!\n";
-
-
-# @AU_MACROS & AC_MACROS -- AU and AC macros and yet another useful comment.
-open MACROS, ("$autoconf "
- . "--trace AU_DEFUN:'AU:\$f:\$1' --trace define:'AC:\$f:\$1' "
- . "-i /dev/null |")
- or die "$me: cannot open: $!\n";
-my (%ac_macros, %au_macros);
-while (<MACROS>)
- {
- chomp;
- /^(AC|AU):(.*):([^:]*)$/ or next;
- my $filename = basename ($2);
- if ($1 eq "AC")
- {
- $ac_macros{$3} = $filename;
- }
- else
- {
- $au_macros{$3} = $filename;
- }
- }
-close MACROS
- or die "$me: cannot close: $!\n";
-# Don't keep AU macros in @AC_MACROS.
-delete $ac_macros{$_}
- foreach (keys %au_macros);
-if ($debug)
- {
- print STDERR "Current Autoconf macros:\n";
- print STDERR join (' ', sort keys %ac_macros) . "\n\n";
- print STDERR "Obsolete Autoconf macros:\n";
- print STDERR join (' ', sort keys %au_macros) . "\n\n";
- }
-
-# $au_changequote -- enable the quote `[', `]' right before any AU macro.
-my $au_changequote =
- 's/\b(' . join ('|', keys %au_macros) . ')\b/_au_changequote([,])$1/g';
-
-# au.m4 -- definitions the AU macros.
-xsystem ("$autoconf --trace AU_DEFUN:'_au_defun(\@<:\@\$1\@:>\@,
-\@<:\@\$2\@:>\@)' -i /dev/null "
- . ">$tmp/au.m4");
-
-# ac.m4 -- autoquoting definitions of the AC macros (M4sugar excluded).
-# disable.m4 -- undefine the macros of AC and m4sugar.
-open AC_M4, ">$tmp/ac.m4"
- or die "$me: cannot open: $!\n";
-open DISABLE_M4, ">$tmp/disable.m4"
- or die "$me: cannot open: $!\n";
-foreach (sort keys %ac_macros)
- {
- print AC_M4 "_au_define([$_], [[\$0(\$\@)]])\n"
- unless $ac_macros{$_} eq "m4sugar.m4";
- print DISABLE_M4 "_au_undefine([$_])\n";
- }
-close DISABLE_M4
- or die "$me: cannot close: $!\n";
-close AC_M4
- or die "$me: cannot close: $!\n";
-
-
-
-## ------------------- ##
-## Process the files. ##
-## ------------------- ##
-
-foreach my $file (@ARGV)
- {
- my $filename = $file;
- # We need an actual file.
- if ($file eq '-')
- {
- $file = "$tmp/stdin";
- system "cat >$file";
- }
- elsif (! -r "$file")
- {
- die "$me: $file: No such file or directory";
- }
-
- # input.m4 -- m4 program to produce the updated file.
- # Load the values, the dispatcher, neutralize m4, and the prepared
- # input file.
- my $input_m4 = <<EOF;
- divert(-1) -*- Autoconf -*-
- changequote([, ])
-
- # Move all the builtins into the \`_au_' pseudo namespace
- include([$tmp/m4save.m4])
-
- # _au_defun(NAME, BODY)
- # ---------------------
- # Define NAME to BODY, plus AU activation/deactivation.
- _au_define([_au_defun],
- [_au_define([\$1],
- [_au_enable()dnl
- \$2[]dnl
- _au_disable()])])
-
- # Import the definition of the obsolete macros.
- _au_include([$tmp/au.m4])
-
-
- ## ------------------------ ##
- ## _au_enable/_au_disable. ##
- ## ------------------------ ##
-
- # They work by pair: each time an AU macro is activated, it runs
- # _au_enable, and at its end its runs _au_disable (see _au_defun
- # above). But since AU macros might use AU macros, which should
- # enable/disable only for the outter AU macros.
- #
- # \`_au_enabled' is used to this end, condionning whether we really
- # enable/disable.
-
-
- # __au_enable
- # -----------
- # Reenable the builtins, and m4sugar.
- _au_define([__au_enable],
- [_au_divert(-1)
- # Enable special characters.
- _au_changecom([#])
-
- # Enable the m4 builtins, m4sugar and the autoquoting AC macros.
- _au_include([$tmp/m4.m4])
- _au_include([$autoconf_dir/m4sugar/m4sugar.m4])
- _au_include([$tmp/ac.m4])
-
- _au_divert(0)])
-
- # _au_enable
- # ----------
- # Called at the beginning of all the obsolete macros. Reenable the
- # builtins, and m4sugar if needed.
- _au_define([_au_enable],
- [_au_ifdef([_au_enabled],
- [],
- [__au_enable()])_au_dnl
- _au_pushdef([_au_enabled])])
-
-
- # __au_disable
- # ------------
- # Disable the builtins, and m4sugar.
- _au_define([__au_disable],
- [_au_divert(-1)
- # Disable m4sugar, the AC autoquoting macros, and m4.
- _au_include([$tmp/disable.m4])
- _au_include([$tmp/unm4.m4])
-
- # Disable special characters.
- _au_changequote()
- _au_changecom()
-
- _au_divert(0)])
-
- # _au_disable
- # -----------
- # Called at the end of all the obsolete macros. Disable the
- # builtins, and m4sugar if needed..
- _au_define([_au_disable],
- [_au_popdef([_au_enabled])_au_dnl
- _au_ifdef([_au_enabled],
- [],
- [__au_disable()])])
-
-
- ## ------------------------------- ##
- ## Disable, and process the file. ##
- ## ------------------------------- ##
- _au_disable()_au_dnl
-EOF
-
- $input_m4 =~ s/^ //mg;
-
- # prepared input -- input, but reenables the quote before each AU macro.
- open INPUT_M4, ">$tmp/input.m4"
- or die "$me: cannot open: $!\n";
- open FILE, "<$file"
- or die "$me: cannot open: $!\n";
- print INPUT_M4 "$input_m4";
- while (<FILE>)
- {
- eval $au_changequote;
- print INPUT_M4;
- }
- close FILE
- or die "$me: cannot close: $!\n";
- close INPUT_M4
- or die "$me: cannot close: $!\n";
-
- # Now ask m4 to perform the update.
- print STDERR "$me: running $m4 $tmp/input.m4\n"
- if $verbose;
- if (system ("$m4 $tmp/input.m4 >$tmp/updated"))
- {
- # Exit status of system() is in the upper byte.
- $! >>= 8;
- die "$me: cannot update \`$filename'\n";
- };
-
- if ("$file" eq "$tmp/stdin")
- {
- system ("cat $tmp/updated");
- }
- elsif (! system ("cmp -s $tmp/updated $file"))
- {
- # File didn't change, so don't update its mod time.
- print STDERR "$me: \`$file' is unchanged\n"
- }
- else
- {
- # Back up and install the new one.
- if (system ("mv $file $file${SIMPLE_BACKUP_SUFFIX} && "
- . "mv $tmp/updated $file") == 0)
- {
- print STDERR "$me: \`$file' is updated\n";
- }
- else
- {
- die "$me: cannot update \`$file'\n";
- }
- }
- }
-
-exit 0;
-
-
-# ## ---------------------------- ##
-# ## How `autoupdate' functions. ##
-# ## ---------------------------- ##
-#
-# The task of `autoupdate' is not trivial: the biggest difficulty being
-# that you must limit the changes to the parts that really need to be
-# updated. Finding a satisfying implementation proved to be quite hard,
-# as this is the fourth implementation of `autoupdate'.
-#
-# Below, we will use a simple example of obsolete macro:
-#
-# AU_DEFUN([OLD], [NEW([$1, $2], m4_eval([$1 + $2]))])
-# AC_DEFUN([NEW], [echo "sum($1) = $2"])
-#
-# the input file contains
-#
-# dnl The Unbelievable Truth
-# OLD(1, 2)
-# NEW([0, 0], [0])
-#
-# Of course the expected output is
-#
-# dnl The Unbelievable Truth
-# NEW([1, 2], [3])
-# NEW([0, 0], [0])
-#
-#
-# # First implementation: sed
-# # =========================
-#
-# The first implementation was only able to change the name of obsolete
-# macros.
-#
-# The file `acoldnames.m4' defined the old names based on the new names.
-# It was simple then to produce a sed script such as:
-#
-# s/OLD/NEW/g
-#
-# Updating merely consisted in running this script on the file to
-# update.
-#
-# This scheme suffers an obvious limitation: that `autoupdate' was
-# unable to cope with new macros that just swap some of its arguments
-# compared to the old macro. Fortunately, that was enough to upgrade
-# from Autoconf 1 to Autoconf 2. (But I have no idea whether the
-# changes in Autoconf 2 were precisely limited by this constraint.)
-#
-#
-# # Second implementation: hooks
-# # ============================
-#
-# The version 2.15 of Autoconf brought a vast number of changes compared
-# to 2.13, so a solution was needed. One could think to extend the
-# `sed' scripts with specialized code for complex macros. But this
-# approach is of course full of flaws:
-#
-# a. the Autoconf maintainers have to write these snippets, which we
-# just don't want to,
-#
-# b. I really don't think you'll ever manage to handle the quoting of
-# m4 from sed.
-#
-# To satisfy a., let's remark that the code which implements the old
-# features in term of the new feature is exactly the code which should
-# replace the old code.
-#
-# To answer point b, as usual in the history of Autoconf, the answer, at
-# least on the paper, is simple: m4 is the best tool to parse m4, so
-# let's use m4.
-#
-# Therefore the specification is:
-#
-# I want to be able to tell Autoconf, well, m4, that the macro I
-# am currently defining is an obsolete macro (so that the user is
-# warned), which code is the code to use when running autoconf,
-# but that the very same code has to be used when running
-# autoupdate. To summarize, the interface I want is
-# `AU_DEFUN(OLD-NAME, NEW-CODE)'.
-#
-#
-# Now for the technical details.
-#
-# When running autoconf, except for the warning, AU_DEFUN is basically
-# AC_DEFUN.
-#
-# When running autoupdate, we want *only* OLD-NAMEs to be expanded.
-# This obviously means that acgeneral.m4 and acspecific.m4 must not be
-# loaded. Nonetheless, because we want to use a rich set of m4
-# features, m4sugar.m4 is needed. Please note that the fact that
-# Autoconf's macros are not loaded is positive on two points:
-#
-# - we do get an updated `configure.ac', not a `configure'!
-#
-# - the old macros are replaced by *calls* to the new-macros, not the
-# body of the new macros, since their body is not defined!!!
-# (Whoa, that's really beautiful!).
-#
-# Additionally we need to disable the quotes when reading the input for
-# two reasons: first because otherwise `m4' will swallow the quotes of
-# other macros:
-#
-# NEW([1, 2], 3)
-# => NEW(1, 2, 3)
-#
-# and second, because we want to update the macro calls which are
-# quoted, i.e., we want
-#
-# FOO([OLD(1, 2)])
-# => FOO([NEW([1, 2], [3])])
-#
-# If we don't disable the quotes, only the macros called at the top
-# level would be updated.
-#
-# So, let's disable the quotes.
-#
-# Well, not quite: m4sugar.m4 still needs to use quotes for some macros.
-# Well, in this case, when running in autoupdate code, each macro first
-# reestablishes the quotes, expands itself, and disables the quotes.
-#
-# Thinking a bit more, you realize that in fact, people may use `define'
-# `ifelse' etc. in their files, and you certainly don't want to process
-# them. Another example is `dnl': you don't want to remove the
-# comments. You then realize you don't want exactly to import m4sugar:
-# you want to specify when it is enabled (macros active), and disabled.
-# m4sugar provides m4_disable/m4_enable to this end.
-#
-# You're getting close to it. Now remains one task: how to handle
-# twofold definitions?
-#
-# Remember that the same AU_DEFUN must be understood in two different
-# ways, the AC way, and the AU way.
-#
-# One first solution is to check whether acgeneral.m4 was loaded. But
-# that's definitely not cute. Another is simply to install `hooks',
-# that is to say, to keep in some place m4 knows, late `define' to be
-# triggered *only* in AU mode.
-#
-# You first think to design AU_DEFUN like this:
-#
-# 1. AC_DEFUN(OLD-NAME,
-# [Warn the user OLD-NAME is obsolete.
-# NEW-CODE])
-#
-# 2. Store for late AU binding([define(OLD_NAME,
-# [Reestablish the quotes.
-# NEW-CODE
-# Disable the quotes.])])
-#
-# but this will not work: NEW-CODE has probably $1, $2 etc. and these
-# guys will be replaced with the argument of `Store for late AU binding'
-# when you call it.
-#
-# I don't think there is a means to avoid this using this technology
-# (remember that $1 etc. are *always* expanded in m4). You may also try
-# to replace them with $[1] to preserve them for a later evaluation, but
-# if `Store for late AU binding' is properly written, it will remain
-# quoted till the end...
-#
-# You have to change technology. Since the problem is that `$1'
-# etc. should be `consumed' right away, one solution is to define now a
-# second macro, `AU_OLD-NAME', and to install a hook than binds OLD-NAME
-# to AU_OLD-NAME. Then, autoupdate.m4 just need to run the hooks. By
-# the way, the same method was used in autoheader.
-#
-#
-# # Third implementation: m4 namespaces by m4sugar
-# # ==============================================
-#
-# Actually, this implementation was just a clean up of the previous
-# implementation: instead of defining hooks by hand, m4sugar was equipped
-# with `namespaces'. What are they?
-#
-# Sometimes we want to disable some *set* of macros, and restore them
-# later. We provide support for this via namespaces.
-#
-# There are basically three characters playing this scene: defining a
-# macro in a namespace, disabling a namespace, and restoring a namespace
-# (i.e., all the definitions it holds).
-#
-# Technically, to define a MACRO in NAMESPACE means to define the macro
-# named `NAMESPACE::MACRO' to the VALUE. At the same time, we append
-# `undefine(NAME)' in the macro named `m4_disable(NAMESPACE)', and
-# similarly a binding of NAME to the value of `NAMESPACE::MACRO' in
-# `m4_enable(NAMESPACE)'. These mechanisms allow to bind the macro of
-# NAMESPACE and to unbind them at will.
-#
-# Of course this implementation is really inefficient: m4 has to grow
-# strings which can become quickly huge, which slows it significantly.
-#
-# In particular one should avoid as much as possible to use `define' for
-# temporaries. Now that `define' as quite a complex meaning, it is an
-# expensive operations that should be limited to macros. Use
-# `m4_define' for temporaries.
-#
-# Private copies of the macros we used in entering / exiting the m4sugar
-# namespace. It is much more convenient than fighting with the renamed
-# version of define etc.
-#
-#
-#
-# Those two implementations suffered from serious problems:
-#
-# - namespaces were really expensive, and incurred a major performance
-# loss on `autoconf' itself, not only `autoupdate'. One solution
-# would have been the limit the use of namespaces to `autoupdate', but
-# that's again some complications on m4sugar, which really doesn't need
-# this. So we wanted to get rid of the namespaces.
-#
-# - since the quotes were disabled, autoupdate was sometimes making
-# wrong guesses, for instance on:
-#
-# foo([1, 2])
-#
-# m4 saw 2 arguments: `[1'and `2]'. A simple solution, somewhat
-# fragile, is to reestablish the quotes right before all the obsolete
-# macros, i.e., to use sed so that the previous text becomes
-#
-# changequote([, ])foo([1, 2])
-#
-# To this end, one wants to trace the definition of obsolete macros.
-#
-# It was there that the limitations of the namespace approach became
-# painful: because it was a complex machinery playing a lot with the
-# builtins of m4 (hence, quite fragile), tracing was almost impossible.
-#
-#
-# So this approach was dropped.
-#
-#
-# # The fourth implementation: two steps
-# # ====================================
-#
-# If you drop the uses of namespaces, you no longer can compute the
-# updated value, and replace the old call with it simultaneously.
-#
-# Obviously you will use m4 to compute the updated values, but you may
-# use some other tool to achieve the replacement. Personally, I trust
-# nobody but m4 to parse m4, so below, m4 will perform the two tasks.
-#
-# How can m4 be used to replace *some* macros calls with newer values.
-# Well, that's dead simple: m4 should learn the definitions of obsolete
-# macros, forget its builtins, disable the quotes, and then run on the
-# input file, which amounts to doing this:
-#
-# divert(-1)dnl
-# changequote([, ])
-# define([OLD], [NEW([$1, $2], m4_eval([$1 + $2]))changequote()])
-# undefine([dnl])
-# undefine([m4_eval])
-# # Some more undefines...
-# changequote()
-# divert(0)dnl
-# dnl The Unbelievable Truth
-# changequote([, ])OLD(1, 2)
-# NEW([0, 0],
-# 0)
-#
-# which will result in
-#
-# dnl The Unbelievable Truth
-# NEW(1, 2, m4_eval(1 + 2))
-# NEW([0, 0],
-# 0)
-#
-# Grpmh. Two problems. A minor problem: it would have been much better
-# to have the `m4_eval' computed, and a major problem: you lost the
-# quotation in the result.
-#
-# Let's address the big problem first. One solution is to define any
-# modern macro to rewrite its calls with the proper quotation, thanks to
-# `$@'. Again, tracing the `define's makes it possible to know which
-# are these macros, so you input is:
-#
-# divert(-1)dnl
-# changequote([, ])
-# define([OLD], [NEW([$1, $2], m4_eval([$1 + $2]))changequote()])
-# define([NEW], [[NEW($@)]changequote()])
-# undefine([dnl])
-# undefine([m4_eval])
-# # Some more undefines...
-# changequote()
-# divert(0)dnl
-# dnl The Unbelievable Truth
-# changequote([, ])OLD(1, 2)
-# changequote([, ])NEW([0, 0],
-# 0)
-#
-# which results in
-#
-# dnl The Unbelievable Truth
-# NEW([1, 2],[m4_eval(1 + 2)])
-# NEW([0, 0],[0])
-#
-# Our problem is solved, i.e., the first call to `NEW' is properly
-# quoted, but introduced another problem: we changed the layout of the
-# second calls, which can be a drama in the case of huge macro calls
-# (think of `AC_TRY_RUN' for instance). This example didn't show it,
-# but we also introduced parens to macros which did not have some:
-#
-# AC_INIT
-# => AC_INIT()
-#
-# No big deal for the semantics (unless the macro depends upon $#, which
-# is bad), but the users would not be happy.
-#
-# Additionally, we introduced quotes that we not there before, which is
-# OK in most cases, but could change the semantics of the file.
-#
-# Cruel dilemma: we do want the auto-quoting definition of `NEW' when
-# evaluating `OLD', but we don't when we evaluate the second `NEW'.
-# Back to namespaces?
-#
-# No.
-#
-#
-# # Second step: replacement
-# # ------------------------
-#
-# No, as announced above, we will work in two steps: in a first step we
-# compute the updated values, and in a second step we replace them. Our
-# goal is something like this:
-#
-# divert(-1)dnl
-# changequote([, ])
-# define([OLD], [NEW([1, 2], [3])changequote()])
-# undefine([dnl])
-# undefine([m4_eval])
-# # Some more undefines...
-# changequote()
-# divert(0)dnl
-# dnl The Unbelievable Truth
-# changequote([, ])OLD(1, 2)
-# NEW([0, 0],
-# 0)
-#
-# i.e., the new value of `OLD' is precomputed using the auto-quoting
-# definition of `NEW' and the m4 builtins. We'll see how afterwards,
-# let's finish with the replacement.
-#
-# Of course the solution above is wrong: if there were other calls to
-# `OLD' with different values, we would smash them to the same value.
-# But it is quite easy to generalize the scheme above:
-#
-# divert(-1)dnl
-# changequote([, ])
-# define([OLD([1],[2])], [NEW([1, 2], [3])])
-# define([OLD], [defn([OLD($@)])changequote()])
-# undefine([dnl])
-# undefine([m4_eval])
-# # Some more undefines...
-# changequote()
-# divert(0)dnl
-# dnl The Unbelievable Truth
-# changequote([, ])OLD(1, 2)
-# NEW([0, 0],
-# 0)
-#
-# i.e., for each call to obsolete macros, we build an array `call =>
-# value', and use a macro to dispatch these values. This results in:
-#
-# dnl The Unbelievable Truth
-# NEW([1, 2], [3])
-# NEW([0, 0],
-# 0)
-#
-# In French, we say `Youpi !', which you might roughly translate as
-# `yipeee!'.
-#
-#
-# # First step: computation
-# # -----------------------
-#
-# Let's study the anatomy of the file, and name its sections:
-#
-# prologue
-# divert(-1)dnl
-# changequote([, ])
-# values
-# define([OLD([1],[2])], [NEW([1, 2], [3])])
-# dispatcher
-# define([OLD], [defn([OLD($@)])changequote()])
-# disabler
-# undefine([dnl])
-# undefine([m4_eval])
-# # Some more undefines...
-# changequote()
-# divert(0)dnl
-# input
-# dnl The Unbelievable Truth
-# changequote([, ])OLD(1, 2)
-# NEW([0, 0],
-# 0)
-#
-#
-# # Computing the `values' section
-# # ..............................
-#
-# First we need to get the list of all the AU macro uses. To this end,
-# first get the list of all the AU macros names by tracing `AU_DEFUN' in
-# the initialization of autoconf. This list is computed in the file
-# `au.txt' below.
-#
-# Then use this list to trace all the AU macro uses in the input. The
-# goal is obtain in the case of our example:
-#
-# [define([OLD([1],[2])],]@<<@OLD([1],[2])@>>@[)]
-#
-# This is the file `values.in' below.
-#
-# We want to evaluate this with only the builtins (in fact m4sugar), the
-# auto-quoting definitions of the new macros (`new.m4'), and the
-# definition of the old macros (`old.m4'). Computing these last two
-# files is easy: it's just a matter of using the right `--trace' option.
-#
-# So the content of `values.in' is:
-#
-# include($autoconf_dir/m4sugar.m4)
-# m4_include(new.m4)
-# m4_include(old.m4)
-# divert(0)dnl
-# [define([OLD([1],[2])],]@<<@OLD([1],[2])@>>@[)]
-#
-# We run m4 on it, which yields:
-#
-# define([OLD([1],[2])],@<<@NEW([1, 2], [3])@>>@)
-#
-# Transform `@<<@' and `@>>@' into quotes and we get
-#
-# define([OLD([1],[2])],[NEW([1, 2], [3])])
-#
-# This is `values.m4'.
-#
-#
-# # Computing the `dispatcher' section
-# # ..................................
-#
-# The `prologue', and the `disabler' are simple and need no commenting.
-#
-# To compute the `dispatcher' (`dispatch.m4'), again, it is a simple
-# matter of using the right `--trace'.
-#
-# Finally, the input is not exactly the input file, rather it is the
-# input file with the added `changequote'. To this end, we build
-# `quote.sed'.
-#
-#
-# # Putting it all together
-# # .......................
-#
-# We build the file `input.m4' which contains:
-#
-# divert(-1)dnl
-# changequote([, ])
-# include(values.m4)
-# include(dispatch.m4)
-# undefine([dnl])
-# undefine([eval])
-# # Some more undefines...
-# changequote()
-# divert(0)dnl
-# dnl The Unbelievable Truth
-# changequote([, ])OLD(1, 2)
-# NEW([0, 0],
-# 0)
-#
-# And we just run m4 on it. Et voila`, Monsieur ! Mais oui, mais oui.
-#
-# Well, there are a few additional technicalities. For instance, we
-# rely on `changequote', `ifelse' and `defn', but we don't want to
-# interpret the changequotes of the user, so we simply use another name:
-# `_au_changequote' etc.
-#
-#
-# # Failure of the fourth approach
-# # ------------------------------
-#
-# This approach is heavily based on traces, but then there is an obvious
-# problem: non expanded code will never be seen/ In particular, the body
-# of a `define' definition is not seen, so on the input
-#
-# define([idem], [OLD(0, [$1])])
-#
-# autoupdate would never see the `OLD', and wouldn't have updated it.
-# Worse yet, if `idem(0)' was used later, then autoupdate sees that
-# `OLD' is used, computes the result for `OLD(0, 0)' and sets up a
-# dispatcher for `OLD'. Since there was no computed value for `OLD(0,
-# [$1])', the dispatcher would have replaced with... nothinhg, leading
-# to
-#
-# define([idem], [])
-#
-# With some more thinking, you see that the two step approach is wrong,
-# the namespace approach was much saner.
-#
-# But you learned a lot, in particular you realized that using traces
-# can make it possible to simulate namespaces!
-#
-#
-#
-# # The fifth implementation: m4 namespaces by files
-# # ================================================
-#
-# The fourth implementation demonstrated something unsurprising: you
-# cannot precompute, i.e., the namespace approach was the right one.
-# Still, we no longer want them, they're too expensive. Let's have a
-# look at the way it worked.
-#
-# When updating
-#
-# dnl The Unbelievable Truth
-# OLD(1, 2)
-# NEW([0, 0], [0])
-#
-# you evaluate `input.m4':
-#
-# divert(-1)
-# changequote([, ])
-# define([OLD],
-# [m4_enable()NEW([$1, $2], m4_eval([$1 + $2]))m4_disable()])
-# ...
-# m4_disable()
-# dnl The Unbelievable Truth
-# OLD(1, 2)
-# NEW([0, 0], [0])
-#
-# where `m4_disable' undefines the m4 and m4sugar, and disables the quotes
-# and comments:
-#
-# define([m4_disable],
-# [undefine([__file__])
-# ...
-# changecom(#)
-# changequote()])
-#
-# `m4_enable' does the converse: reestablish quotes and comments
-# --easy--, reestablish m4sugar --easy: just load `m4sugar.m4' again-- and
-# reenable the builtins. This later task requires that you first save
-# the builtins. And BTW, the definition above of `m4_disable' cannot
-# work: you undefined `changequote' before using it! So you need to use
-# your privates copies of the builtins. Let's introduce three files for
-# this:
-#
-# `m4save.m4'
-# moves the m4 builtins into the `_au_' pseudo namespace
-# `unm4.m4'
-# undefines the builtins
-# `m4.m4'
-# restores them
-#
-# So `input.m4' is:
-#
-# divert(-1)
-# changequote([, ])
-#
-# include([m4save.m4])
-#
-# # Import AU.
-# define([OLD],
-# [m4_enable()NEW([$1, $2], m4_eval([$1 + $2]))m4_disable()])
-#
-# define([_au_enable],
-# [_au_changecom([#])
-# _au_include([m4.m4])
-# _au_include(m4sugar.m4)])
-#
-# define([_au_disable],
-# [# Disable m4sugar.
-# # Disable the m4 builtins.
-# _au_include([unm4.m4])
-# # 1. Disable special characters.
-# _au_changequote()
-# _au_changecom()])
-#
-# m4_disable()
-# dnl The Unbelievable Truth
-# OLD(1, 2)
-# NEW([0, 0], [0])
-#
-# Based on what we learned in the fourth implementation we know that we
-# have to enable the quotes *before* any AU macro, and we know we need
-# to build autoquoting versions of the AC macros. But the autoquoting
-# AC definitions must be disabled in the rest of the file, and enabled
-# inside AU macros.
-#
-# Using `autoconf --trace' it is easy to build the files
-#
-# `ac.m4'
-# define the autoquoting AC fake macros
-# `disable.m4'
-# undefine the m4sugar and AC autoquoting macros.
-# `au.m4'
-# definitions of the AU macros (such as `OLD' above).
-#
-# Now, `input.m4' is:
-#
-# divert(-1)
-# changequote([, ])
-#
-# include([m4save.m4])
-# # Import AU.
-# include([au.m4])
-#
-# define([_au_enable],
-# [_au_changecom([#])
-# _au_include([m4.m4])
-# _au_include(m4sugar.m4)
-# _au_include(ac.m4)])
-#
-# define([_au_disable],
-# [_au_include([disable.m4])
-# _au_include([unm4.m4])
-# # 1. Disable special characters.
-# _au_changequote()
-# _au_changecom()])
-#
-# m4_disable()
-# dnl The Unbelievable Truth
-# _au_changequote([, ])OLD(1, 2)
-# NEW([0, 0], [0])
-#
-# Finally, version V is ready.
-#
-# Well... almost.
-#
-# There is a slight problem that remains: if an AU macro OUTTER includes
-# an AU macro INNER, then _au_enable will be run when entering OUTTER
-# and when entering INNER (not good, but not too bad yet). But when
-# getting out of INNER, _au_disable will disable everything while we
-# were still in OUTTER. Badaboom.
-#
-# Therefore _au_enable and _au_disable have to be written to work by
-# pairs: each _au_enable pushdef's _au_enabled, and each _au_disable
-# popdef's _au_enabled. And of course _au_enable and _au_disable are
-# effective when _au_enabled is *not* defined.
-#
-# Finally, version V' is ready. And there is much rejoicing. (And I
-# have free time again. I think. Yeah, right.)
}
use Data::Dumper;
-use Autoconf::Struct;
+use Autom4te::Struct;
use Carp;
use Getopt::Long;
use IO::File;
# only ac_max_sed_lines should be used.
: ${ac_max_here_lines=38}
-ac_unique_file="autoconf.in"
+ac_unique_file="ChangeLog"
# Initialize some variables set by options.
ac_init_help=
MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
# Initialize the test suite.
-AUTOTEST_PATH=..
+AUTOTEST_PATH=../bin
# Extract the first word of "expr", so it can be a program name with args.
set dummy expr; ac_word=$2
# This is needed because Automake does not seem to realize there is
# a AC-SUBST inside AC-PROG-GNU-M4. Grmph!
-# `autoconf' and `ifnames' use AWK. And we need decent RE support.
+# `ifnames' uses AWK.
for ac_prog in mawk gawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
test -n "$AWK" && break
done
-# Some AWK fail
-if echo xfoo | $AWK '/foo|^bar$/ { print }' | grep xfoo >/dev/null; then :; else
- { { echo "$as_me:1276: error: the regex engine of $AWK is too broken to be used
- you might want to install GNU AWK" >&5
-echo "$as_me: error: the regex engine of $AWK is too broken to be used
- you might want to install GNU AWK" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
# Generating man pages.
HELP2MAN=${HELP2MAN-"${am_missing_run}help2man"}
# We use a path for perl so the #! line in autoscan will work.
# Extract the first word of "perl", so it can be a program name with args.
set dummy perl; ac_word=$2
-echo "$as_me:1290: checking for $ac_word" >&5
+echo "$as_me:1281: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_PERL+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
test -z "$ac_dir" && ac_dir=.
if $as_executable_p "$ac_dir/$ac_word"; then
ac_cv_path_PERL="$ac_dir/$ac_word"
- echo "$as_me:1307: found $ac_dir/$ac_word" >&5
+ echo "$as_me:1298: found $ac_dir/$ac_word" >&5
break
fi
done
PERL=$ac_cv_path_PERL
if test -n "$PERL"; then
- echo "$as_me:1319: result: $PERL" >&5
+ echo "$as_me:1310: result: $PERL" >&5
echo "${ECHO_T}$PERL" >&6
else
- echo "$as_me:1322: result: no" >&5
+ echo "$as_me:1313: result: no" >&5
echo "${ECHO_T}no" >&6
fi
if test "$PERL" = no; then
- { { echo "$as_me:1327: error: perl is not found" >&5
+ { { echo "$as_me:1318: error: perl is not found" >&5
echo "$as_me: error: perl is not found" >&2;}
{ (exit 1); exit 1; }; }
fi
+$PERL -e 'require 5.005;' || {
+ { { echo "$as_me:1323: error: perl 5.005 or better is required" >&5
+echo "$as_me: error: perl 5.005 or better is required" >&2;}
+ { (exit 1); exit 1; }; }
+}
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:1344: checking for a BSD compatible install" >&5
+echo "$as_me:1340: checking for a BSD compatible install" >&5
echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_install_sh
fi
fi
-echo "$as_me:1393: result: $INSTALL" >&5
+echo "$as_me:1389: result: $INSTALL" >&5
echo "${ECHO_T}$INSTALL" >&6
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# Automake can't see inner AC_SUBSTS (`aclocal' is bypassed), so we tag the
# AC_SUBSTS here too.
-ac_config_files="$ac_config_files Makefile m4/Makefile man/Makefile doc/Makefile config/Makefile lib/Makefile lib/Autoconf/Makefile lib/autoscan/Makefile lib/m4sugar/Makefile lib/autoconf/Makefile lib/autotest/Makefile tests/Makefile tests/atconfig"
+ac_config_files="$ac_config_files Makefile m4/Makefile man/Makefile doc/Makefile config/Makefile lib/Makefile lib/Autom4te/Makefile lib/autoscan/Makefile lib/m4sugar/Makefile lib/autoconf/Makefile lib/autotest/Makefile bin/Makefile tests/Makefile tests/atconfig"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:1518: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:1514: creating $CONFIG_STATUS" >&5
echo "$as_me: creating $CONFIG_STATUS" >&6;}
cat >$CONFIG_STATUS <<_ACEOF
#! $SHELL
echo "$ac_cs_version"; exit 0 ;;
--he | --h)
# Conflict between --help and --header
- { { echo "$as_me:1686: error: ambiguous option: $1
+ { { echo "$as_me:1682: error: ambiguous option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2;}
ac_need_defaults=false;;
# This is an error.
- -*) { { echo "$as_me:1705: error: unrecognized option: $1
+ -*) { { echo "$as_me:1701: error: unrecognized option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2;}
"doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"config/Makefile" ) CONFIG_FILES="$CONFIG_FILES config/Makefile" ;;
"lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
- "lib/Autoconf/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Autoconf/Makefile" ;;
+ "lib/Autom4te/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Autom4te/Makefile" ;;
"lib/autoscan/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/autoscan/Makefile" ;;
"lib/m4sugar/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/m4sugar/Makefile" ;;
"lib/autoconf/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/autoconf/Makefile" ;;
"lib/autotest/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/autotest/Makefile" ;;
+ "bin/Makefile" ) CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;;
"tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
"tests/atconfig" ) CONFIG_FILES="$CONFIG_FILES tests/atconfig" ;;
- *) { { echo "$as_me:1753: error: invalid argument: $ac_config_target" >&5
+ *) { { echo "$as_me:1750: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
esac
esac
if test x"$ac_file" != x-; then
- { echo "$as_me:1964: creating $ac_file" >&5
+ { echo "$as_me:1961: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
rm -f "$ac_file"
fi
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:1982: error: cannot find input file: $f" >&5
+ test -f "$f" || { { echo "$as_me:1979: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
echo $f;;
echo $srcdir/$f
else
# /dev/null tree
- { { echo "$as_me:1995: error: cannot find input file: $f" >&5
+ { { echo "$as_me:1992: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
fi
# Report the state of this version of Autoconf if this is a beta.
-case 2.52a in
- *[a-z]*)
cat <<EOF
You are about to use an experimental version of Autoconf. Be sure to
Below you will find information on the status of this version of Autoconf.
EOF
- sed -n '/^\* Status/,$p' $srcdir/BUGS;;
-esac
+ sed -n '/^\* Status/,$p' $srcdir/BUGS
+
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(GNU Autoconf, 2.52a, bug-autoconf@gnu.org)
-AC_CONFIG_SRCDIR(autoconf.in)
+AC_CONFIG_SRCDIR(ChangeLog)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(autoconf, 2.52a)
# Initialize the test suite.
-AT_CONFIG(..)
+AT_CONFIG(../bin)
AC_PATH_PROG(EXPR, expr)
# We use a path for GNU m4 so even if users have another m4 first in
AC_SUBST(VERSION)
AC_CONFIG_FILES(Makefile m4/Makefile man/Makefile doc/Makefile config/Makefile
- lib/Makefile lib/Autoconf/Makefile lib/autoscan/Makefile
+ lib/Makefile lib/Autom4te/Makefile lib/autoscan/Makefile
lib/m4sugar/Makefile
lib/autoconf/Makefile lib/autotest/Makefile
+ bin/Makefile
tests/Makefile tests/atconfig)
AC_OUTPUT
+++ /dev/null
-#! @SHELL@
-# -*- shell-script -*-
-# ifnames - print the identifiers used in C preprocessor conditionals
-# Copyright 1994, 1995, 1999, 2000 Free Software Foundation, Inc.
-
-# This program 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; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# Reads from stdin if no files are given.
-# Writes to stdout.
-
-# Written by David MacKenzie <djm@gnu.ai.mit.edu>
-# and Paul Eggert <eggert@twinsun.com>.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] ... [FILE] ...
-
-Scan all of the C source FILES (or the standard input, if none are
-given) and write to the standard output a sorted list of all the
-identifiers that appear in those files in \`#if', \`#elif', \`#ifdef', or
-\`#ifndef' directives. Print each identifier on a line, followed by a
-space-separated list of the files in which that identifier occurs.
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
-
-Report bugs to <bug-autoconf@gnu.org>."
-
-version="\
-ifnames (@PACKAGE_NAME@) @VERSION@
-Written by David J. MacKenzie and Paul Eggert.
-
-Copyright 1994, 1995, 1999, 2000 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="\
-Try \`$me --help' for more information."
-
-while test $# -gt 0; do
- case "$1" in
- --help | -h )
- echo "$usage"; exit 0 ;;
- --version | -V )
- echo "$version"; exit 0 ;;
- --) # Stop option processing.
- shift; break ;;
- -*)
- exec >&2
- echo "$me: invalid option $1"
- echo "$help"
- exit 1 ;;
- *) break ;;
- esac
-done
-
-# Variables.
-: ${AWK=@AWK@}
-
-$AWK '
- # Record that sym was found in FILENAME.
- function file_sym(sym, i, fs)
- {
- if (sym ~ /^[A-Za-z_]/)
- {
- if (!found[sym,FILENAME])
- {
- found[sym,FILENAME] = 1
-
- # Insert FILENAME into files[sym], keeping the list sorted.
- i = 1
- fs = files[sym]
- while (match(substr(fs, i), /^ [^ ]*/) \
- && substr(fs, i + 1, RLENGTH - 1) < FILENAME)
- {
- i += RLENGTH
- }
- files[sym] = substr(fs, 1, i - 1) " " FILENAME substr(fs, i)
- }
- }
- }
-
- {
- while (sub(/\\$/, "", $0) > 0)
- {
- if ((getline tmp) > 0)
- $0 = $0 tmp
- else
- break
- }
- }
-
- /^[\t ]*#/ {
- if (sub(/^[\t ]*#[\t ]*ifn?def[\t ]+/, "", $0))
- {
- sub(/[^A-Za-z_0-9].*/, "", $0)
- file_sym($0)
- }
- if (sub(/^[\t ]*#[\t ]*(el)?if[\t ]+/, "", $0))
- {
- # Remove comments. Not perfect, but close enough.
- gsub(/\/\*[^\/]*(\*\/)?/, "", $0)
-
- for (i = split($0, field, /[^A-Za-z_0-9]+/); 1 <= i; i--)
- {
- if (field[i] != "defined")
- {
- file_sym(field[i])
- }
- }
- }
- }
-
- END {
- for (sym in files)
- {
- print sym files[sym]
- }
- }
-' ${1+"$@"} | sort
--- /dev/null
+## Process this file with automake to create Makefile.in
+
+perllibdir = $(pkgdatadir)/Autoconf
+perllib_DATA = Struct.pm
+EXTRA_DIST = $(perllib_DATA)
--- /dev/null
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+AWK = @AWK@
+EXPR = @EXPR@
+HELP2MAN = @HELP2MAN@
+M4 = @M4@
+PACKAGE = @PACKAGE@
+PACKAGE_NAME = @PACKAGE_NAME@
+PERL = @PERL@
+VERSION = @VERSION@
+
+perllibdir = $(pkgdatadir)/Autoconf
+perllib_DATA = Struct.pm
+EXTRA_DIST = $(perllib_DATA)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_CLEAN_FILES =
+DATA = $(perllib_DATA)
+
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+all: all-redirect
+.SUFFIXES:
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Autom4te/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+install-perllibDATA: $(perllib_DATA)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(perllibdir)
+ @list='$(perllib_DATA)'; for p in $$list; do \
+ if test -f $(srcdir)/$$p; then \
+ echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(perllibdir)/$$p"; \
+ $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(perllibdir)/$$p; \
+ else if test -f $$p; then \
+ echo " $(INSTALL_DATA) $$p $(DESTDIR)$(perllibdir)/$$p"; \
+ $(INSTALL_DATA) $$p $(DESTDIR)$(perllibdir)/$$p; \
+ fi; fi; \
+ done
+
+uninstall-perllibDATA:
+ @$(NORMAL_UNINSTALL)
+ list='$(perllib_DATA)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(perllibdir)/$$p; \
+ done
+tags: TAGS
+TAGS:
+
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = lib/Autom4te
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu lib/Autom4te/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
+install-exec: install-exec-am
+
+install-data-am: install-perllibDATA
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-perllibDATA
+uninstall: uninstall-am
+all-am: Makefile $(DATA)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(perllibdir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-generic clean-am
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: uninstall-perllibDATA install-perllibDATA tags distdir info-am \
+info dvi-am dvi check check-am installcheck-am installcheck \
+install-exec-am install-exec install-data-am install-data install-am \
+install uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
--- /dev/null
+# autoconf -- create `configure' using m4 macros
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program 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; either version 2, or (at your option)
+# any later version.
+
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+package Autom4te::Struct;
+
+## See POD after __END__
+
+use 5.005;
+
+use strict;
+use vars qw(@ISA @EXPORT $VERSION);
+
+use Carp;
+
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw(struct);
+
+$VERSION = '0.58';
+
+## Tested on 5.002 and 5.003 without class membership tests:
+my $CHECK_CLASS_MEMBERSHIP = ($] >= 5.003_95);
+
+my $print = 0;
+sub printem {
+ if (@_) { $print = shift }
+ else { $print++ }
+}
+
+{
+ package Class::Struct::Tie_ISA;
+
+ sub TIEARRAY {
+ my $class = shift;
+ return bless [], $class;
+ }
+
+ sub STORE {
+ my ($self, $index, $value) = @_;
+ Class::Struct::_subclass_error();
+ }
+
+ sub FETCH {
+ my ($self, $index) = @_;
+ $self->[$index];
+ }
+
+ sub FETCHSIZE {
+ my $self = shift;
+ return scalar(@$self);
+ }
+
+ sub DESTROY { }
+}
+
+sub struct {
+
+ # Determine parameter list structure, one of:
+ # struct( class => [ element-list ])
+ # struct( class => { element-list })
+ # struct( element-list )
+ # Latter form assumes current package name as struct name.
+
+ my ($class, @decls);
+ my $base_type = ref $_[1];
+ if ( $base_type eq 'HASH' ) {
+ $class = shift;
+ @decls = %{shift()};
+ _usage_error() if @_;
+ }
+ elsif ( $base_type eq 'ARRAY' ) {
+ $class = shift;
+ @decls = @{shift()};
+ _usage_error() if @_;
+ }
+ else {
+ $base_type = 'ARRAY';
+ $class = (caller())[0];
+ @decls = @_;
+ }
+ _usage_error() if @decls % 2 == 1;
+
+ # Ensure we are not, and will not be, a subclass.
+
+ my $isa = do {
+ no strict 'refs';
+ \@{$class . '::ISA'};
+ };
+ _subclass_error() if @$isa;
+ tie @$isa, 'Class::Struct::Tie_ISA';
+
+ # Create constructor.
+
+ croak "function 'new' already defined in package $class"
+ if do { no strict 'refs'; defined &{$class . "::new"} };
+
+ my @methods = ();
+ my %refs = ();
+ my %arrays = ();
+ my %hashes = ();
+ my %classes = ();
+ my $got_class = 0;
+ my $out = '';
+
+ $out = "{\n package $class;\n use Carp;\n sub new {\n";
+ $out .= " my (\$class, \%init) = \@_;\n";
+ $out .= " \$class = __PACKAGE__ unless \@_;\n";
+
+ my $cnt = 0;
+ my $idx = 0;
+ my( $cmt, $name, $type, $elem );
+
+ if( $base_type eq 'HASH' ){
+ $out .= " my(\$r) = {};\n";
+ $cmt = '';
+ }
+ elsif( $base_type eq 'ARRAY' ){
+ $out .= " my(\$r) = [];\n";
+ }
+ while( $idx < @decls ){
+ $name = $decls[$idx];
+ $type = $decls[$idx+1];
+ push( @methods, $name );
+ if( $base_type eq 'HASH' ){
+ $elem = "{'${class}::$name'}";
+ }
+ elsif( $base_type eq 'ARRAY' ){
+ $elem = "[$cnt]";
+ ++$cnt;
+ $cmt = " # $name";
+ }
+ if( $type =~ /^\*(.)/ ){
+ $refs{$name}++;
+ $type = $1;
+ }
+ my $init = "defined(\$init{'$name'}) ? \$init{'$name'} :";
+ if( $type eq '@' ){
+ $out .= " croak 'Initializer for $name must be array reference'\n";
+ $out .= " if defined(\$init{'$name'}) && ref(\$init{'$name'}) ne 'ARRAY';\n";
+ $out .= " \$r->$elem = $init [];$cmt\n";
+ $arrays{$name}++;
+ }
+ elsif( $type eq '%' ){
+ $out .= " croak 'Initializer for $name must be hash reference'\n";
+ $out .= " if defined(\$init{'$name'}) && ref(\$init{'$name'}) ne 'HASH';\n";
+ $out .= " \$r->$elem = $init {};$cmt\n";
+ $hashes{$name}++;
+ }
+ elsif ( $type eq '$') {
+ $out .= " \$r->$elem = $init undef;$cmt\n";
+ }
+ elsif( $type =~ /^\w+(?:::\w+)*$/ ){
+ $init = "defined(\$init{'$name'}) ? \%{\$init{'$name'}} : ()";
+ $out .= " croak 'Initializer for $name must be hash reference'\n";
+ $out .= " if defined(\$init{'$name'}) && ref(\$init{'$name'}) ne 'HASH';\n";
+ $out .= " \$r->$elem = '${type}'->new($init);$cmt\n";
+ $classes{$name} = $type;
+ $got_class = 1;
+ }
+ else{
+ croak "'$type' is not a valid struct element type";
+ }
+ $idx += 2;
+ }
+ $out .= " bless \$r, \$class;\n }\n";
+
+ # Create accessor methods.
+
+ my( $pre, $pst, $sel );
+ $cnt = 0;
+ foreach $name (@methods){
+ if ( do { no strict 'refs'; defined &{$class . "::$name"} } ) {
+ carp "function '$name' already defined, overrides struct accessor method";
+ }
+ else {
+ $pre = $pst = $cmt = $sel = '';
+ if( defined $refs{$name} ){
+ $pre = "\\(";
+ $pst = ")";
+ $cmt = " # returns ref";
+ }
+ $out .= " sub $name {$cmt\n my \$r = shift;\n";
+ if( $base_type eq 'ARRAY' ){
+ $elem = "[$cnt]";
+ ++$cnt;
+ }
+ elsif( $base_type eq 'HASH' ){
+ $elem = "{'${class}::$name'}";
+ }
+ if( defined $arrays{$name} ){
+ $out .= " my \$i;\n";
+ $out .= " \@_ ? (\$i = shift) : return \$r->$elem;\n";
+ $sel = "->[\$i]";
+ }
+ elsif( defined $hashes{$name} ){
+ $out .= " my \$i;\n";
+ $out .= " \@_ ? (\$i = shift) : return \$r->$elem;\n";
+ $sel = "->{\$i}";
+ }
+ elsif( defined $classes{$name} ){
+ if ( $CHECK_CLASS_MEMBERSHIP ) {
+ $out .= " croak '$name argument is wrong class' if \@_ && ! UNIVERSAL::isa(\$_[0], '$classes{$name}');\n";
+ }
+ }
+ $out .= " croak 'Too many args to $name' if \@_ > 1;\n";
+ $out .= " \@_ ? ($pre\$r->$elem$sel = shift$pst) : $pre\$r->$elem$sel$pst;\n";
+ $out .= " }\n";
+ }
+ }
+ $out .= "}\n1;\n";
+
+ print $out if $print;
+ my $result = eval $out;
+ carp $@ if $@;
+}
+
+sub _usage_error {
+ confess "struct usage error";
+}
+
+sub _subclass_error {
+ croak 'struct class cannot be a subclass (@ISA not allowed)';
+}
+
+1; # for require
+
+
+__END__
+
+=head1 NAME
+
+Class::Struct - declare struct-like datatypes as Perl classes
+
+=head1 SYNOPSIS
+
+ use Class::Struct;
+ # declare struct, based on array:
+ struct( CLASS_NAME => [ ELEMENT_NAME => ELEMENT_TYPE, ... ]);
+ # declare struct, based on hash:
+ struct( CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... });
+
+ package CLASS_NAME;
+ use Class::Struct;
+ # declare struct, based on array, implicit class name:
+ struct( ELEMENT_NAME => ELEMENT_TYPE, ... );
+
+
+ package Myobj;
+ use Class::Struct;
+ # declare struct with four types of elements:
+ struct( s => '$', a => '@', h => '%', c => 'My_Other_Class' );
+
+ $obj = new Myobj; # constructor
+
+ # scalar type accessor:
+ $element_value = $obj->s; # element value
+ $obj->s('new value'); # assign to element
+
+ # array type accessor:
+ $ary_ref = $obj->a; # reference to whole array
+ $ary_element_value = $obj->a(2); # array element value
+ $obj->a(2, 'new value'); # assign to array element
+
+ # hash type accessor:
+ $hash_ref = $obj->h; # reference to whole hash
+ $hash_element_value = $obj->h('x'); # hash element value
+ $obj->h('x', 'new value'); # assign to hash element
+
+ # class type accessor:
+ $element_value = $obj->c; # object reference
+ $obj->c->method(...); # call method of object
+ $obj->c(new My_Other_Class); # assign a new object
+
+
+=head1 DESCRIPTION
+
+C<Class::Struct> exports a single function, C<struct>.
+Given a list of element names and types, and optionally
+a class name, C<struct> creates a Perl 5 class that implements
+a "struct-like" data structure.
+
+The new class is given a constructor method, C<new>, for creating
+struct objects.
+
+Each element in the struct data has an accessor method, which is
+used to assign to the element and to fetch its value. The
+default accessor can be overridden by declaring a C<sub> of the
+same name in the package. (See Example 2.)
+
+Each element's type can be scalar, array, hash, or class.
+
+
+=head2 The C<struct()> function
+
+The C<struct> function has three forms of parameter-list.
+
+ struct( CLASS_NAME => [ ELEMENT_LIST ]);
+ struct( CLASS_NAME => { ELEMENT_LIST });
+ struct( ELEMENT_LIST );
+
+The first and second forms explicitly identify the name of the
+class being created. The third form assumes the current package
+name as the class name.
+
+An object of a class created by the first and third forms is
+based on an array, whereas an object of a class created by the
+second form is based on a hash. The array-based forms will be
+somewhat faster and smaller; the hash-based forms are more
+flexible.
+
+The class created by C<struct> must not be a subclass of another
+class other than C<UNIVERSAL>.
+
+It can, however, be used as a superclass for other classes. To facilitate
+this, the generated constructor method uses a two-argument blessing.
+Furthermore, if the class is hash-based, the key of each element is
+prefixed with the class name (see I<Perl Cookbook>, Recipe 13.12).
+
+A function named C<new> must not be explicitly defined in a class
+created by C<struct>.
+
+The I<ELEMENT_LIST> has the form
+
+ NAME => TYPE, ...
+
+Each name-type pair declares one element of the struct. Each
+element name will be defined as an accessor method unless a
+method by that name is explicitly defined; in the latter case, a
+warning is issued if the warning flag (B<-w>) is set.
+
+
+=head2 Element Types and Accessor Methods
+
+The four element types -- scalar, array, hash, and class -- are
+represented by strings -- C<'$'>, C<'@'>, C<'%'>, and a class name --
+optionally preceded by a C<'*'>.
+
+The accessor method provided by C<struct> for an element depends
+on the declared type of the element.
+
+=over
+
+=item Scalar (C<'$'> or C<'*$'>)
+
+The element is a scalar, and by default is initialized to C<undef>
+(but see L<Initializing with new>).
+
+The accessor's argument, if any, is assigned to the element.
+
+If the element type is C<'$'>, the value of the element (after
+assignment) is returned. If the element type is C<'*$'>, a reference
+to the element is returned.
+
+=item Array (C<'@'> or C<'*@'>)
+
+The element is an array, initialized by default to C<()>.
+
+With no argument, the accessor returns a reference to the
+element's whole array (whether or not the element was
+specified as C<'@'> or C<'*@'>).
+
+With one or two arguments, the first argument is an index
+specifying one element of the array; the second argument, if
+present, is assigned to the array element. If the element type
+is C<'@'>, the accessor returns the array element value. If the
+element type is C<'*@'>, a reference to the array element is
+returned.
+
+=item Hash (C<'%'> or C<'*%'>)
+
+The element is a hash, initialized by default to C<()>.
+
+With no argument, the accessor returns a reference to the
+element's whole hash (whether or not the element was
+specified as C<'%'> or C<'*%'>).
+
+With one or two arguments, the first argument is a key specifying
+one element of the hash; the second argument, if present, is
+assigned to the hash element. If the element type is C<'%'>, the
+accessor returns the hash element value. If the element type is
+C<'*%'>, a reference to the hash element is returned.
+
+=item Class (C<'Class_Name'> or C<'*Class_Name'>)
+
+The element's value must be a reference blessed to the named
+class or to one of its subclasses. The element is initialized to
+the result of calling the C<new> constructor of the named class.
+
+The accessor's argument, if any, is assigned to the element. The
+accessor will C<croak> if this is not an appropriate object
+reference.
+
+If the element type does not start with a C<'*'>, the accessor
+returns the element value (after assignment). If the element type
+starts with a C<'*'>, a reference to the element itself is returned.
+
+=back
+
+=head2 Initializing with C<new>
+
+C<struct> always creates a constructor called C<new>. That constructor
+may take a list of initializers for the various elements of the new
+struct.
+
+Each initializer is a pair of values: I<element name>C< =E<gt> >I<value>.
+The initializer value for a scalar element is just a scalar value. The
+initializer for an array element is an array reference. The initializer
+for a hash is a hash reference.
+
+The initializer for a class element is also a hash reference, and the
+contents of that hash are passed to the element's own constructor.
+
+See Example 3 below for an example of initialization.
+
+
+=head1 EXAMPLES
+
+=over
+
+=item Example 1
+
+Giving a struct element a class type that is also a struct is how
+structs are nested. Here, C<timeval> represents a time (seconds and
+microseconds), and C<rusage> has two elements, each of which is of
+type C<timeval>.
+
+ use Class::Struct;
+
+ struct( rusage => {
+ ru_utime => timeval, # seconds
+ ru_stime => timeval, # microseconds
+ });
+
+ struct( timeval => [
+ tv_secs => '$',
+ tv_usecs => '$',
+ ]);
+
+ # create an object:
+ my $t = new rusage;
+
+ # $t->ru_utime and $t->ru_stime are objects of type timeval.
+ # set $t->ru_utime to 100.0 sec and $t->ru_stime to 5.0 sec.
+ $t->ru_utime->tv_secs(100);
+ $t->ru_utime->tv_usecs(0);
+ $t->ru_stime->tv_secs(5);
+ $t->ru_stime->tv_usecs(0);
+
+
+=item Example 2
+
+An accessor function can be redefined in order to provide
+additional checking of values, etc. Here, we want the C<count>
+element always to be nonnegative, so we redefine the C<count>
+accessor accordingly.
+
+ package MyObj;
+ use Class::Struct;
+
+ # declare the struct
+ struct ( 'MyObj', { count => '$', stuff => '%' } );
+
+ # override the default accessor method for 'count'
+ sub count {
+ my $self = shift;
+ if ( @_ ) {
+ die 'count must be nonnegative' if $_[0] < 0;
+ $self->{'count'} = shift;
+ warn "Too many args to count" if @_;
+ }
+ return $self->{'count'};
+ }
+
+ package main;
+ $x = new MyObj;
+ print "\$x->count(5) = ", $x->count(5), "\n";
+ # prints '$x->count(5) = 5'
+
+ print "\$x->count = ", $x->count, "\n";
+ # prints '$x->count = 5'
+
+ print "\$x->count(-5) = ", $x->count(-5), "\n";
+ # dies due to negative argument!
+
+=item Example 3
+
+The constructor of a generated class can be passed a list
+of I<element>=>I<value> pairs, with which to initialize the struct.
+If no initializer is specified for a particular element, its default
+initialization is performed instead. Initializers for non-existent
+elements are silently ignored.
+
+Note that the initializer for a nested struct is specified
+as an anonymous hash of initializers, which is passed on to the nested
+struct's constructor.
+
+
+ use Class::Struct;
+
+ struct Breed =>
+ {
+ name => '$',
+ cross => '$',
+ };
+
+ struct Cat =>
+ [
+ name => '$',
+ kittens => '@',
+ markings => '%',
+ breed => 'Breed',
+ ];
+
+
+ my $cat = Cat->new( name => 'Socks',
+ kittens => ['Monica', 'Kenneth'],
+ markings => { socks=>1, blaze=>"white" },
+ breed => { name=>'short-hair', cross=>1 },
+ );
+
+ print "Once a cat called ", $cat->name, "\n";
+ print "(which was a ", $cat->breed->name, ")\n";
+ print "had two kittens: ", join(' and ', @{$cat->kittens}), "\n";
+
+=back
+
+=head1 Author and Modification History
+
+
+Modified by Damian Conway, 1999-03-05, v0.58.
+
+ Added handling of hash-like arg list to class ctor.
+
+ Changed to two-argument blessing in ctor to support
+ derivation from created classes.
+
+ Added classname prefixes to keys in hash-based classes
+ (refer to "Perl Cookbook", Recipe 13.12 for rationale).
+
+ Corrected behaviour of accessors for '*@' and '*%' struct
+ elements. Package now implements documented behaviour when
+ returning a reference to an entire hash or array element.
+ Previously these were returned as a reference to a reference
+ to the element.
+
+
+Renamed to C<Class::Struct> and modified by Jim Miner, 1997-04-02.
+
+ members() function removed.
+ Documentation corrected and extended.
+ Use of struct() in a subclass prohibited.
+ User definition of accessor allowed.
+ Treatment of '*' in element types corrected.
+ Treatment of classes as element types corrected.
+ Class name to struct() made optional.
+ Diagnostic checks added.
+
+
+Originally C<Class::Template> by Dean Roehrich.
+
+ # Template.pm --- struct/member template builder
+ # 12mar95
+ # Dean Roehrich
+ #
+ # changes/bugs fixed since 28nov94 version:
+ # - podified
+ # changes/bugs fixed since 21nov94 version:
+ # - Fixed examples.
+ # changes/bugs fixed since 02sep94 version:
+ # - Moved to Class::Template.
+ # changes/bugs fixed since 20feb94 version:
+ # - Updated to be a more proper module.
+ # - Added "use strict".
+ # - Bug in build_methods, was using @var when @$var needed.
+ # - Now using my() rather than local().
+ #
+ # Uses perl5 classes to create nested data types.
+ # This is offered as one implementation of Tom Christiansen's "structs.pl"
+ # idea.
+
+=cut
## Process this file with automake to create Makefile.in
-SUBDIRS = Autoconf m4sugar autoconf autotest autoscan
+SUBDIRS = Autom4te m4sugar autoconf autotest autoscan
PERL = @PERL@
VERSION = @VERSION@
-SUBDIRS = Autoconf m4sugar autoconf autotest autoscan
+SUBDIRS = Autom4te m4sugar autoconf autotest autoscan
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
CONFIG_CLEAN_FILES =
DIST_COMMON = Makefile.am Makefile.in
# Depend on configure.ac to get version number changes.
common_dep = $(top_srcdir)/configure.ac $(srcdir)/common.x
-autoconf.1: $(common_dep) $(srcdir)/autoconf.x $(top_srcdir)/autoconf.in
-autoheader.1: $(common_dep) $(srcdir)/autoheader.x $(top_srcdir)/autoheader.in
-autom4te.1: $(common_dep) $(srcdir)/autom4te.x $(top_srcdir)/autom4te.in
-autoreconf.1: $(common_dep) $(srcdir)/autoreconf.x $(top_srcdir)/autoreconf.in
-autoscan.1: $(common_dep) $(srcdir)/autoscan.x $(top_srcdir)/autoscan.in
-autoupdate.1: $(common_dep) $(srcdir)/autoupdate.x $(top_srcdir)/autoupdate.in
-ifnames.1: $(common_dep) $(srcdir)/ifnames.x $(top_srcdir)/ifnames.in
+binsrcdir = $(top_srcdir)/bin
+autoconf.1: $(common_dep) $(srcdir)/autoconf.x $(binsrcdir)/autoconf.in
+autoheader.1: $(common_dep) $(srcdir)/autoheader.x $(binsrcdir)/autoheader.in
+autom4te.1: $(common_dep) $(srcdir)/autom4te.x $(binsrcdir)/autom4te.in
+autoreconf.1: $(common_dep) $(srcdir)/autoreconf.x $(binsrcdir)/autoreconf.in
+autoscan.1: $(common_dep) $(srcdir)/autoscan.x $(binsrcdir)/autoscan.in
+autoupdate.1: $(common_dep) $(srcdir)/autoupdate.x $(binsrcdir)/autoupdate.in
+ifnames.1: $(common_dep) $(srcdir)/ifnames.x $(binsrcdir)/ifnames.in
# Independent from this package.
config.guess.1: $(srcdir)/config.guess.x $(top_srcdir)/config/config.guess
SUFFIXES = .x .1
.x.1:
- test -f $(top_builddir)/$* && prog=$(top_builddir)/$*; \
- test -f $(top_srcdir)/$* && prog=$(top_srcdir)/$*; \
+ test -f $(top_builddir)/bin/$* && prog=$(top_builddir)/bin/$*; \
test -f $(top_srcdir)/config/$* && prog=$(top_srcdir)/config/$*; \
if test -n "$$prog"; then \
echo "Updating man page $@"; \
+ autom4te_perllibdir="$(top_srcdir)/lib" \
$(HELP2MAN) \
--include=$(srcdir)/$*.x \
--include=$(srcdir)/common.x \
# Depend on configure.ac to get version number changes.
common_dep = $(top_srcdir)/configure.ac $(srcdir)/common.x
+binsrcdir = $(top_srcdir)/bin
SUFFIXES = .x .1
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
-autoconf.1: $(common_dep) $(srcdir)/autoconf.x $(top_srcdir)/autoconf.in
-autoheader.1: $(common_dep) $(srcdir)/autoheader.x $(top_srcdir)/autoheader.in
-autom4te.1: $(common_dep) $(srcdir)/autom4te.x $(top_srcdir)/autom4te.in
-autoreconf.1: $(common_dep) $(srcdir)/autoreconf.x $(top_srcdir)/autoreconf.in
-autoscan.1: $(common_dep) $(srcdir)/autoscan.x $(top_srcdir)/autoscan.in
-autoupdate.1: $(common_dep) $(srcdir)/autoupdate.x $(top_srcdir)/autoupdate.in
-ifnames.1: $(common_dep) $(srcdir)/ifnames.x $(top_srcdir)/ifnames.in
+autoconf.1: $(common_dep) $(srcdir)/autoconf.x $(binsrcdir)/autoconf.in
+autoheader.1: $(common_dep) $(srcdir)/autoheader.x $(binsrcdir)/autoheader.in
+autom4te.1: $(common_dep) $(srcdir)/autom4te.x $(binsrcdir)/autom4te.in
+autoreconf.1: $(common_dep) $(srcdir)/autoreconf.x $(binsrcdir)/autoreconf.in
+autoscan.1: $(common_dep) $(srcdir)/autoscan.x $(binsrcdir)/autoscan.in
+autoupdate.1: $(common_dep) $(srcdir)/autoupdate.x $(binsrcdir)/autoupdate.in
+ifnames.1: $(common_dep) $(srcdir)/ifnames.x $(binsrcdir)/ifnames.in
# Independent from this package.
config.guess.1: $(srcdir)/config.guess.x $(top_srcdir)/config/config.guess
config.sub.1: $(srcdir)/config.sub.x $(top_srcdir)/config/config.sub
.x.1:
- test -f $(top_builddir)/$* && prog=$(top_builddir)/$*; \
- test -f $(top_srcdir)/$* && prog=$(top_srcdir)/$*; \
+ test -f $(top_builddir)/bin/$* && prog=$(top_builddir)/bin/$*; \
test -f $(top_srcdir)/config/$* && prog=$(top_srcdir)/config/$*; \
if test -n "$$prog"; then \
echo "Updating man page $@"; \
+ autom4te_perllibdir="$(top_srcdir)/lib" \
$(HELP2MAN) \
--include=$(srcdir)/$*.x \
--include=$(srcdir)/common.x \
check-local: atconfig testsuite
$(SHELL) testsuite
-AUTOM4TE = autom4te_perllibdir='$(top_srcdir)/lib' ../autom4te
+AUTOM4TE = autom4te_perllibdir='$(top_srcdir)/lib' ../bin/autom4te
testsuite: $(top_srcdir)/lib/m4sugar/m4sugar.m4 \
$(top_srcdir)/lib/m4sugar/m4sh.m4 \
$(top_srcdir)/lib/autotest/general.m4 \
EXTRA_DIST = README atspecific.m4 aclocal.m4 $(SUITE) mktests.sh
-AUTOM4TE = autom4te_perllibdir='$(top_srcdir)/lib' ../autom4te
+AUTOM4TE = autom4te_perllibdir='$(top_srcdir)/lib' ../bin/autom4te
# The files which contains macro we check for syntax. Don't use $(top_srcdir)
# here since below we explicitly `cd' to $srcdir. As for the dependencies,
DISTCLEANFILES = atconfig testsuite
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
CONFIG_CLEAN_FILES = atconfig
-DIST_COMMON = README Makefile.am Makefile.in atconfig.in configure \
-configure.ac
+DIST_COMMON = README Makefile.am Makefile.in atconfig.in config.guess \
+config.sub configure.in install-sh ltmain.sh
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)