dnl Process this file with autoconf to produce a configure script.
dnl
dnl aclocal_cache.m4, included by sowing/confdb/aclocal.m4, fixes 
dnl bugs in autoconf caching.
dnl
dnl The file name here refers to a file in the source being configured
AC_PREREQ(2.59)
AC_INIT(uni_pmiutil.h)
dnl
dnl Definitions will be placed in this file rather than in the DEFS variable
AC_CONFIG_HEADER(pmiconf.h)
AH_TOP([/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*  
 *  (C) 2001 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */
#ifndef PMICONF_H_INCLUDED
#define PMICONF_H_INCLUDED
])
AH_BOTTOM([#endif])
dnl
dnl Set the directory that contains support scripts such as install-sh and
dnl config.guess
dnl AC_CONFIG_AUX_DIR(../../../confdb)
dnl
echo "RUNNING CONFIGURE FOR THE UNI PMI"
dnl
dnl
dnl Use AC_ARG_ENABLE to look for --enable-feature and AC_ARG_WITH to look for
dnl --with-capability
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(error-checking,
[--enable-error-checking=level - Control the amount of error checking.  
level may be 
    no        - no error checking
    runtime   - error checking controlable at runtime through environment 
                variables
    all       - error checking always enabled],,enable_error_checking=all)
dnl
AC_ARG_ENABLE(timing,
[--enable-timing=level - Control the amount of timing information 
collected by the MPICH implementation.  level may be
    none    - Collect no data
    all     - Collect lots of data
    runtime - Runtime control of data collected
The default is all.],,enable_timing=all)
dnl
AC_ARG_ENABLE(g,
[--enable-g=option - Control the level of debugging support in the PMI
implementation.  option may be a list of common separated names including
    none  - No debugging
    mem   - Memory usage tracing
    all   - All of the above choices],,enable_g=none)
dnl
dnl
dnl First check that we have a clean build if we are doing a VPATH build
PAC_VPATH_CHECK()
dnl
dnl Process any enable or with values
dnl error-checking
case "$enable_error_checking" in 
    no)
    ;;
    all|yes|runtime)
    error_checking_kind=`echo $enable_error_checking | \
    tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
    error_checking_kind=MPID_ERROR_LEVEL_$error_checking_kind
    AC_DEFINE_UNQUOTED(HAVE_ERROR_CHECKING,$error_checking_kind,[define to enable error checking])
    ;;
    *)
    AC_MSG_WARN([Unknown value $enable_error_checking for enable-error-checking])
    ;;
esac
dnl
dnl timing
case "$enable_timing" in
    no|none)
    ;;
    all|log|yes|time|runtime)
    timing_kind=`echo $enable_timing | \
    tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
    timing_kind=MPID_TIMING_KIND_$timing_kind
    AC_DEFINE_UNQUOTED(HAVE_TIMING,$timing_kind,[define to enable timing collection])
    ;;
    *)
    AC_MSG_WARN([Unknown value $enable_timing for enable-timing])
    ;; 
esac
dnl
dnl enable-g
case "$enable_g" in 
    no|none)
    ;;
    mem|all)
    AC_DEFINE(USE_MEMORY_TRACING,,[Define to enable memory tracing])
    enable_g_mem=yes
    CFLAGS="$CFLAGS -g"
    ;;
    *)
    AC_MSG_WARN([Unknown value $enable_g for enable-g])
    ;;
esac
dnl
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
dnl The recommended order for items in a configure.in file is
dnl     check for programs
dnl     check for libraries
dnl     check for header files
dnl     check for typedefs
dnl     check for structures
dnl     check for compiler characteristics
dnl     check for library functions
dnl     check for system services
dnl Here are some sample tests
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 Find SSH.  If SSH is defined, use that instead
dnl AC_PATH_PROG(SSH,ssh)
dnl
dnl AC_PROG_MAKE_SET
PAC_PROG_MAKE
dnl
dnl     check for compiler characteristics
AC_C_CONST
dnl
dnl Look for Standard headers
AC_HEADER_STDC
dnl Check for a specific header
AC_CHECK_HEADERS(string.h sys/time.h unistd.h sys/types.h stdlib.h errno.h)
dnl
dnl Setup other replaceable values
MPILIBNAME=mpich
AC_SUBST(MPILIBNAME)

AC_SUBST(master_top_srcdir)

dnl Configure any subdirectories.  Note that config.status will *not* 
dnl reexecute these!
dnl Export any important variables first:
export AR
export RANLIB
export MPILIBNAME
export CC
PAC_SUBDIR_CACHE

AC_SUBST(CC_SHL)
AC_SUBST(C_LINK_SHL)
AC_SUBST(ENABLE_SHLIB)

AC_OUTPUT(Makefile)


PAC_SUBDIR_CACHE_CLEANUP
