dnl
dnl rcsid = $Header: /nfs/globus1/src/master/globus_top/configure.in,v 1.35 1997/09/15 22:58:26 karlcz Exp $
dnl
litenl
dnl rcsid = $Header: /nfs/globus1/src/master/globus_top/configure.in,v 1.35 1997/09/15 22:58:26 karlcz Exp $
dnl
AC_REVISION($Revision: 1.35 $)dnl
AC_INIT(configuration)
AC_PREREQ(2.12)


dnl Check for explicitly enabled modules
dnl order is unimportant

AC_ARG_ENABLE(nexus,
        [  --enable-nexus                configure Nexus],
        [lac_enable_nexus="$enableval"],
        [lac_enable_nexus="no"])
AC_ARG_ENABLE(gram,
        [  --enable-gram                 configure GRAM],
        [lac_enable_gram="$enableval"],
        [lac_enable_gram="no"])
AC_ARG_ENABLE(gssapi,
        [  --enable-gssapi               configure GSSAPI],
        [lac_enable_gssapi="$enableval"],
        [lac_enable_gssapi="no"])
AC_ARG_ENABLE(gssapi_cleartext,
        [  --enable-gssapi_cleartext     configure GSSAPI_CLEARTEXT],
        [lac_enable_gssapi_cleartext="$enableval"],
        [lac_enable_gssapi_cleartext="no"])
AC_ARG_ENABLE(gssapi_spkm,
        [  --enable-gssapi_spkm          configure GSSAPI_SPKM],
        [lac_enable_gssapi_spkm="$enableval"],
        [lac_enable_gssapi_spkm="no"])
AC_ARG_ENABLE(hbm,
        [  --enable-hbm                  configure Heartbeat Monitor],
        [lac_enable_hbm="$enableval"],
        [lac_enable_hbm="no"])
AC_ARG_ENABLE(mds,
        [  --enable-mds                  configure MDS],
        [lac_enable_mds="$enableval"],
        [lac_enable_mds="no"])
AC_ARG_ENABLE(nws,
        [  --enable-nws                  configure NWS],
        [lac_enable_nws="$enableval"],
        [lac_enable_nws="no"])
AC_ARG_ENABLE(top,
        [  --enable-top                  configure TOPOLOGYD],
        [lac_enable_top="$enableval"],
        [lac_enable_top="no"])
AC_ARG_ENABLE(globusrc,
        [  --enable-globusrc             configure RC startup scripts],
        [lac_enable_globusrc="$enableval"],
        [lac_enable_globusrc="no"])
AC_ARG_ENABLE(grub,
        [  --enable-grub                 configure GRUB],
        [lac_enable_grub="$enableval"],
        [lac_enable_grub="no"])



dnl Enable any modules required by already-enabled modules
dnl this is computing transitive-closure in one pass, so make sure
dnl tests are topologically sorted, module A expanded before B 
dnl if A depends on B.

if test "$lac_enable_grub" = "yes" ; then
    lac_enable_gram="yes"
    dnl gram builds these right now:
    dnl lac_enable_gssapi="yes"
    dnl lac_enable_nexus="yes"
fi

if test "$lac_enable_gram" = "yes" ; then
    # null command for stupid shells
    echo > /dev/null 
    dnl gram builds these right now:
    dnl lac_enable_gssapi="yes"
    dnl lac_enable_nexus="yes"
fi

if test "$lac_enable_nws" = "yes" ; then
    # requires nexus
    lac_enable_nexus="yes"
fi

# The abstract "gssapi" module must enable one of the implementation
# modules...
if test "$lac_enable_gssapi" = "yes" ; then
    if test "$lac_enable_gssapi_cleartext" = "yes" ; then
        if test "$lac_enable_gssapi_spkm" = "yes" ; then
            # build both implementations!?
            echo Both GSSAPI modules have been enabled!?
        fi
    elif test "$lac_enable_gssapi_spkm" = "yes" ; then
        # null command for stupid shells
        echo > /dev/null
    else
        # enable a default implementation
        lac_enable_gssapi_cleartext="yes"
    fi
fi



dnl Build SUBDIRS list
dnl the modules are built in the order specified in this list,
dnl so make sure the list is topologically sorted, module B before A
dnl if A depends on B (this is the reverse order of the previous phase).

SUBDIRS=""

dnl Always put globus_start at the head of the list
if test "$lac_enable_globusrc" = "yes" ; then
    SUBDIRS="globus_start $SUBDIRS"
fi

if test "$lac_enable_nexus" = "yes" ; then
    SUBDIRS="$SUBDIRS nexus"
fi

if test "$lac_enable_gssapi_cleartext" = "yes" ; then
    SUBDIRS="$SUBDIRS gssapi_cleartext"
fi
if test "$lac_enable_gssapi_spkm" = "yes" ; then
    SUBDIRS="$SUBDIRS gssapi_spkm"
fi

if test "$lac_enable_gram" = "yes" ; then
    SUBDIRS="$SUBDIRS gram"
fi

if test "$lac_enable_hbm" = "yes" ; then
    SUBDIRS="$SUBDIRS hbm"
fi
if test "$lac_enable_mds" = "yes" ; then
    SUBDIRS="$SUBDIRS mds"
fi
if test "$lac_enable_top" = "yes" ; then
    SUBDIRS="$SUBDIRS topologyd"
fi

if test "$lac_enable_grub" = "yes" ; then
    SUBDIRS="$SUBDIRS grub"
fi

if test "$lac_enable_nws" = "yes" ; then
    SUBDIRS="$SUBDIRS nws"
fi


dnl default module list if nothing has been enabled
dnl Order of subdirs is important

if test "$SUBDIRS" = "" ; then
    SUBDIRS="globus_start \
             nexus gssapi_cleartext gram \
	     heartbeat_monitor mds topologyd"
fi


LAC_INIT
LAC_COMPILERS_ARGS
LAC_NEXUS_ARGS
LAC_GRAM_ARGS
LAC_GSSAPI_ARGS
LAC_GSSAPI_CLEARTEXT_ARGS
LAC_GSSAPI_SPKM_ARGS
LAC_MDS_ARGS


dnl For each component that is enable
dnl   1. verify any pre-configuration requirements
dnl   2. insert commands into the globus_start 
dnl      configuration script

for dir in $SUBDIRS
do
  case $dir in
    mds )  
           :
        ;;
    *   )  :
        ;;
  esac
done


AC_SUBST(SUBDIRS)
AC_CONFIG_SUBDIRS($SUBDIRS)

DOCDIRS="docs ports0/docs"
dnl DOCDIRS="ports0/docs"
AC_SUBST(DOCDIRS)

LAC_MAKEFILES(makefile_header, Makefile)

AC_OUTPUT($lac_makefiles $lac_makefile_headers, 
  LAC_INSERT_MAKEFILE_HEADERS echo timestamp > stamp-h,
  [lac_makefiles="$lac_makefiles"]
)







