dnl Process this file with autoconf to produce a configure script
dnl This file is part of publib
dnl "@(#)publib-framework:$Id: configure.in,v 1.7 1996/02/17 21:01:57 liw Exp $"
AC_INIT(Rules.mk.in)
changequote(,)dnl
srcdir="`cd $srcdir; pwd`"
objdir="`pwd`"
library=""
libshort=""
modules=""
verbmake="no"
assert="-UNDEBUG"
autoconf=yes
SAVEDCONFIG="${objdir}/Default.config"
if test -f "$SAVEDCONFIG"
then
	. "$SAVEDCONFIG"
else
	SAVEDCONFIG=""
fi
deflibrary="$library"
deflibshort="$libshort"
defmodules="$modules"
defverbmake="$verbmake"
defassert="$assert"
defautoconf="$autoconf"
changequote([,])dnl
AC_SUBST(library)
AC_SUBST(libshort)
AC_SUBST(modules)
AC_SUBST(verbmake)
AC_SUBST(ASSERT)
AC_SUBST(WARNCFLAGS)
AC_SUBST(SAVEDCONFIG)
AC_ARG_WITH(verbose-make,[  --with-verbose-make     Report progress during make],verbmake="$withval",verbmake="$defverbmake")
AC_ARG_WITH(library,[  --with-library          Specify base name for all installed files],library="$withval",library="$deflibrary")
AC_ARG_WITH(libshort,[  --with-libshort          Specify name of library file only],libshort="$withval",libshort="$deflibshort")
AC_ARG_WITH(modules,[  --with-modules          Specify module directory],modules="$withval",modules="$defmodules")
AC_ARG_WITH(noassert,[  --with-noassert         Don't generate code for assertions],ASSERT="yes",ASSERT="$defassert")
AC_SUBST(objdir)
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_MAKE_SET
AC_CHECK_PROG(MAKE,gmake,gmake,make)
AC_CHECK_PROG(AUTOCONF,autoconf,autoconf,:)
changequote(,)dnl
# Fix $modules
x=''
for i in `echo $modules | tr : " "`
do
	x="$x `cd $i;pwd`/*"
done
modules="$x"
# Fix library and libshort
if test "$library" = "xYzZy" -a "$libshort" = "xYzZy"
then
	echo "missing library name (--with-library and/or --with-libshort)" 2>&1
	exit 1
fi
if test "$library" = "xYzZy"; then library="$libshort"; fi
if test "$libshort" = "xYzZy"; then libshort="$library"; fi
if test "$ASSERT" = yes; then ASSERT="-UNDEBUG"; else ASSERT="-DNDEBUG"; fi
if test "$defautoconf" = no; then AUTOCONF=":"; fi
changequote([,])dnl
AC_OUTPUT(Makefile Rules.mk)

dnl ---------------------------------------------------------------
dnl Run configure scripts for all modules that have them
echo Running configure scripts in modules...

test -d config.modules || mkdir config.modules || exit 1
for i in $modules
do
	if test -f "$i/configure"
	then
		j="config.modules/`basename $i`"
		test -d "$j" || mkdir "$j" || exit 1
		echo Running "$AUTOCONF" in "$i"
		(cd "$i" && "$AUTOCONF")
		echo Running "$i/configure"
		(cd "$j" && "$i/configure") || exit 1
	fi
done
