2004-01-07 10:42:50 +03:00
|
|
|
dnl -*- shell-script -*-
|
|
|
|
dnl
|
2004-11-22 04:38:40 +03:00
|
|
|
dnl Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
dnl All rights reserved.
|
|
|
|
dnl Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
dnl All rights reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
dnl University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
dnl All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
dnl $COPYRIGHT$
|
|
|
|
dnl
|
|
|
|
dnl Additional copyrights may follow
|
|
|
|
dnl
|
2004-01-07 10:42:50 +03:00
|
|
|
dnl $HEADER$
|
|
|
|
dnl
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
AC_DEFUN([OMPI_SETUP_CC],[
|
2004-01-07 10:42:50 +03:00
|
|
|
|
|
|
|
# Modularize this setup so that sub-configure.in scripts can use this
|
|
|
|
# same setup code.
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_show_subtitle "C compiler and preprocessor"
|
2004-01-07 10:42:50 +03:00
|
|
|
|
|
|
|
# $%@#!@#% AIX!! This has to be called before anything invokes the C
|
|
|
|
# compiler.
|
|
|
|
|
|
|
|
dnl AC_AIX
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check for the compiler
|
|
|
|
#
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_cflags_save="$CFLAGS"
|
2004-01-07 10:42:50 +03:00
|
|
|
AC_PROG_CC
|
2005-08-28 17:11:38 +04:00
|
|
|
OMPI_CC_ORIGINAL="$CC"
|
2004-01-07 10:42:50 +03:00
|
|
|
BASECC="`basename $CC`"
|
2004-06-07 19:33:53 +04:00
|
|
|
CFLAGS="$ompi_cflags_save"
|
|
|
|
AC_DEFINE_UNQUOTED(OMPI_CC, "$CC", [OMPI underlying C compiler])
|
2005-06-17 05:06:36 +04:00
|
|
|
OMPI_CC_ABSOLUTE="`which $CC`"
|
|
|
|
AC_SUBST(OMPI_CC_ABSOLUTE)
|
2004-01-07 10:42:50 +03:00
|
|
|
|
2005-01-21 16:53:48 +03:00
|
|
|
# Check for compilers that impersonate gcc
|
|
|
|
|
|
|
|
AC_MSG_CHECKING([for compilers that impersonate gcc])
|
2005-08-28 17:11:38 +04:00
|
|
|
msg="not this one!"
|
|
|
|
liar=
|
2005-01-21 16:53:48 +03:00
|
|
|
TRULY_GCC=$GCC
|
|
|
|
if test "$GCC" = "yes"; then
|
|
|
|
AC_TRY_COMPILE([], [
|
|
|
|
int i = 3;
|
|
|
|
#if __INTEL_COMPILER
|
|
|
|
#error Yes, I am lying about being gcc.
|
|
|
|
#endif
|
2005-08-28 17:11:38 +04:00
|
|
|
], [], [msg=intel liar=yes])
|
2005-01-21 16:53:48 +03:00
|
|
|
|
|
|
|
# If we made it through unscathed, then it really is gcc
|
2005-08-28 17:11:38 +04:00
|
|
|
if test -z "$liar"; then
|
2005-01-21 16:53:48 +03:00
|
|
|
TRULY_GCC=yes
|
|
|
|
else
|
|
|
|
TRULY_GCC=no
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# We never thought that this was gcc to begin with
|
|
|
|
TRULY_GCC=no
|
|
|
|
fi
|
|
|
|
AC_MSG_RESULT([$msg])
|
|
|
|
|
2005-04-18 20:38:27 +04:00
|
|
|
# Do we want code coverage
|
|
|
|
if test "$WANT_COVERAGE" = "1"; then
|
|
|
|
if test "$TRULY_GCC" = "yes"; then
|
|
|
|
CLEANFILES="*.bb *.bbg *.da *.*.gcov ${CLEANFILES}"
|
|
|
|
AC_MSG_WARN([-fprofile-arcs -ftest-coverage has been added to CFLAGS (--enable-coverage)])
|
|
|
|
WANT_DEBUG=1
|
|
|
|
CFLAGS="-ftest-coverage -fprofile-arcs ${CFLAGS}"
|
|
|
|
WRAPPER_EXTRA_CFLAGS="-ftest-coverage -fprofile-arcs ${WRAPPER_EXTRA_CFLAGS}"
|
|
|
|
else
|
|
|
|
AC_MSG_WARN([Code coverage functionality is currently available only with GCC])
|
|
|
|
AC_MSG_ERROR([Configure: Cannot continue])
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2004-01-07 10:42:50 +03:00
|
|
|
# Do we want debugging?
|
|
|
|
|
|
|
|
if test "$WANT_DEBUG" = "1"; then
|
2004-01-11 03:07:54 +03:00
|
|
|
CFLAGS="$CFLAGS -g"
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_UNIQ(CFLAGS)
|
2004-03-29 00:39:15 +04:00
|
|
|
AC_MSG_WARN([-g has been added to CFLAGS (--enable-debug)])
|
2004-01-11 03:07:54 +03:00
|
|
|
fi
|
|
|
|
|
2005-01-21 16:53:48 +03:00
|
|
|
# These flags are generally gcc-specific; even the gcc-impersonating
|
|
|
|
# compilers won't accept them.
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_CFLAGS_BEFORE_PICKY="$CFLAGS"
|
2005-01-21 16:53:48 +03:00
|
|
|
if test "$TRULY_GCC" = "yes" -a "$WANT_PICKY_COMPILER" = 1; then
|
2004-10-16 23:51:04 +04:00
|
|
|
add="-Wall -Wundef -Wno-long-long -Wsign-compare"
|
2004-01-11 03:07:54 +03:00
|
|
|
add="$add -Wmissing-prototypes -Wstrict-prototypes"
|
2004-03-26 10:04:45 +03:00
|
|
|
add="$add -Wcomment -pedantic"
|
2004-01-11 03:07:54 +03:00
|
|
|
|
|
|
|
# see if -Wno-long-double works...
|
|
|
|
CFLAGS_orig="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Wno-long-double"
|
|
|
|
AC_TRY_COMPILE([], [], add="$add -Wno-long-double")
|
|
|
|
CFLAGS="$CFLAGS_orig"
|
|
|
|
|
|
|
|
add="$add -Werror-implicit-function-declaration "
|
|
|
|
|
2004-01-07 10:42:50 +03:00
|
|
|
CFLAGS="$CFLAGS $add"
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_UNIQ(CFLAGS)
|
2004-08-28 14:38:40 +04:00
|
|
|
AC_MSG_WARN([$add has been added to CFLAGS (--enable-picky)])
|
2004-01-07 10:42:50 +03:00
|
|
|
unset add
|
|
|
|
fi
|
|
|
|
|
2004-12-06 00:33:46 +03:00
|
|
|
# See if this version of gcc allows -finline-functions and/or
|
2005-01-21 16:53:48 +03:00
|
|
|
# -fno-strict-aliasing. Even check the gcc-impersonating compilers.
|
2004-05-18 18:14:12 +04:00
|
|
|
if test "$GCC" = "yes"; then
|
|
|
|
CFLAGS_orig="$CFLAGS"
|
2004-12-06 00:33:46 +03:00
|
|
|
|
|
|
|
CFLAGS="$CFLAGS_orig -finline-functions"
|
2004-05-18 18:14:12 +04:00
|
|
|
add=
|
|
|
|
AC_TRY_COMPILE([], [], add=" -finline-functions")
|
|
|
|
CFLAGS="$CFLAGS_orig$add"
|
2004-12-06 00:33:46 +03:00
|
|
|
|
|
|
|
CFLAGS="$CFLAGS_orig -fno-strict-aliasing"
|
|
|
|
add=
|
|
|
|
AC_TRY_COMPILE([], [], add=" -fno-strict-aliasing")
|
|
|
|
CFLAGS="$CFLAGS_orig$add"
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_UNIQ(CFLAGS)
|
2004-05-18 18:14:12 +04:00
|
|
|
AC_MSG_WARN([$add has been added to CFLAGS])
|
|
|
|
unset add
|
|
|
|
fi
|
|
|
|
|
2004-12-16 19:34:16 +03:00
|
|
|
# Try to enable restrict keyword
|
|
|
|
RESTRICT_CFLAGS=
|
|
|
|
case "${host}" in
|
|
|
|
ia64-unknown-linux*)
|
|
|
|
if test "$CC" = "ecc" ; then
|
|
|
|
RESTRICT_CFLAGS="-restrict"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
mips-sgi-irix*)
|
|
|
|
if test "$CC" = "cc" ; then
|
|
|
|
RESTRICT_CFLAGS="-LANG:restrict=ON"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
i?86-pc-linux*)
|
|
|
|
if test "$CC" = "icc" ; then
|
|
|
|
RESTRICT_CFLAGS="-restrict"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if test ! -z "$RESTRICT_CFLAGS" ; then
|
|
|
|
CFLAGS_orig="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS_orig $RESTRICT_CFLAGS"
|
|
|
|
add=
|
|
|
|
AC_TRY_COMPILE([], [], add=" $RESTRICT_CFLAGS")
|
|
|
|
CFLAGS="${CFLAGS_orig}${add}"
|
|
|
|
OMPI_UNIQ(CFLAGS)
|
|
|
|
AC_MSG_WARN([$add has been added to CFLAGS])
|
|
|
|
unset add
|
|
|
|
fi
|
|
|
|
|
2004-01-07 10:42:50 +03:00
|
|
|
# Preload the optflags for the case where the user didn't specify any.
|
|
|
|
# If we're using GNU compilers, use -O3 (since it GNU doesn't require
|
|
|
|
# all compilation units to be compiled with the same level of
|
|
|
|
# optimization -- selecting a high level of optimization is not
|
|
|
|
# prohibitive). If we're using anything else, be conservative and
|
|
|
|
# just use -O.
|
|
|
|
|
2005-01-21 16:53:48 +03:00
|
|
|
# Note: gcc-imperonating compilers accept -O3, so there's no need for
|
|
|
|
# $TRULY_GCC here.
|
|
|
|
|
2004-01-07 10:42:50 +03:00
|
|
|
if test "$GCC" = yes; then
|
|
|
|
OPTFLAGS="-O3"
|
|
|
|
else
|
|
|
|
OPTFLAGS="-O"
|
|
|
|
fi
|
2004-01-16 04:31:56 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_CHECK_OPTFLAGS("$OMPI_CFLAGS_BEFORE_PICKY")
|
|
|
|
OMPI_CFLAGS_BEFORE_PICKY="$co_result"
|
2004-01-16 04:31:56 +03:00
|
|
|
|
2004-01-07 10:42:50 +03:00
|
|
|
AC_MSG_CHECKING([for C optimization flags])
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_CHECK_OPTFLAGS("$CFLAGS")
|
2004-01-07 10:42:50 +03:00
|
|
|
AC_MSG_RESULT([$co_result])
|
2004-01-16 04:31:56 +03:00
|
|
|
CFLAGS="$co_result"])
|