head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.2
	netbsd-11-0-RC3:1.1.1.2
	netbsd-11-0-RC2:1.1.1.2
	netbsd-11-0-RC1:1.1.1.2
	perseant-exfatfs-base-20250801:1.1.1.2
	netbsd-11:1.1.1.2.0.30
	netbsd-11-base:1.1.1.2
	netbsd-10-1-RELEASE:1.1.1.2
	perseant-exfatfs-base-20240630:1.1.1.2
	perseant-exfatfs:1.1.1.2.0.28
	perseant-exfatfs-base:1.1.1.2
	netbsd-8-3-RELEASE:1.1.1.2
	netbsd-9-4-RELEASE:1.1.1.2
	netbsd-10-0-RELEASE:1.1.1.2
	netbsd-10-0-RC6:1.1.1.2
	netbsd-10-0-RC5:1.1.1.2
	netbsd-10-0-RC4:1.1.1.2
	netbsd-10-0-RC3:1.1.1.2
	netbsd-10-0-RC2:1.1.1.2
	netbsd-10-0-RC1:1.1.1.2
	netbsd-10:1.1.1.2.0.26
	netbsd-10-base:1.1.1.2
	netbsd-9-3-RELEASE:1.1.1.2
	cjep_sun2x-base1:1.1.1.2
	cjep_sun2x:1.1.1.2.0.24
	cjep_sun2x-base:1.1.1.2
	cjep_staticlib_x-base1:1.1.1.2
	netbsd-9-2-RELEASE:1.1.1.2
	cjep_staticlib_x:1.1.1.2.0.22
	cjep_staticlib_x-base:1.1.1.2
	netbsd-9-1-RELEASE:1.1.1.2
	phil-wifi-20200421:1.1.1.2
	phil-wifi-20200411:1.1.1.2
	is-mlppp:1.1.1.2.0.20
	is-mlppp-base:1.1.1.2
	phil-wifi-20200406:1.1.1.2
	netbsd-8-2-RELEASE:1.1.1.2
	netbsd-9-0-RELEASE:1.1.1.2
	netbsd-9-0-RC2:1.1.1.2
	netbsd-9-0-RC1:1.1.1.2
	phil-wifi-20191119:1.1.1.2
	netbsd-9:1.1.1.2.0.18
	netbsd-9-base:1.1.1.2
	phil-wifi-20190609:1.1.1.2
	netbsd-8-1-RELEASE:1.1.1.2
	netbsd-8-1-RC1:1.1.1.2
	pgoyette-compat-merge-20190127:1.1.1.2
	pgoyette-compat-20190127:1.1.1.2
	pgoyette-compat-20190118:1.1.1.2
	pgoyette-compat-1226:1.1.1.2
	pgoyette-compat-1126:1.1.1.2
	pgoyette-compat-1020:1.1.1.2
	pgoyette-compat-0930:1.1.1.2
	pgoyette-compat-0906:1.1.1.2
	netbsd-7-2-RELEASE:1.1.1.1
	pgoyette-compat-0728:1.1.1.2
	netbsd-8-0-RELEASE:1.1.1.2
	phil-wifi:1.1.1.2.0.16
	phil-wifi-base:1.1.1.2
	pgoyette-compat-0625:1.1.1.2
	netbsd-8-0-RC2:1.1.1.2
	pgoyette-compat-0521:1.1.1.2
	pgoyette-compat-0502:1.1.1.2
	pgoyette-compat-0422:1.1.1.2
	netbsd-8-0-RC1:1.1.1.2
	pgoyette-compat-0415:1.1.1.2
	pgoyette-compat-0407:1.1.1.2
	pgoyette-compat-0330:1.1.1.2
	pgoyette-compat-0322:1.1.1.2
	pgoyette-compat-0315:1.1.1.2
	netbsd-7-1-2-RELEASE:1.1.1.1
	pgoyette-compat:1.1.1.2.0.14
	pgoyette-compat-base:1.1.1.2
	netbsd-7-1-1-RELEASE:1.1.1.1
	matt-nb8-mediatek:1.1.1.2.0.12
	matt-nb8-mediatek-base:1.1.1.2
	perseant-stdc-iso10646:1.1.1.2.0.10
	perseant-stdc-iso10646-base:1.1.1.2
	netbsd-8:1.1.1.2.0.8
	netbsd-8-base:1.1.1.2
	prg-localcount2-base3:1.1.1.2
	prg-localcount2-base2:1.1.1.2
	prg-localcount2-base1:1.1.1.2
	prg-localcount2:1.1.1.2.0.6
	prg-localcount2-base:1.1.1.2
	pgoyette-localcount-20170426:1.1.1.2
	bouyer-socketcan-base1:1.1.1.2
	pgoyette-localcount-20170320:1.1.1.2
	netbsd-7-1:1.1.1.1.0.48
	netbsd-7-1-RELEASE:1.1.1.1
	netbsd-7-1-RC2:1.1.1.1
	netbsd-7-nhusb-base-20170116:1.1.1.1
	bouyer-socketcan:1.1.1.2.0.4
	bouyer-socketcan-base:1.1.1.2
	pgoyette-localcount-20170107:1.1.1.2
	netbsd-7-1-RC1:1.1.1.1
	pgoyette-localcount-20161104:1.1.1.2
	netbsd-7-0-2-RELEASE:1.1.1.1
	localcount-20160914:1.1.1.2
	netbsd-7-nhusb:1.1.1.1.0.46
	netbsd-7-nhusb-base:1.1.1.1
	pgoyette-localcount-20160806:1.1.1.2
	pgoyette-localcount-20160726:1.1.1.2
	pgoyette-localcount:1.1.1.2.0.2
	pgoyette-localcount-base:1.1.1.2
	netbsd-7-0-1-RELEASE:1.1.1.1
	netbsd-7-0:1.1.1.1.0.44
	netbsd-7-0-RELEASE:1.1.1.1
	netbsd-7-0-RC3:1.1.1.1
	netbsd-7-0-RC2:1.1.1.1
	netbsd-7-0-RC1:1.1.1.1
	am-utils-6-2-20140117:1.1.1.2
	netbsd-5-2-3-RELEASE:1.1.1.1
	netbsd-5-1-5-RELEASE:1.1.1.1
	netbsd-6-0-6-RELEASE:1.1.1.1
	netbsd-6-1-5-RELEASE:1.1.1.1
	netbsd-7:1.1.1.1.0.42
	netbsd-7-base:1.1.1.1
	yamt-pagecache-base9:1.1.1.1
	yamt-pagecache-tag8:1.1.1.1
	netbsd-6-1-4-RELEASE:1.1.1.1
	netbsd-6-0-5-RELEASE:1.1.1.1
	tls-earlyentropy:1.1.1.1.0.40
	tls-earlyentropy-base:1.1.1.1
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.1
	riastradh-drm2-base3:1.1.1.1
	netbsd-6-1-3-RELEASE:1.1.1.1
	netbsd-6-0-4-RELEASE:1.1.1.1
	netbsd-5-2-2-RELEASE:1.1.1.1
	netbsd-5-1-4-RELEASE:1.1.1.1
	netbsd-6-1-2-RELEASE:1.1.1.1
	netbsd-6-0-3-RELEASE:1.1.1.1
	netbsd-5-2-1-RELEASE:1.1.1.1
	netbsd-5-1-3-RELEASE:1.1.1.1
	netbsd-6-1-1-RELEASE:1.1.1.1
	riastradh-drm2-base2:1.1.1.1
	riastradh-drm2-base1:1.1.1.1
	riastradh-drm2:1.1.1.1.0.32
	riastradh-drm2-base:1.1.1.1
	netbsd-6-1:1.1.1.1.0.38
	netbsd-6-0-2-RELEASE:1.1.1.1
	netbsd-6-1-RELEASE:1.1.1.1
	khorben-n900:1.1.1.1.0.36
	netbsd-6-1-RC4:1.1.1.1
	netbsd-6-1-RC3:1.1.1.1
	agc-symver:1.1.1.1.0.34
	agc-symver-base:1.1.1.1
	netbsd-6-1-RC2:1.1.1.1
	netbsd-6-1-RC1:1.1.1.1
	yamt-pagecache-base8:1.1.1.1
	netbsd-5-2:1.1.1.1.0.30
	netbsd-6-0-1-RELEASE:1.1.1.1
	yamt-pagecache-base7:1.1.1.1
	netbsd-5-2-RELEASE:1.1.1.1
	netbsd-5-2-RC1:1.1.1.1
	matt-nb6-plus-nbase:1.1.1.1
	yamt-pagecache-base6:1.1.1.1
	netbsd-6-0:1.1.1.1.0.28
	netbsd-6-0-RELEASE:1.1.1.1
	netbsd-6-0-RC2:1.1.1.1
	tls-maxphys:1.1.1.1.0.26
	tls-maxphys-base:1.1.1.1
	matt-nb6-plus:1.1.1.1.0.24
	matt-nb6-plus-base:1.1.1.1
	netbsd-6-0-RC1:1.1.1.1
	yamt-pagecache-base5:1.1.1.1
	yamt-pagecache-base4:1.1.1.1
	netbsd-6:1.1.1.1.0.22
	netbsd-6-base:1.1.1.1
	netbsd-5-1-2-RELEASE:1.1.1.1
	netbsd-5-1-1-RELEASE:1.1.1.1
	yamt-pagecache-base3:1.1.1.1
	yamt-pagecache-base2:1.1.1.1
	yamt-pagecache:1.1.1.1.0.2
	yamt-pagecache-base:1.1.1.1
	cherry-xenmp:1.1.1.1.0.20
	cherry-xenmp-base:1.1.1.1
	bouyer-quota2-nbase:1.1.1.1
	bouyer-quota2:1.1.1.1.0.18
	bouyer-quota2-base:1.1.1.1
	matt-mips64-premerge-20101231:1.1.1.1
	matt-nb5-mips64-premerge-20101231:1.1.1.1
	matt-nb5-pq3:1.1.1.1.0.16
	matt-nb5-pq3-base:1.1.1.1
	netbsd-5-1:1.1.1.1.0.14
	netbsd-5-1-RELEASE:1.1.1.1
	netbsd-5-1-RC4:1.1.1.1
	matt-nb5-mips64-k15:1.1.1.1
	netbsd-5-1-RC3:1.1.1.1
	netbsd-5-1-RC2:1.1.1.1
	netbsd-5-1-RC1:1.1.1.1
	netbsd-5-0-2-RELEASE:1.1.1.1
	matt-nb5-mips64-premerge-20091211:1.1.1.1
	matt-premerge-20091211:1.1.1.1
	matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.1.1.1
	matt-nb4-mips64-k7-u2a-k9b:1.1.1.1
	matt-nb5-mips64-u1-k1-k5:1.1.1.1
	matt-nb5-mips64:1.1.1.1.0.12
	netbsd-5-0-1-RELEASE:1.1.1.1
	jym-xensuspend-nbase:1.1.1.1
	netbsd-5-0:1.1.1.1.0.10
	netbsd-5-0-RELEASE:1.1.1.1
	netbsd-5-0-RC4:1.1.1.1
	am-utils-6-2a3-20090320:1.1.1.1
	netbsd-5-0-RC3:1.1.1.1
	netbsd-5-0-RC2:1.1.1.1
	jym-xensuspend:1.1.1.1.0.8
	jym-xensuspend-base:1.1.1.1
	netbsd-5-0-RC1:1.1.1.1
	haad-dm-base:1.1.1.1
	haad-dm-base2:1.1.1.1
	haad-nbase2:1.1.1.1
	netbsd-5:1.1.1.1.0.6
	netbsd-5-base:1.1.1.1
	matt-mips64-base2:1.1.1.1
	haad-dm:1.1.1.1.0.4
	haad-dm-base1:1.1.1.1
	am-utils-6-2a3-20080919:1.1.1.1
	ezk:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2008.09.19.20.07.14;	author christos;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2008.09.19.20.07.14;	author christos;	state Exp;
branches
	1.1.1.1.4.1;
next	1.1.1.2;

1.1.1.2
date	2015.01.17.16.34.14;	author christos;	state Exp;
branches;
next	;
commitid	B6NBxRQfTZgTFo6y;

1.1.1.1.4.1
date	2008.09.19.20.07.14;	author haad;	state dead;
branches;
next	1.1.1.1.4.2;

1.1.1.1.4.2
date	2008.10.19.22.39.29;	author haad;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#!/bin/sh
# Build all of the am-utils package in a directory A.<cpu-company-system>
# Used by am-utils users.
# Erez Zadok <ezk AT am-utils.org>
#
# run "buildall -h" to get usage
#
#set -x

##############################################################################
# first test if we are in the right directory to run this script
# change to the right directory
test -f ../config.guess && cd ..
test -f ../../config.guess && cd ../..
pwd=`pwd`
host_alias=`(cd /tmp; $pwd/config.guess.long)`
if test -z "$host_alias" ; then
	echo "$0: must run from the source or the A. directory."
	echo "$0: cannot find $pwd/config.guess"
	exit 1
else
	:
fi

##############################################################################
# pattern of lines to remove from config.cache (for developers only)
# Example: if you change TRY_COMPILE_NFS, redo these:
#pat='fhandle|nfs_fh|nfs_args|struct_nfs|opt'
#pat='style_|mount_trap|mtype|transport|dref'
#pat='mntent|mnttab'
#pat='nfs_args|fh_len|irix|proto|vers'
#pat='3|proto|tcp|ver|nfs_prot|mtype'
#pat='trap|style|mtype|transport|os_libs|restartable|unmount_args|yp_order'
#pat='yp_all|nsl|nis'

##############################################################################
# initialize variables (build command, config command, variables)
bld_cmd=""
bld_flags=""
cnf_cmd=""
cnf_flags="-C"			# use config.cache cache file
inst_cmd=""
inst_flags=""
mkcnf_cmd=""
vars=""
expvars=""
default=yes

##############################################################################
# check if CFLAGS or AM_CFLAGS was passed
test -z "$CFLAGS" || vars="$vars CFLAGS=\"${CFLAGS}\""
test -z "$CFLAGS" || expvars="$expvars CFLAGS"
test -z "$AM_CFLAGS" || vars="$vars AM_CFLAGS=\"${AM_CFLAGS}\""

##############################################################################
# functions

add_gcc_flags1 () {
    case "${CC}" in
	cc | */cc )
		# do nothing
		;;
	    * )
		vars="$vars AM_CFLAGS=\"-Werror\""
		AM_CFLAGS="-Werror"
		expvars="$expvars AM_CFLAGS"
		;;
    esac
}

add_gcc_flags2 () {
    case "${CC}" in
	cc | */cc )
		# do nothing
		;;
	    * )
		vars="$vars AM_CFLAGS=\"-Wall -Werror\""
		AM_CFLAGS="-Wall -Werror"
		expvars="$expvars AM_CFLAGS"
		;;
    esac
}

add_shared_flags () {
    cnf_cmd="$cnf_cmd --enable-shared --disable-static"
}

add_prefix_flags () {
    cnf_cmd="$cnf_cmd --prefix=/usr/local/AMD"
}

##############################################################################
# iterate over all options, and set the command to run with any variables
while [ $# != 0 ]; do
case "$1" in
    -b )
	# look for GNU make if possible
	gmake --version -f /dev/null > /dev/null 2>&1
	if [ $? = 0 ]
	then
	    bld_cmd="${MAKE:-gmake}"
	else
	    bld_cmd="${MAKE:-make}"
	fi
	default=no
	shift
    ;;

    -i )
	# look for GNU make if possible
	gmake --version -f /dev/null > /dev/null 2>&1
	if [ $? = 0 ]
	then
	    inst_cmd="${MAKE:-gmake} install"
	else
	    inst_cmd="${MAKE:-make} install"
	fi
	default=no
	shift
    ;;

    -c )
	cnf_cmd="../configure --enable-debug=yes"
#	add_gcc_flags1
	default=no
	shift
    ;;

    -cs )
	cnf_cmd="../configure --enable-debug=yes"
	add_shared_flags
#	add_gcc_flags1
	default=no
	shift
    ;;

    -C )
	cnf_cmd="../configure --enable-debug=yes"
	add_gcc_flags2
	default=no
	shift
    ;;

    -Cs )
	cnf_cmd="../configure --enable-debug=yes"
	add_shared_flags
	add_gcc_flags2
	default=no
	shift
    ;;

    -d )
	cnf_cmd="../configure --enable-debug=yes"
	add_prefix_flags
#	add_gcc_flags1
	default=no
	shift
    ;;

    -ds )
	cnf_cmd="../configure --enable-debug=yes"
	add_prefix_flags
	add_shared_flags
#	add_gcc_flags1
	default=no
	shift
    ;;

    -D )
	cnf_cmd="../configure --enable-debug=yes"
	add_prefix_flags
	add_gcc_flags2
	default=no
	shift
    ;;

    -Ds )
	cnf_cmd="../configure -enable-debug=yes"
#	cnf_cmd="../configure -enable-debug=mem"
#  	cnf_cmd="../configure --prefix=/usr/local/AMD --enable-debug=yes --enable-shared --disable-static \
#  	    --enable-cppflags=\"-I${HOME}/ldap/include -I${HOME}/hesiod/include\" \
#  	    --enable-ldflags=\"-L${HOME}/ldap/lib -L${HOME}/hesiod/lib\""
#	cnf_cmd="$cnf_cmd \
#  	    --enable-cppflags=-I${HOME}/ldap/include \
#  	    --enable-ldflags=-L${HOME}/ldap/lib"
#	cnf_cmd="../configure -enable-debug=yes --enable-cppflags=-I/usr/local/include --enable-ldflags=-L/usr/local/lib"
	add_prefix_flags
	add_shared_flags
	add_gcc_flags2
	default=no
	shift
    ;;

    -K )
#	mkcnf_cmd="../m4/mkconf"
	mkcnf_cmd="../bootstrap"
	if test -f bootstrap ; then
	    :
	else
	    echo "am-utils maintainer option only!"
	    exit 1
	fi
	default=no
	shift
    ;;

    -q )
	cnf_cmd="./config.status"
	default=no
	shift
    ;;

    -- )
	shift
	cmdline_cnf_flags="$*"
	break	# from while loop
    ;;

    -h | * )
cat <<EOF
Usage: buildall [-b] [-[cCdD][s]] [-K] [-q] [-h] [-- configopts]
     -b: build only
     -c:  configure (debugging)
     -cs: configure (debugging, shared libs)
     -C:  configure (strict compile, debugging)
     -Cs: configure (strict compile, debugging, shared libs)
     -d:  configure in /usr/local/AMD (debugging)
     -ds: configure in /usr/local/AMD (debugging, shared libs)
     -D:  configure in /usr/local/AMD (strict compile, debugging)
     -Ds: configure in /usr/local/AMD (strict compile, debugging, shared libs)
     -K: run mkconf to update *.in files (developers only)
     -i: build and install
     -q: quick configure only (run config.status)
     -h: print usage
     configopts: options to pass to configure (must be last and after a --)
You may pass variables: CFLAGS for build, MAKE for your make program
and AM_CFLAGS for additional build flags.
EOF
    exit 1
    ;;

esac
done

# if AM_CFLAGS was set before, then add it to the configure option
if test -n "${AM_CFLAGS}"; then
    extra_cnf_flags="--enable-am-cflags=${AM_CFLAGS}"
else
    :
fi

# check if no options were given, and set to defaults
if test "$default" = "yes"; then
    # look for GNU make if possible
    gmake --version -f /dev/null > /dev/null 2>&1
    if [ $? = 0 ]
    then
	bld_cmd="${MAKE:-gmake}"
    else
	bld_cmd="${MAKE:-make}"
    fi
    cnf_cmd="../configure"
else
    :
fi

##############################################################################
# make build directory if needed
if test -d ./A.${host_alias} ; then
    :
else
    mkdir ./A.${host_alias}
fi
echo "Configuring/building am-utils in directory ./A.${host_alias} ..."
echo cd ./A.${host_alias}
cd ./A.${host_alias} || exit 1

##############################################################################
# this is for developers only (remove config.cache entries)
if test -n "$pat"; then
    if test -f config.cache; then
	egrep $pat config.cache | while read i; do echo '	'$i;done
	egrep -v $pat config.cache > tmp.$$ && \
		mv config.cache config.cache.old && mv tmp.$$ config.cache
    else
	:
    fi
else
    :
fi

##############################################################################
# Some system's /bin/sh has limits/bugs which prevent it from being used
# with configure
case "${host_alias}" in
    *hpux9* | *aix5.1* )
	if test -n "$cnf_cmd"; then
	    if test -f /bin/bash; then
		cnf_cmd="/bin/bash $cnf_cmd"
	    elif test -f /bin/ksh; then
		cnf_cmd="/bin/ksh $cnf_cmd"
	    fi
	else
	    :
	fi
	echo "WARNING: do not use /bin/make under this system."
	echo "Instead, use GNU make or 'ksh ./configure' directly."
	;;
    mips-sgi-irix5.2)
	echo "WARNING: do not use /bin/make under this system."
	echo "Instead, use GNU make or ./configure directly."
	;;
esac

##############################################################################
# see if need to run mkconf
if test -n "$mkcnf_cmd"; then
    echo $mkcnf_cmd
    $mkcnf_cmd || exit 1
else
    :
fi

##############################################################################
# see if need to [re]configure
if test -n "$cnf_cmd"; then
    if test -n "$vars"; then
	echo $vars
	eval $vars
	echo export $expvars
	export $expvars
    else
	:
    fi
    if test -z "${cnf_flags}${extra_cnf_flags}"; then
	echo $cnf_cmd $cmdline_cnf_flags
	$cnf_cmd $cmdline_cnf_flags || exit 1
    else
	echo $cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags
	$cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags || exit 1
    fi
else
    :
fi

##############################################################################
# if need to [re]build
if test -n "$bld_cmd"; then
    echo $bld_cmd $bld_flags
    $bld_cmd $bld_flags || exit 1
else
    :
fi

##############################################################################
# if need to install
if test -n "$inst_cmd"; then
    echo $inst_cmd $inst_flags
    $inst_cmd $inst_flags || exit 1
else
    :
fi

##############################################################################
@


1.1.1.1
log
@import current am-utils.
@
text
@@


1.1.1.2
log
@Import am-utils 6.2-20140117
@
text
@d15 2
a16 2
pwd=$(pwd)
host_alias=$(cd /tmp; $pwd/config.guess.long)
d247 1
a247 1
    extra_cnf_flags="--enable-am-cflags=\"${AM_CFLAGS}\""
d337 1
a337 1
	eval $cnf_cmd $cmdline_cnf_flags || exit 1
d339 2
a340 2
	echo $cnf_cmd $cnf_flags $extra_cnf_flags $cmdline_cnf_flags
	eval $cnf_cmd $cnf_flags $extra_cnf_flags $cmdline_cnf_flags || exit 1
@


1.1.1.1.4.1
log
@file buildall was added on branch haad-dm on 2008-10-19 22:39:29 +0000
@
text
@d1 364
@


1.1.1.1.4.2
log
@Sync with HEAD.
@
text
@a0 364
#!/bin/sh
# Build all of the am-utils package in a directory A.<cpu-company-system>
# Used by am-utils users.
# Erez Zadok <ezk AT am-utils.org>
#
# run "buildall -h" to get usage
#
#set -x

##############################################################################
# first test if we are in the right directory to run this script
# change to the right directory
test -f ../config.guess && cd ..
test -f ../../config.guess && cd ../..
pwd=`pwd`
host_alias=`(cd /tmp; $pwd/config.guess.long)`
if test -z "$host_alias" ; then
	echo "$0: must run from the source or the A. directory."
	echo "$0: cannot find $pwd/config.guess"
	exit 1
else
	:
fi

##############################################################################
# pattern of lines to remove from config.cache (for developers only)
# Example: if you change TRY_COMPILE_NFS, redo these:
#pat='fhandle|nfs_fh|nfs_args|struct_nfs|opt'
#pat='style_|mount_trap|mtype|transport|dref'
#pat='mntent|mnttab'
#pat='nfs_args|fh_len|irix|proto|vers'
#pat='3|proto|tcp|ver|nfs_prot|mtype'
#pat='trap|style|mtype|transport|os_libs|restartable|unmount_args|yp_order'
#pat='yp_all|nsl|nis'

##############################################################################
# initialize variables (build command, config command, variables)
bld_cmd=""
bld_flags=""
cnf_cmd=""
cnf_flags="-C"			# use config.cache cache file
inst_cmd=""
inst_flags=""
mkcnf_cmd=""
vars=""
expvars=""
default=yes

##############################################################################
# check if CFLAGS or AM_CFLAGS was passed
test -z "$CFLAGS" || vars="$vars CFLAGS=\"${CFLAGS}\""
test -z "$CFLAGS" || expvars="$expvars CFLAGS"
test -z "$AM_CFLAGS" || vars="$vars AM_CFLAGS=\"${AM_CFLAGS}\""

##############################################################################
# functions

add_gcc_flags1 () {
    case "${CC}" in
	cc | */cc )
		# do nothing
		;;
	    * )
		vars="$vars AM_CFLAGS=\"-Werror\""
		AM_CFLAGS="-Werror"
		expvars="$expvars AM_CFLAGS"
		;;
    esac
}

add_gcc_flags2 () {
    case "${CC}" in
	cc | */cc )
		# do nothing
		;;
	    * )
		vars="$vars AM_CFLAGS=\"-Wall -Werror\""
		AM_CFLAGS="-Wall -Werror"
		expvars="$expvars AM_CFLAGS"
		;;
    esac
}

add_shared_flags () {
    cnf_cmd="$cnf_cmd --enable-shared --disable-static"
}

add_prefix_flags () {
    cnf_cmd="$cnf_cmd --prefix=/usr/local/AMD"
}

##############################################################################
# iterate over all options, and set the command to run with any variables
while [ $# != 0 ]; do
case "$1" in
    -b )
	# look for GNU make if possible
	gmake --version -f /dev/null > /dev/null 2>&1
	if [ $? = 0 ]
	then
	    bld_cmd="${MAKE:-gmake}"
	else
	    bld_cmd="${MAKE:-make}"
	fi
	default=no
	shift
    ;;

    -i )
	# look for GNU make if possible
	gmake --version -f /dev/null > /dev/null 2>&1
	if [ $? = 0 ]
	then
	    inst_cmd="${MAKE:-gmake} install"
	else
	    inst_cmd="${MAKE:-make} install"
	fi
	default=no
	shift
    ;;

    -c )
	cnf_cmd="../configure --enable-debug=yes"
#	add_gcc_flags1
	default=no
	shift
    ;;

    -cs )
	cnf_cmd="../configure --enable-debug=yes"
	add_shared_flags
#	add_gcc_flags1
	default=no
	shift
    ;;

    -C )
	cnf_cmd="../configure --enable-debug=yes"
	add_gcc_flags2
	default=no
	shift
    ;;

    -Cs )
	cnf_cmd="../configure --enable-debug=yes"
	add_shared_flags
	add_gcc_flags2
	default=no
	shift
    ;;

    -d )
	cnf_cmd="../configure --enable-debug=yes"
	add_prefix_flags
#	add_gcc_flags1
	default=no
	shift
    ;;

    -ds )
	cnf_cmd="../configure --enable-debug=yes"
	add_prefix_flags
	add_shared_flags
#	add_gcc_flags1
	default=no
	shift
    ;;

    -D )
	cnf_cmd="../configure --enable-debug=yes"
	add_prefix_flags
	add_gcc_flags2
	default=no
	shift
    ;;

    -Ds )
	cnf_cmd="../configure -enable-debug=yes"
#	cnf_cmd="../configure -enable-debug=mem"
#  	cnf_cmd="../configure --prefix=/usr/local/AMD --enable-debug=yes --enable-shared --disable-static \
#  	    --enable-cppflags=\"-I${HOME}/ldap/include -I${HOME}/hesiod/include\" \
#  	    --enable-ldflags=\"-L${HOME}/ldap/lib -L${HOME}/hesiod/lib\""
#	cnf_cmd="$cnf_cmd \
#  	    --enable-cppflags=-I${HOME}/ldap/include \
#  	    --enable-ldflags=-L${HOME}/ldap/lib"
#	cnf_cmd="../configure -enable-debug=yes --enable-cppflags=-I/usr/local/include --enable-ldflags=-L/usr/local/lib"
	add_prefix_flags
	add_shared_flags
	add_gcc_flags2
	default=no
	shift
    ;;

    -K )
#	mkcnf_cmd="../m4/mkconf"
	mkcnf_cmd="../bootstrap"
	if test -f bootstrap ; then
	    :
	else
	    echo "am-utils maintainer option only!"
	    exit 1
	fi
	default=no
	shift
    ;;

    -q )
	cnf_cmd="./config.status"
	default=no
	shift
    ;;

    -- )
	shift
	cmdline_cnf_flags="$*"
	break	# from while loop
    ;;

    -h | * )
cat <<EOF
Usage: buildall [-b] [-[cCdD][s]] [-K] [-q] [-h] [-- configopts]
     -b: build only
     -c:  configure (debugging)
     -cs: configure (debugging, shared libs)
     -C:  configure (strict compile, debugging)
     -Cs: configure (strict compile, debugging, shared libs)
     -d:  configure in /usr/local/AMD (debugging)
     -ds: configure in /usr/local/AMD (debugging, shared libs)
     -D:  configure in /usr/local/AMD (strict compile, debugging)
     -Ds: configure in /usr/local/AMD (strict compile, debugging, shared libs)
     -K: run mkconf to update *.in files (developers only)
     -i: build and install
     -q: quick configure only (run config.status)
     -h: print usage
     configopts: options to pass to configure (must be last and after a --)
You may pass variables: CFLAGS for build, MAKE for your make program
and AM_CFLAGS for additional build flags.
EOF
    exit 1
    ;;

esac
done

# if AM_CFLAGS was set before, then add it to the configure option
if test -n "${AM_CFLAGS}"; then
    extra_cnf_flags="--enable-am-cflags=${AM_CFLAGS}"
else
    :
fi

# check if no options were given, and set to defaults
if test "$default" = "yes"; then
    # look for GNU make if possible
    gmake --version -f /dev/null > /dev/null 2>&1
    if [ $? = 0 ]
    then
	bld_cmd="${MAKE:-gmake}"
    else
	bld_cmd="${MAKE:-make}"
    fi
    cnf_cmd="../configure"
else
    :
fi

##############################################################################
# make build directory if needed
if test -d ./A.${host_alias} ; then
    :
else
    mkdir ./A.${host_alias}
fi
echo "Configuring/building am-utils in directory ./A.${host_alias} ..."
echo cd ./A.${host_alias}
cd ./A.${host_alias} || exit 1

##############################################################################
# this is for developers only (remove config.cache entries)
if test -n "$pat"; then
    if test -f config.cache; then
	egrep $pat config.cache | while read i; do echo '	'$i;done
	egrep -v $pat config.cache > tmp.$$ && \
		mv config.cache config.cache.old && mv tmp.$$ config.cache
    else
	:
    fi
else
    :
fi

##############################################################################
# Some system's /bin/sh has limits/bugs which prevent it from being used
# with configure
case "${host_alias}" in
    *hpux9* | *aix5.1* )
	if test -n "$cnf_cmd"; then
	    if test -f /bin/bash; then
		cnf_cmd="/bin/bash $cnf_cmd"
	    elif test -f /bin/ksh; then
		cnf_cmd="/bin/ksh $cnf_cmd"
	    fi
	else
	    :
	fi
	echo "WARNING: do not use /bin/make under this system."
	echo "Instead, use GNU make or 'ksh ./configure' directly."
	;;
    mips-sgi-irix5.2)
	echo "WARNING: do not use /bin/make under this system."
	echo "Instead, use GNU make or ./configure directly."
	;;
esac

##############################################################################
# see if need to run mkconf
if test -n "$mkcnf_cmd"; then
    echo $mkcnf_cmd
    $mkcnf_cmd || exit 1
else
    :
fi

##############################################################################
# see if need to [re]configure
if test -n "$cnf_cmd"; then
    if test -n "$vars"; then
	echo $vars
	eval $vars
	echo export $expvars
	export $expvars
    else
	:
    fi
    if test -z "${cnf_flags}${extra_cnf_flags}"; then
	echo $cnf_cmd $cmdline_cnf_flags
	$cnf_cmd $cmdline_cnf_flags || exit 1
    else
	echo $cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags
	$cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags || exit 1
    fi
else
    :
fi

##############################################################################
# if need to [re]build
if test -n "$bld_cmd"; then
    echo $bld_cmd $bld_flags
    $bld_cmd $bld_flags || exit 1
else
    :
fi

##############################################################################
# if need to install
if test -n "$inst_cmd"; then
    echo $inst_cmd $inst_flags
    $inst_cmd $inst_flags || exit 1
else
    :
fi

##############################################################################
@
