dnl
dnl $Id: configure.in,v 1.9.6.1 1997/11/07 02:08:40 colin Exp $
dnl
dnl This file in input to autoconf.  It consists of a series of m4
dnl macros which expand to produce the shell script "configure".
dnl Anything which is not an m4 macro is copied directly to the output.
dnl
dnl Start things up.  If the specified file doesn't exist, configure
dnl will complain.

AC_INIT(pub/test/pgpTest.h)

dnl The following tests need to know that we intend to produce a config.h
dnl file, even though this won't expand to any shell script code until
dnl AC_OUTPUT time.
AC_CONFIG_HEADER(unix/pgpConfig.h)

dnl The following directory is where we will find the ancillary scripts,
dnl like install-sh, config.sub, and config.guess.
AC_CONFIG_AUX_DIR(unix/config)

dnl Platform configuration
AC_CANONICAL_HOST
# Export the host CPU to Makefiles for assembly-language use
HOST_CPU=$host_cpu
AC_SUBST(HOST_CPU)

dnl Checks for programs.
# Find a compiler to use.
# Check 1) The $CC environment varaible, 2) gcc, 3) acc, and 4) cc.
dnl This used to be just AC-CHECK-PROGS(CC, gcc acc, cc), but...
# This deals with brain-damaged Sun systems that place a bogus cc or
# acc executable in the $PATH, which just prints an error and exit.
# We deal with this by actually trying to compile a trivial test program.
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
  AC_MSG_CHECKING(For C compiler (cached))
  CC="$ac_cv_prog_CC"
  AC_MSG_RESULT($CC)
elif test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
  AC_MSG_CHECKING(For C compiler)
  AC_MSG_RESULT($CC)
else
  IFS="${IFS=	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  echo 'main(){return 0;}' > conftest.$ac_ext
  for ac_prog in gcc acc cc; do
# Extract the first word of "$ac_prog", so it can be a program name with args.
    set dummy $ac_prog; ac_word=$2
    AC_MSG_CHECKING(for $ac_word)
    for ac_dir in $PATH; do
      test -z "$ac_dir" && ac_dir=.
      if test -r "$ac_dir/$ac_word"; then
        CC="$ac_prog"
        if eval $ac_compile; then
          ac_cv_prog_CC="$ac_prog"
        fi
        break
      fi
    done
    CC="$ac_cv_prog_CC"
    if test -n "$CC"; then
      AC_MSG_RESULT($ac_dir/$CC)
      break;
    fi
    AC_MSG_RESULT(no)
  done
  if test ! -n "$CC"; then
    AC_MSG_ERROR(no C compiler found)
  fi
  IFS="$ac_save_ifs"
  rm -f conftest*
fi
AC_SUBST(CC)

AC_CACHE_CHECK(whether we are using GNU CC, ac_cv_prog_gcc,
[dnl The semicolon is to pacify NeXT's syntax-checking cpp.
cat > conftest.c <<EOF
#ifdef __GNUC__
  yes;
#endif
EOF
if ${CC-cc} -E conftest.c 2>&AC_FD_CC | egrep yes >/dev/null 2>&1; then
  ac_cv_prog_gcc=yes
else
  ac_cv_prog_gcc=no
fi])

if test $ac_cv_prog_gcc = yes; then
  if test "${CFLAGS+set}" != set; then
AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_gcc_g,
[echo 'void f(){}' > conftest.c
if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
  ac_cv_prog_gcc_g=yes
else
  ac_cv_prog_gcc_g=no
fi
rm -f conftest*
])
  fi
fi

# Now, figure out what CFLAGS we want.  If the user didn't ask specifically,
# we're going to use some ideas of our own.
if test "${CFLAGS+set}" != set; then

# Prefer optimizing, with debugging a second
if test $ac_cv_prog_gcc$ac_cv_prog_gcc_g = yesyes; then
  CFLAGS="-O -g"
else
  CFLAGS=-O
fi

dnl This ugly hack is to get warnings enabled where possible.
AC_MSG_CHECKING(for useful warning options (\$WARN))
# This currently only deals with gcc and SunPro CC.
if test "${WARN+set}" != set; then
  if test $ac_cv_prog_gcc = yes; then
    WARN="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
-Wwrite-strings"
  elif $CC -flags 2>&1 | grep SunSoft >/dev/null 2>&1 ||
	$CC -flags 2>&1 | grep SunPro >/dev/null 2>&1; then
    if $CC -flags 2>&1 | grep 'checking' | grep '^-vc' > /dev/null 2>&1; then
      WARN=-vc
    elif $CC -flags 2>&1 | grep 'checking' | grep '^-v ' > /dev/null 2>&1; then
      WARN=-v
    fi
    if $CC -flags 2>&1 | grep '^-xstrconst' > /dev/null 2>&1; then
      WARN="${WARN}${WARN+ }-xstrconst"
    fi
  fi
  # Any other compiler's warning flags?
fi
AC_MSG_RESULT(${WARN-none})
AC_SUBST(WARN)

AC_MSG_CHECKING(for useful tuning options (\$TUNE))
if test "${TUNE+set}" != set; then
  if test $ac_cv_prog_gcc = yes; then
    TUNE="-O6 -fomit-frame-pointer"
    case "$host_cpu" in
    i486)
      TUNE="$TUNE -m486"
      ;;
    i586 | i686)
      TUNE="$TUNE -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2"
      ;;
    sparc)
      # Try to use the architecture-detecting tool with SunPro CC.
      if bn_tune=`(fpversion -foption) 2>/dev/null`; then
	if test "$bn_tune" = xcg92 || test "$bn_tune" = cg92; then
	  TUNE="$TUNE -mv8"
	elif test "$bn_tune" != xcg89 && test "$bn_tune" != cg89; then
	  TUNE="$TUNE -mv8"
	  bn_tune_guess=yes
	fi
      else
	TUNE="$TUNE -mv8"
	bn_tune_guess=yes
      fi
      ;;
    esac
  elif $CC -flags 2>&1 | grep SunSoft >/dev/null 2>&1; then
    # SunPro C compiler - now grok version and platform
    if $CC -flags 2>&1 | grep '^-xO.*5' >/dev/null 2>&1; then
      TUNE=-xO5
    else
      TUNE=-xO4
    fi
    # Architecture: -native if avail., else as fpversion says, else guess -mv8
    if $CC -flags 2>&1 | grep '^-native' >/dev/null 2>&1; then
      TUNE="$TUNE -native"
    elif bn_tune=`(fpversion -foption) 2>/dev/null`; then
      TUNE="$TUNE -$bn_tune"
    elif $CC -flags 2>&1 | grep '^-xcg92' >/dev/null 2>&1; then
      TUNE="$TUNE -xcg92"
      bn_tune_guess=yes
    fi
  fi
fi
bn_tune_set=${TUNE+set}
# If nothing better is available, turn on -O
: ${TUNE=-O}
AC_MSG_RESULT(${TUNE-none})
if test "$bn_tune_set" != set; then
  AC_MSG_WARN(not optimizing heavily - try setting \$CFLAGS)
elif test "$bn_tune_guess" = yes; then
  AC_MSG_WARN([architecture guessed.  If incorrect, use explicit \$TUNE.])
fi
AC_SUBST(TUNE)

fi
# ^^ end of CFLAGS inference section

AC_REQUIRE_CPP
# Finally, figure out the command to generate dependencies.
AC_CACHE_CHECK(how to make dependencies, ac_cv_prog_DEPEND,
[if test -n "$DEPEND"; then
  ac_cv_prog_DEPEND="$DEPEND"
else
  IFS="${IFS=	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  echo '#include "confdefs.h"' > conftest.c
  for ac_prog in "$CPP -M" "$CC -xM" "$CC -M"; do
    echo $ac_prog $CPPFLAGS conftest.c 1>&AC_FD_CC;
    if $ac_prog $CPPFLAGS conftest.c 2>&AC_FD_CC \
                    | egrep "conftest\.o" >/dev/null 2>&1; then
      ac_cv_prog_DEPEND="$ac_prog $CPPFLAGS"
      break
    fi
  done
  if test ! -n "$ac_cv_prog_DEPEND"; then
    ac_cv_prog_DEPEND=:
  fi
  IFS="$ac_save_ifs"
  rm -f conftest*
fi])
DEPEND="$ac_cv_prog_DEPEND"
AC_SUBST(DEPEND)

# Find a BSD-compatibile install program, with install-sh as a fallback.
AC_PROG_INSTALL

# Find "ranlib".  Sone systems don't have or need ranlib.  If so,
# ":" (do nothing) is used instead.
AC_PROG_RANLIB

# Use symlinks (ln -s) if possible.  If not, use hard links (ln).
AC_PROG_LN_S

# Figure out how to test for symlinks...  Check 'test -L' and then 'test -h'
AC_CACHE_CHECK(how to test for symlinks, ac_cv_prog_TEST_L,
[rm -f conftest
$ac_cv_prog_LN_S foo conftest
IFS="${IFS=	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
if ( test -L conftest ); then
  ac_cv_prog_TEST_L="test -L"
elif ( test -h conftest ); then
  ac_cv_prog_TEST_L="test -h"
else
  ac_cv_prog_TEST_L="test ! -f"
fi
IFS="$ac_save_ifs"
rm -f conftest*])
TEST_L="$ac_cv_prog_TEST_L"
AC_SUBST(TEST_L)

dnl Checks for libraries.
dnl (we don't have any)

dnl Checks for library functions.
dnl (we don't have any)

# The big bang!  Produce the output files.  This is config.cache, and
# config.status, which builds the config.h file and a long list of
# Makefiles.
dnl The value specified to AC_CONFIG_HEADER at the top if the file is
dnl used here.
PGP_AC_OUTPUT(
	Makefile
	priv/Makefile
	priv/clientlib/Makefile
	priv/crypto/Makefile
	priv/crypto/bignum/Makefile
	priv/crypto/cipher/Makefile
	priv/crypto/compress/Makefile
	priv/crypto/hash/Makefile
	priv/crypto/pipe/Makefile
	priv/crypto/pipe/crypt/Makefile
	priv/crypto/pipe/file/Makefile
	priv/crypto/pipe/parser/Makefile
	priv/crypto/pipe/sig/Makefile
	priv/crypto/pipe/text/Makefile
	priv/crypto/pipe/utils/Makefile
	priv/crypto/random/Makefile
	priv/debug/Makefile
	priv/encrypt/Makefile
	priv/regexp/Makefile
	priv/include/Makefile
	priv/keys/Makefile
	priv/keys/keydb/Makefile
	priv/keys/keys/Makefile
	priv/keys/pubkey/Makefile
	priv/ui/Makefile
	priv/ui/common/Makefile
	priv/ui/unix/Makefile
	priv/utilities/Makefile
	priv/utilities/helper/Makefile
	priv/utilities/prefs/Makefile
	priv/utilities/utils/Makefile
	priv/utilities/errors/Makefile
	priv/keyserver/Makefile
	pub/Makefile
	pub/clientlib/Makefile
	pub/test/Makefile
	pub/include/Makefile, unix/config/pre.in, unix/config/post.in)
