#! /bin/sh
#
# This configure script is *not* autoconf-based and has different semantics.
# It attempts to autodetect all settings and options where possible. It is
# possible to override autodetection with the --enable-option/--disable-option
# command line parameters.  --enable-option forces the option on skipping
# autodetection. Yes, this means that compilation may fail and yes, this is not
# how autoconf-based configure scripts behave.
#
# configure generates config.mak.autogen, then included in the Makefile.
#
# If you want to add a new check for $feature, add it at two places - to the
# variable list and to the checks section. You will find both below.
#
#############################################################################

[ -f ./config-lib.sh ] || {
	echo "config-lib.sh not found; please run ./configure from the source tree" >&2
	exit 1
}
. ./config-lib.sh



#############################################################################

# List variables for features and libraries here:

add_feature "_no_symlink_head" "no-symlink-head" "NO_SYMLINK_HEAD" "auto" \
"  --enable-no-symlink-head  Never have .git/HEAD as a symbolic link"

add_feature "_nsec" "nsec" "USE_NSEC" "no" \
"  --enable-nsec          Use sub-second resolution when checking mtimes"

add_library "_expat" "expat" " NO_EXPAT" "auto" \
"  --without-expat        Disable libexpat support (disables git-http-push)"


#############################################################################


process_params "$@"
test_setup
basic_tests


#############################################################################


echocheck "whether to prohibit usage of symlinked HEAD"
if test "$_no_symlink_head" = auto ; then
	if win32; then
		_no_symlink_head=yes
	else
		_no_symlink_head=no
	fi
fi
echores "$_no_symlink_head"


echocheck "for expat"
if test "$_expat" = auto ; then
	cat > $TMPC <<EOF
#include <expat.h>
int main(void) { return 0; }
EOF
	_expat=no
	cc_check -lexpat && _expat=yes
fi
echores "$_expat"


# Insert tests for features and libraries here.

#############################################################################


write_config
