AC_PREREQ(2.59)
dnl Process this file with autoconf to produce a configure script.
dnl
dnl The file name here refers to a file in the source being configured
AC_INIT(rlog.c)
dnl
dnl Definitions will be placed in this file rather than in the DEFS variable
AC_CONFIG_HEADER(rlogconf.h)
AH_TOP([/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*  
 *  (C) 2001 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */
#ifndef FORKERCONF_H_INCLUDED
#define FORKERCONF_H_INCLUDED
])
AH_BOTTOM([#endif])
dnl
echo "RUNNING CONFIGURE FOR RLOG"
dnl
dnl
dnl Enable better caching control
PAC_ARG_CACHING
dnl
AC_ARG_ENABLE(echo, 
[--enable-echo  - Turn on strong echoing. The default is enable=no.] ,set -x)
dnl
AC_ARG_ENABLE(strict,
[--enable-strict - Turn on strict debugging with gcc],
CFLAGS="$CFLAGS -O2 -Wall -Wstrict-prototypes -Wmissing-prototypes")
dnl
AC_ARG_ENABLE(g,
[--enable-g=option - Control the level of debugging support in the implementation.  
option may be a list of common separated names including
    none  - No debugging
    all   - All of the above choices],,enable_g=none)
dnl
dnl
AC_ARG_ENABLE(sharedlibs,
[--enable-sharedlibs=kind - Enable shared libraries.  kind may be
    gnu     - Standard gcc and GNU ld options for creating shared libraries
    libtool - GNU libtool 
This option is currently ignored])
dnl enable-g
# strip off multiple options, separated by commas
save_IFS="$IFS"
IFS=","
for option in $enable_g ; do
case "$option" in 
    no|none)
    ;;
    mem|all|yes)
    AC_DEFINE(USE_MEMORY_TRACING,,[Define to enable memory tracing])
    enable_g_mem=yes
    CFLAGS="$CFLAGS -g"
    ;;
    log|nesting|handle|debug|dbg)
    # Ignore these (they are valid for other configures)
    ;;
    *)
    AC_MSG_WARN([Unknown value $option for enable-g])
    ;;
esac
done
IFS="$save_IFS"
dnl
dnl
dnl First check that we have a clean build if we are doing a VPATH build
PAC_VPATH_CHECK()

dnl This test is complicated by the fact that top_srcdir is not set until
dnl the very end of configure.  Instead, we get it ourselves
if test -z "$top_srcdir" ; then
   use_top_srcdir=$srcdir   
else
   use_top_srcdir=$top_srcdir
fi
if test -z "$master_top_srcdir" ; then 
    master_top_srcdir=$use_top_srcdir
fi
AC_SUBST(master_top_srcdir)
export master_top_srcdir
#
# Get the master builddir (which may be imported from above)
if test -z "$master_top_builddir" ; then
    master_top_builddir=`pwd`
fi
export master_top_builddir
AC_SUBST(master_top_builddir)
dnl
dnl Find a C compiler (choose gcc first)
AC_PROG_CC
AC_PATH_PROG(AR,ar)
# Note that we set RANLIB to true if we don't find it (some systems neither
# need it nor provide it)
AC_CHECK_PROGS(RANLIB,ranlib,true)
dnl
dnl AC_PROG_MAKE_SET
PAC_PROG_MAKE
dnl
AC_PATH_PROG(PERL,perl)
dnl     check for compiler characteristics
dnl PAC_PROG_C_WEAK_SYMBOLS
AC_C_CONST
PAC_C_VOLATILE
PAC_C_RESTRICT
AC_C_INLINE
dnl PAC_C_STRUCT_ALIGNMENT
dnl
dnl Look for Standard headers
AC_HEADER_STDC
AC_CHECK_HEADER(jni.h)
if test "$ac_cv_header_jni_h" != "yes" ; then
   # Try to find the java include path.  For now, just generate warning
   # At ANL, places to look include /soft/com/packages/j2sdk1.4.0/include
   # and /soft/com/packages/jdk-1.3.1/include (and /soft/com/jdk*)
   # May also want to look in $JAVA_HOME/include
   AC_MSG_WARN([cannot compile trace code])
fi
dnl
MPILIBNAME=${MPILIBNAME:-"mpich"}
AC_SUBST(MPILIBNAME)
PMPILIBNAME=${PMPILIBNAME:-"p$MPILIBNAME"}
AC_SUBST(PMPILIBNAME)

dnl
dnl How do I get configure to find these values for me?
dnl use AC_PATH_PROG to find a likely location, then search likely 
dnl directory paths for the files that you need.  Allow an environment
dnl variable to provide the values, so that if they are in a strange
dnl place, the user can set the environment variable and configure will
dnl use that value (it should still check that the value is valid, i.e.,
dnl the necessary files are in the specified directory)
dnl
java_home=/soft/com/packages/j2sdk1.4.0
java_arch=linux
AC_SUBST(java_home)
AC_SUBST(java_arch)

if test -z "$ENABLE_SHLIB" ; then
    CC_SHL="$CC"
    ENABLE_SHLIB=none
fi
PAC_CC_SUBDIR_SHLIBS
dnl
dnl Dependency handling
AC_SUBST(MAKE_DEPEND_C)

dnl AC_SEARCH_LIBS(socket, socket)
dnl AC_CHECK_LIB(thread, mutex_init)
dnl AC_CHECK_HEADERS(foo.h bar.h)
dnl AC_CHECK_FUNCS(baz biff)

dnl
dnl Etags
AC_SUBST(ETAGS)
AC_SUBST(ETAGSADD)
export ETAGS
export ETAGSADD
dnl
dnl 
dnl
dnl Other autoconf variables that may be imported from the calling environment
AC_SUBST(DOCTEXT)

dnl Generate the Makefiles from Makefile.in
AC_OUTPUT_COMMANDS([chmod a+x pprintirlog])
AC_OUTPUT(Makefile pprintirlog)

