#!/bin/sh
#
# The real work is done in the `src' directory.  This is just here to
# allow for the standard ./configure && make && make install sequence
# from the topdirectory
#
# If you want to build for multiple architectures, do:
# 
#	% mkdir myarch
#	% cd myarch
#	% ../src/configure [options]
#	% make
#	% make install

TARGET=lite
configoptions=""
mtoptions="--enable-mt"

usage()
{ cat << _EOM_
Usage: configure option ... 

Options:

  --with-world:		Build all (default packages)
  --disable-mt:		Do not build for multi-threading

This toplevel configure  and  Makefile  ony   deal  with  very  standard
installations. More complicated cases should check INSTALL.notes and use
the configure and makefiles in the src and package directories.
_EOM_
}


while [ "$1" != "" ]; do
  case "$1" in
    --with-world)	TARGET=world
			shift
			;;
    --disable-mt)	mtoptions=""
			shift
			;;
    --help)		usage
    			exit 0
			;;
    *)			configoptions="$configoptions $1"
			shift
			;;
  esac
done

if [ -z "$BUILDARCH" ]; then
  BUILDARCH=src;
fi

if [ ! -d "$BUILDARCH" ]; then mkdir "$BUILDARCH"; fi

sed -e "s/@BUILDARCH@/$BUILDARCH/" \
    -e "s/@TARGET@/$TARGET/" \
	Makefile.in > Makefile

(cd $BUILDARCH && ../src/configure $configoptions $mtoptions)

case $TARGET in
  world)
	;;
esac
