Commit fe73ff3e authored by Shane Snyder's avatar Shane Snyder
Browse files

add more autoconf logic for MPI, GCC detection

parent f6d6be43
......@@ -650,11 +650,12 @@ GREP
CPP
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
ac_ct_CC
CC
MPICC
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
......@@ -701,6 +702,7 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
with_mpi
with_gcc
with_zlib
enable_ld_preload
enable_cuserid
......@@ -727,6 +729,7 @@ enable_mdhim
ac_precious_vars='build_alias
host_alias
target_alias
MPICC
CC
CFLAGS
LDFLAGS
......@@ -1378,6 +1381,7 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--without-mpi Build without support for MPI
--without-gcc Build without a GCC-compatible compiler
--with-zlib=DIR root directory path of zlib installation defaults to
/usr/local or /usr if not found in /usr/local
--without-zlib to disable zlib usage completely
......@@ -1394,6 +1398,7 @@ Optional Packages:
--with-mod-mem=<num> Maximum amount of memory (in MiB) for each Darshan module
Some influential environment variables:
MPICC MPI C compiler command
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
......@@ -1521,6 +1526,52 @@ fi
} # ac_fn_c_try_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
test -x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
......@@ -1718,52 +1769,6 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_header_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
test -x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
# -------------------------------------------
# Tests whether TYPE exists after having included INCLUDES, setting cache
......@@ -2297,23 +2302,135 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
ENABLE_MPI=1
# Check whether --with-mpi was given.
if test "${with_mpi+set}" = set; then :
withval=$with_mpi;
else
with_mpi=auto
fi
if test "x$with_mpi" = "xno"; then :
ENABLE_MPI=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to compile using MPI" >&5
$as_echo_n "checking whether to compile using MPI... " >&6; }
if test x"$with_mpi" != xno; then
_ax_prog_cc_mpi_mpi_wanted=yes
else
_ax_prog_cc_mpi_mpi_wanted=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_ax_prog_cc_mpi_mpi_wanted" >&5
$as_echo "$_ax_prog_cc_mpi_mpi_wanted" >&6; }
if test x"$_ax_prog_cc_mpi_mpi_wanted" = xyes; then
if test -z "$CC" && test -n "$MPICC"; then
CC="$MPICC"
else
if test -n "$ac_tool_prefix"; then
for ac_prog in mpicc mpixlc_r mpixlc hcc mpxlc_r mpxlc sxmpicc mpifcc mpgcc mpcc cmpicc cc gcc
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
$as_echo "#define HAVE_MPI /**/" >>confdefs.h
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in mpicc mpixlc_r mpixlc hcc mpxlc_r mpxlc sxmpicc mpifcc mpgcc mpcc cmpicc cc gcc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
ac_ext=c
test -n "$ac_ct_CC" && break
done
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
fi
fi
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
......@@ -3103,34 +3220,171 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test "x$ENABLE_MPI" = "x1"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the mpicc compiler works" >&5
$as_echo_n "checking whether the mpicc compiler works... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
# Check for compiler
# Needs to be split off into an extra macro to ensure right expansion
# order.
if test x"$_ax_prog_cc_mpi_mpi_wanted" = xno; then :
_ax_prog_cc_mpi_mpi_found=no
else
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
# test whether MPI_Init is available
# We do not use AC_SEARCH_LIBS here, as it caches its outcome and
# thus disallows corresponding calls in the other AX_PROG_*_MPI
# macros.
for lib in NONE mpi mpich; do
save_LIBS=$LIBS
if test x"$lib" = xNONE; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for function MPI_Init" >&5
$as_echo_n "checking for function MPI_Init... " >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for function MPI_Init in -l$lib" >&5
$as_echo_n "checking for function MPI_Init in -l$lib... " >&6; }
LIBS="-l$lib $LIBS"
fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char MPI_Init ();
int
main ()
{
return MPI_Init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
_ax_prog_cc_mpi_mpi_found=yes
else
_ax_prog_cc_mpi_mpi_found=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_ax_prog_cc_mpi_mpi_found" >&5
$as_echo "$_ax_prog_cc_mpi_mpi_found" >&6; }
if test "x$_ax_prog_cc_mpi_mpi_found" = "xyes"; then
break;
fi
LIBS=$save_LIBS
done
# Check for header
if test x"$_ax_prog_cc_mpi_mpi_found" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpi.h" >&5
$as_echo_n "checking for mpi.h... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <mpi.h>
int
main ()
{
int ret = MPI_Init(0, (void*)0)
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
as_fn_error $? "CC doesn't appear to be a valid MPI compiler. See INSTALL document or try adding CC=mpicc to your configure command line." "$LINENO" 5
_ax_prog_cc_mpi_mpi_found=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$_ax_prog_cc_mpi_mpi_found" = xyes; then :
use_mpi=yes
:
else
use_mpi=no
:
fi
ENABLE_MPI=1
if test "x$use_mpi" = "xno"; then :
ENABLE_MPI=
if test "x$with_mpi" = "xyes"; then :
as_fn_error $? "CC doesn't appear to be a valid MPI compiler and MPI support was requested. See INSTALL document or try adding CC=mpicc to your configure command line." "$LINENO" 5
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: not checking whether the mpicc compiler works" >&5
$as_echo "$as_me: not checking whether the mpicc compiler works" >&6;}
ENABLE_MPI=1
$as_echo "#define HAVE_MPI /**/" >>confdefs.h
fi
# Check whether --with-gcc was given.
if test "${with_gcc+set}" = set; then :
withval=$with_gcc;
else
with_gcc=yes
fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
#error GCC ERROR
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
if test "x$with_gcc" = "xyes"; then :
as_fn_error which is strongly recommended for building Darshan. To force use of a non-GCC compatible compiler "CC doesn't appear to be a GNU-compatible compiler" "$LINENO" 5
fi
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
......@@ -5889,8 +6143,9 @@ $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: Building Darshan with the following features:" >&5
$as_echo "$as_me: Building Darshan with the following features:" >&6;}
msg="Building Darshan with CC=$CC and with the following features:"
{ $as_echo "$as_me:${as_lineno-$LINENO}: $msg" >&5
$as_echo "$as_me: $msg" >&6;}
if test "x$BUILD_NULL_MODULE" = "x"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: NULL module support: no" >&5
$as_echo "$as_me: NULL module support: no" >&6;}
......
......@@ -14,23 +14,38 @@ AC_CONFIG_HEADER(darshan-runtime-config.h)
AC_PROG_INSTALL
dnl Check for MPI
ENABLE_MPI=1
AC_ARG_WITH(mpi,
AS_HELP_STRING([--without-mpi], [Build without support for MPI]))
AS_IF([test "x$with_mpi" = "xno"],
ENABLE_MPI=,
[AC_DEFINE([HAVE_MPI], [], [Define if build is MPI-enabled])])
[AS_HELP_STRING([--without-mpi], [Build without support for MPI])],
,
[with_mpi=auto])
AX_PROG_CC_MPI([test x"$with_mpi" != xno],
[use_mpi=yes],
[use_mpi=no])
dnl Check to see if CC is an MPI compiler
dnl TODO: better error message here
AS_IF([test "x$ENABLE_MPI" = "x1"],
[AC_MSG_CHECKING(whether the mpicc compiler works)
AC_TRY_COMPILE([#include <mpi.h>], [int ret = MPI_Init(0, (void*)0)],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
AC_MSG_ERROR(CC doesn't appear to be a valid MPI compiler. See INSTALL document or try adding CC=mpicc to your configure command line.))],
AC_MSG_NOTICE(not checking whether the mpicc compiler works))
ENABLE_MPI=1
AS_IF([test "x$use_mpi" = "xno"],
[ENABLE_MPI=
AS_IF([test "x$with_mpi" = "xyes"],
[AC_MSG_ERROR(CC doesn't appear to be a valid MPI compiler and MPI support was requested. See INSTALL document or try adding CC=mpicc to your configure command line.)],)],
[ENABLE_MPI=1
AC_DEFINE([HAVE_MPI], [], [Define if build is MPI-enabled])])
dnl check for GCC compiler support
AC_ARG_WITH(gcc,
[AS_HELP_STRING([--without-gcc], [Build without a GCC-compatible compiler])],
,
[with_gcc=yes])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(,[
#ifndef __GNUC__
#error GCC ERROR
#endif
])],
[],
[AS_IF([test "x$with_gcc" = "xyes"],
[AC_MSG_ERROR(CC doesn't appear to be a GNU-compatible compiler, which is strongly recommended for building Darshan. To force use of a non-GCC compatible compiler, add --without-gcc to your configure command line.)],)])
dnl runtime libraries require zlib
CHECK_ZLIB
......@@ -501,7 +516,8 @@ share/mpi-profile/darshan-bg-f.conf
share/ld-opts/darshan-base-ld-opts
)
AC_MSG_NOTICE(Building Darshan with the following features:)
msg="Building Darshan with CC=$CC and with the following features:"
AC_MSG_NOTICE($msg)
AS_IF([test "x$BUILD_NULL_MODULE" = "x"], [AC_MSG_NOTICE(NULL module support: no)], [AC_MSG_NOTICE(NULL module support: yes)])
AS_IF([test "x$BUILD_POSIX_MODULE" = "x"], [AC_MSG_NOTICE(POSIX module support: no)], [AC_MSG_NOTICE(POSIX module support: yes)])
AS_IF([test "x$BUILD_MPIIO_MODULE" = "x"], [AC_MSG_NOTICE(MPIIO module support: no)], [AC_MSG_NOTICE(MPIIO module support: yes)])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment