#! /bin/sh

# (c) Andreas Barth <aba@muenchen.pro-bahn.de> 1999
# Dieses Programm ermglicht "von Hand" die configure-nderungen zu machen
# und steht unter der GPL
#
# taken from unix-connect-0.94 and hacked up for leafnode
# by  Ralf Wildenhues <ralf.wildenhues@gmx.de> 2002
# and Matthias Andree <matthias.andree@gmx.de> 2002
#
# This is subject to the GPL (as stated above in german) and does the
# substitutions done by configure (actually, recent autoconf versions do not
# replace everything until build time;  the built script does build time
# replacement.  DO NOT reorder the SUBSTNAMES unless you know what you are
# doing!
#
# Tries to extract some configure substitutions from $CONFIGURE_AC and
# is not very intelligent about its syntax.  Maybe better use autoconf -t ..

if test $# -ne 1
then
	echo >&2 "usage: $0 configure.ac"
	exit 1
fi

CONFIGURE_AC="$1"
SUBSTNAMES="VERSION
CPPFLAGS
DEFS
LIBS
prefix
exec_prefix
datarootdir
program_transform_name
bindir
sbindir
libexecdir
datadir
sysconfdir
sharedstatedir
localstatedir
libdir
includedir
oldincludedir
infodir
mandir
CC
RANLIB
AWK
NEWS_USER
"

AUTOSUBSTNAMES=`egrep '^[ ]*AC_SUBST|^[ ]*AC_CHECK_PROGS|^[ ]*AC_PATH_PROG(S)?' $CONFIGURE_AC | \
		sed 's/^[ 	]*\(AC_.*([^,]*\),.*/\1)/; s/^[ ]*AC_.*(\(.*\))/\1/; s/^\[\(.*\)\]/\1/; s/^[ 	]*\(.*\)[ 	]*/\1/;'`

echo "#! /bin/sh"
echo "# generated automatically by makesubst -- do not edit"
echo
echo "configure_input=\"DO NOT EDIT -- generated automatically by subst\""
for n in $SUBSTNAMES $AUTOSUBSTNAMES
do
	echo "$n=\"@$n@\""
done
echo "LC_ALL=C ; export LC_ALL"
echo "\"@SED@\"" \"
for n in configure_input $SUBSTNAMES $AUTOSUBSTNAMES
do
	echo "s%[@]$n@%\$$n%g;"
done
echo \"
