2004-01-07 10:42:50 +03:00
|
|
|
dnl -*- shell-script -*-
|
|
|
|
dnl
|
2005-11-05 22:57:48 +03:00
|
|
|
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
dnl University Research and Technology
|
|
|
|
dnl Corporation. All rights reserved.
|
2006-02-27 08:14:35 +03:00
|
|
|
dnl Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
dnl of Tennessee Research Foundation. All rights
|
|
|
|
dnl reserved.
|
2008-04-02 11:44:17 +04:00
|
|
|
dnl Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
dnl University of Stuttgart. All rights reserved.
|
2006-06-09 23:50:51 +04:00
|
|
|
dnl Copyright (c) 2004-2006 The Regents of the University of California.
|
2005-03-24 15:43:37 +03:00
|
|
|
dnl All rights reserved.
|
2007-12-14 05:39:58 +03:00
|
|
|
dnl Copyright (c) 2007 Sun Microsystems, Inc. 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
|
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
# OMPI_SETUP_CC()
|
|
|
|
# ---------------
|
|
|
|
# Do everything required to setup the C compiler. Safe to AC_REQUIRE
|
|
|
|
# this macro.
|
2005-09-07 09:54:53 +04:00
|
|
|
AC_DEFUN([OMPI_SETUP_CC],[
|
2005-12-12 03:41:01 +03:00
|
|
|
# AM_PROG_CC_C_O AC_REQUIREs AC_PROG_CC, so we have to be a little
|
|
|
|
# careful about ordering here, and AC_REQUIRE these things so that
|
|
|
|
# they get stamped out in the right order.
|
2005-09-07 09:54:53 +04:00
|
|
|
|
|
|
|
AC_REQUIRE([_OMPI_START_SETUP_CC])
|
|
|
|
AC_REQUIRE([_OMPI_PROG_CC])
|
|
|
|
AC_REQUIRE([AM_PROG_CC_C_O])
|
2004-01-07 10:42:50 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
OMPI_C_COMPILER_VENDOR([ompi_c_vendor])
|
|
|
|
|
2006-10-23 07:55:52 +04:00
|
|
|
# Check for standard headers, needed here because needed before
|
|
|
|
# the types checks.
|
|
|
|
AC_HEADER_STDC
|
|
|
|
|
2006-08-18 08:12:24 +04:00
|
|
|
# GNU C and autotools are inconsistent about whether this is
|
|
|
|
# defined so let's make it true everywhere for now... However, IBM
|
|
|
|
# XL compilers on PPC Linux behave really badly when compiled with
|
|
|
|
# _GNU_SOURCE defined, so don't define it in that situation.
|
|
|
|
#
|
|
|
|
# Don't use AC_GNU_SOURCE because it requires that no compiler
|
|
|
|
# tests are done before setting it, and we need to at least do
|
|
|
|
# enough tests to figure out if we're using XL or not.
|
|
|
|
AS_IF([test "$ompi_cv_c_compiler_vendor" != "ibm"],
|
|
|
|
[AH_VERBATIM([_GNU_SOURCE],
|
|
|
|
[/* Enable GNU extensions on systems that have them. */
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
# undef _GNU_SOURCE
|
|
|
|
#endif])
|
|
|
|
AC_DEFINE([_GNU_SOURCE])])
|
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
# Do we want code coverage
|
2006-08-01 01:55:01 +04:00
|
|
|
if test "$WANT_COVERAGE" = "1"; then
|
2005-12-12 03:41:01 +03:00
|
|
|
if test "$ompi_c_vendor" = "gnu" ; then
|
2006-08-01 01:55:01 +04:00
|
|
|
# For compilers > gcc-4.x, use --coverage for
|
|
|
|
# compiling and linking to circumvent trouble with
|
|
|
|
# libgcov.
|
|
|
|
CFLAGS_orig="$CFLAGS"
|
|
|
|
LDFLAGS_orig="$LDFLAGS"
|
|
|
|
|
|
|
|
CFLAGS="$CFLAGS_orig --coverage"
|
|
|
|
LDFLAGS="$LDFLAGS_orig --coverage"
|
|
|
|
OMPI_COVERAGE_FLAGS=
|
|
|
|
|
|
|
|
AC_CACHE_CHECK([if $CC supports --coverage],
|
|
|
|
[ompi_cv_cc_coverage],
|
|
|
|
[AC_TRY_COMPILE([], [],
|
|
|
|
[ompi_cv_cc_coverage="yes"],
|
|
|
|
[ompi_cv_cc_coverage="no"])])
|
|
|
|
|
|
|
|
if test "$ompi_cv_cc_coverage" = "yes" ; then
|
|
|
|
OMPI_COVERAGE_FLAGS="--coverage"
|
2007-01-19 17:28:52 +03:00
|
|
|
CLEANFILES="*.gcno ${CLEANFILES}"
|
|
|
|
CONFIG_CLEAN_FILES="*.gcda *.gcov ${CONFIG_CLEAN_FILES}"
|
2006-08-01 01:55:01 +04:00
|
|
|
else
|
|
|
|
OMPI_COVERAGE_FLAGS="-ftest-coverage -fprofile-arcs"
|
2007-01-19 17:28:52 +03:00
|
|
|
CLEANFILES="*.bb *.bbg ${CLEANFILES}"
|
|
|
|
CONFIG_CLEAN_FILES="*.da *.*.gcov ${CONFIG_CLEAN_FILES}"
|
2006-08-01 01:55:01 +04:00
|
|
|
fi
|
|
|
|
CFLAGS="$CFLAGS_orig $OMPI_COVERAGE_FLAGS"
|
|
|
|
LDFLAGS="$LDFLAGS_orig $OMPI_COVERAGE_FLAGS"
|
|
|
|
WRAPPER_EXTRA_CFLAGS="${WRAPPER_EXTRA_CFLAGS} $OMPI_COVERAGE_FLAGS"
|
|
|
|
WRAPPER_EXTRA_LDFLAGS="${WRAPPER_EXTRA_LDFLAGS} $OMPI_COVERAGE_FLAGS"
|
|
|
|
|
|
|
|
OMPI_UNIQ(CFLAGS)
|
|
|
|
OMPI_UNIQ(LDFLAGS)
|
|
|
|
OMPI_UNIQ(WRAPPER_EXTRA_CFLAGS)
|
|
|
|
OMPI_UNIQ(WRAPPER_EXTRA_LDFLAGS)
|
|
|
|
AC_MSG_WARN([$OMPI_COVERAGE_FLAGS has been added to CFLAGS (--enable-coverage)])
|
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
WANT_DEBUG=1
|
|
|
|
else
|
|
|
|
AC_MSG_WARN([Code coverage functionality is currently available only with GCC])
|
|
|
|
AC_MSG_ERROR([Configure: Cannot continue])
|
|
|
|
fi
|
|
|
|
fi
|
2005-01-21 16:53:48 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
# Do we want debugging?
|
2006-04-22 23:23:26 +04:00
|
|
|
if test "$WANT_DEBUG" = "1" -a "$enable_debug_symbols" != "no" ; then
|
2006-03-08 20:17:17 +03:00
|
|
|
if test "$ompi_c_vendor" = "gnu"; then
|
2006-05-20 02:09:29 +04:00
|
|
|
CFLAGS="$CFLAGS -g" # keep the -g3 for when it will become a standard option.
|
2006-03-04 16:59:14 +03:00
|
|
|
else
|
|
|
|
CFLAGS="$CFLAGS -g"
|
|
|
|
fi
|
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
OMPI_UNIQ(CFLAGS)
|
|
|
|
AC_MSG_WARN([-g has been added to CFLAGS (--enable-debug)])
|
|
|
|
fi
|
2004-01-11 03:07:54 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
# These flags are generally gcc-specific; even the
|
|
|
|
# gcc-impersonating compilers won't accept them.
|
|
|
|
OMPI_CFLAGS_BEFORE_PICKY="$CFLAGS"
|
|
|
|
if test "$WANT_PICKY_COMPILER" = 1 -a "$ompi_c_vendor" = "gnu" ; then
|
|
|
|
add="-Wall -Wundef -Wno-long-long -Wsign-compare"
|
|
|
|
add="$add -Wmissing-prototypes -Wstrict-prototypes"
|
|
|
|
add="$add -Wcomment -pedantic"
|
|
|
|
|
|
|
|
# see if -Wno-long-double works...
|
|
|
|
CFLAGS_orig="$CFLAGS"
|
2008-04-02 11:44:17 +04:00
|
|
|
# CFLAGS="$CFLAGS -Wno-long-double"
|
|
|
|
# Starting with GCC-4.4, the compiler complains about not
|
|
|
|
# knowing -Wno-long-double, only if -Wstrict-prototypes is set, too.
|
|
|
|
#
|
|
|
|
# Actually, this is not real fix, as GCC will pass on any -Wno- flag,
|
|
|
|
# have fun with the warning: -Wno-britney
|
|
|
|
CFLAGS="$CFLAGS -Wno-long-double -Wstrict-prototypes"
|
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
AC_CACHE_CHECK([if $CC supports -Wno-long-double],
|
2005-09-16 06:49:31 +04:00
|
|
|
[ompi_cv_cc_wno_long_double],
|
|
|
|
[AC_TRY_COMPILE([], [],
|
|
|
|
[ompi_cv_cc_wno_long_double="yes"],
|
|
|
|
[ompi_cv_cc_wno_long_double="no"])])
|
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
CFLAGS="$CFLAGS_orig"
|
|
|
|
if test "$ompi_cv_cc_wno_long_double" = "yes" ; then
|
|
|
|
add="$add -Wno-long-double"
|
|
|
|
fi
|
2004-01-11 03:07:54 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
add="$add -Werror-implicit-function-declaration "
|
2004-01-11 03:07:54 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
CFLAGS="$CFLAGS $add"
|
|
|
|
OMPI_UNIQ(CFLAGS)
|
|
|
|
AC_MSG_WARN([$add has been added to CFLAGS (--enable-picky)])
|
|
|
|
unset add
|
|
|
|
fi
|
2004-01-07 10:42:50 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
# See if this version of gcc allows -finline-functions and/or
|
|
|
|
# -fno-strict-aliasing. Even check the gcc-impersonating compilers.
|
|
|
|
if test "$GCC" = "yes"; then
|
|
|
|
CFLAGS_orig="$CFLAGS"
|
2004-12-06 00:33:46 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
CFLAGS="$CFLAGS_orig -finline-functions"
|
|
|
|
add=
|
|
|
|
AC_CACHE_CHECK([if $CC supports -finline-functions],
|
2005-09-16 06:49:31 +04:00
|
|
|
[ompi_cv_cc_finline_functions],
|
|
|
|
[AC_TRY_COMPILE([], [],
|
|
|
|
[ompi_cv_cc_finline_functions="yes"],
|
|
|
|
[ompi_cv_cc_finline_functions="no"])])
|
2005-12-12 03:41:01 +03:00
|
|
|
if test "$ompi_cv_cc_finline_functions" = "yes" ; then
|
|
|
|
add=" -finline-functions"
|
|
|
|
fi
|
|
|
|
CFLAGS="$CFLAGS_orig$add"
|
2004-12-06 00:33:46 +03:00
|
|
|
|
2006-08-27 20:28:05 +04:00
|
|
|
CFLAGS_orig="$CFLAGS"
|
2005-12-12 03:41:01 +03:00
|
|
|
CFLAGS="$CFLAGS_orig -fno-strict-aliasing"
|
|
|
|
add=
|
|
|
|
AC_CACHE_CHECK([if $CC supports -fno-strict-aliasing],
|
2005-09-16 06:49:31 +04:00
|
|
|
[ompi_cv_cc_fno_strict_aliasing],
|
|
|
|
[AC_TRY_COMPILE([], [],
|
|
|
|
[ompi_cv_cc_fno_strict_aliasing="yes"],
|
|
|
|
[ompi_cv_cc_fno_strict_aliasing="no"])])
|
2005-12-12 03:41:01 +03:00
|
|
|
if test "$ompi_cv_cc_fno_strict_aliasing" = "yes" ; then
|
|
|
|
add=" -fno-strict-aliasing"
|
|
|
|
fi
|
|
|
|
CFLAGS="$CFLAGS_orig$add"
|
2004-12-06 00:33:46 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
OMPI_UNIQ(CFLAGS)
|
|
|
|
AC_MSG_WARN([$add has been added to CFLAGS])
|
|
|
|
unset add
|
|
|
|
fi
|
2004-05-18 18:14:12 +04:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
# Try to enable restrict keyword
|
|
|
|
RESTRICT_CFLAGS=
|
|
|
|
case "$ompi_c_vendor" in
|
|
|
|
intel)
|
2004-12-16 19:34:16 +03:00
|
|
|
RESTRICT_CFLAGS="-restrict"
|
2005-12-12 03:41:01 +03:00
|
|
|
;;
|
|
|
|
sgi)
|
2004-12-16 19:34:16 +03:00
|
|
|
RESTRICT_CFLAGS="-LANG:restrict=ON"
|
2005-12-12 03:41:01 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if test ! -z "$RESTRICT_CFLAGS" ; then
|
|
|
|
CFLAGS_orig="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS_orig $RESTRICT_CFLAGS"
|
|
|
|
add=
|
|
|
|
AC_CACHE_CHECK([if $CC supports $RESTRICT_CFLAGS],
|
2005-09-16 06:49:31 +04:00
|
|
|
[ompi_cv_cc_restrict_cflags],
|
|
|
|
[AC_TRY_COMPILE([], [],
|
|
|
|
[ompi_cv_cc_restrict_cflags="yes"],
|
|
|
|
[ompi_cv_cc_restrict_cflags="no"])])
|
2006-11-05 23:38:44 +03:00
|
|
|
if test "$ompi_cv_cc_restrict_cflags" = "yes" ; then
|
2007-02-06 16:23:23 +03:00
|
|
|
add=" $RESTRICT_CFLAGS"
|
2005-12-12 03:41:01 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
CFLAGS="${CFLAGS_orig}${add}"
|
|
|
|
OMPI_UNIQ([CFLAGS])
|
|
|
|
if test "$add" != "" ; then
|
|
|
|
AC_MSG_WARN([$add has been added to CFLAGS])
|
|
|
|
fi
|
|
|
|
unset add
|
2005-09-16 06:49:31 +04:00
|
|
|
fi
|
|
|
|
|
2006-06-09 23:50:51 +04:00
|
|
|
# see if the C compiler supports __builtin_expect
|
|
|
|
AC_CACHE_CHECK([if $CC supports __builtin_expect],
|
|
|
|
[ompi_cv_cc_supports___builtin_expect],
|
2006-08-23 02:20:12 +04:00
|
|
|
[AC_TRY_LINK([],
|
2006-06-09 23:50:51 +04:00
|
|
|
[void *ptr = (void*) 0;
|
2006-06-10 04:32:39 +04:00
|
|
|
if (__builtin_expect (ptr != (void*) 0, 1)) return 0;],
|
2006-06-09 23:50:51 +04:00
|
|
|
[ompi_cv_cc_supports___builtin_expect="yes"],
|
|
|
|
[ompi_cv_cc_supports___builtin_expect="no"])])
|
|
|
|
if test "$ompi_cv_cc_supports___builtin_expect" = "yes" ; then
|
|
|
|
have_builtin_expect=1
|
|
|
|
else
|
|
|
|
have_builtin_expect=0
|
|
|
|
fi
|
|
|
|
AC_DEFINE_UNQUOTED([OMPI_C_HAVE_BUILTIN_EXPECT], [$have_builtin_expect],
|
|
|
|
[Whether C compiler supports __builtin_expect])
|
|
|
|
|
|
|
|
# see if the C compiler supports __builtin_prefetch
|
|
|
|
AC_CACHE_CHECK([if $CC supports __builtin_prefetch],
|
|
|
|
[ompi_cv_cc_supports___builtin_prefetch],
|
2006-08-23 02:20:12 +04:00
|
|
|
[AC_TRY_LINK([],
|
2006-06-09 23:50:51 +04:00
|
|
|
[int ptr;
|
2006-06-12 00:10:36 +04:00
|
|
|
__builtin_prefetch(&ptr,0,0);],
|
2006-06-09 23:50:51 +04:00
|
|
|
[ompi_cv_cc_supports___builtin_prefetch="yes"],
|
|
|
|
[ompi_cv_cc_supports___builtin_prefetch="no"])])
|
|
|
|
if test "$ompi_cv_cc_supports___builtin_prefetch" = "yes" ; then
|
|
|
|
have_builtin_prefetch=1
|
|
|
|
else
|
|
|
|
have_builtin_prefetch=0
|
|
|
|
fi
|
|
|
|
AC_DEFINE_UNQUOTED([OMPI_C_HAVE_BUILTIN_PREFETCH], [$have_builtin_prefetch],
|
|
|
|
[Whether C compiler supports __builtin_prefetch])
|
|
|
|
|
2005-12-12 03:41:01 +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.
|
|
|
|
#
|
2006-02-27 08:14:35 +03:00
|
|
|
# Note: gcc-impersonating compilers accept -O3
|
2006-04-22 23:23:26 +04:00
|
|
|
if test "$WANT_DEBUG" = "1"; then
|
|
|
|
OPTFLAGS=
|
2005-12-12 03:41:01 +03:00
|
|
|
else
|
2006-04-22 23:23:26 +04:00
|
|
|
if test "$GCC" = yes; then
|
|
|
|
OPTFLAGS="-O3"
|
|
|
|
else
|
|
|
|
OPTFLAGS="-O"
|
|
|
|
fi
|
2005-09-16 06:49:31 +04:00
|
|
|
fi
|
2004-12-16 19:34:16 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
OMPI_CHECK_OPTFLAGS("$OMPI_CFLAGS_BEFORE_PICKY")
|
|
|
|
OMPI_CFLAGS_BEFORE_PICKY="$co_result"
|
2004-01-07 10:42:50 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
AC_MSG_CHECKING([for C optimization flags])
|
|
|
|
OMPI_CHECK_OPTFLAGS(["$CFLAGS"])
|
|
|
|
AC_MSG_RESULT([$co_result])
|
|
|
|
CFLAGS="$co_result"
|
2007-01-19 17:28:52 +03:00
|
|
|
|
|
|
|
CFLAGS_WITHOUT_OPTFLAGS=""
|
|
|
|
for co_word in $CFLAGS ; do
|
|
|
|
co_found=0
|
|
|
|
case $co_word in
|
|
|
|
+K[0-5]) co_found=1 ;;
|
|
|
|
-O) co_found=1 ;;
|
|
|
|
-O[0-9]) co_found=1 ;;
|
|
|
|
-xO) co_found=1 ;;
|
|
|
|
-xO[0-9]) co_found=1 ;;
|
|
|
|
-fast) co_found=1 ;;
|
|
|
|
esac
|
|
|
|
if test "$co_found" = "0" ; then
|
|
|
|
CFLAGS_WITHOUT_OPTFLAGS="$CFLAGS_WITHOUT_OPTFLAGS $co_word"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
unset co_found co_word
|
|
|
|
|
|
|
|
AC_SUBST([CFLAGS_WITHOUT_OPTFLAGS])
|
2005-12-12 03:41:01 +03:00
|
|
|
])
|
2005-01-21 16:53:48 +03:00
|
|
|
|
2004-01-16 04:31:56 +03:00
|
|
|
|
2005-12-12 03:41:01 +03:00
|
|
|
AC_DEFUN([_OMPI_START_SETUP_CC],[
|
|
|
|
ompi_show_subtitle "C compiler and preprocessor"
|
|
|
|
|
|
|
|
# $%@#!@#% AIX!! This has to be called before anything invokes the C
|
|
|
|
# compiler.
|
|
|
|
dnl AC_AIX
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
AC_DEFUN([_OMPI_PROG_CC],[
|
|
|
|
#
|
|
|
|
# Check for the compiler
|
|
|
|
#
|
|
|
|
ompi_cflags_save="$CFLAGS"
|
|
|
|
AC_PROG_CC
|
|
|
|
BASECC="`basename $CC`"
|
|
|
|
CFLAGS="$ompi_cflags_save"
|
|
|
|
AC_DEFINE_UNQUOTED(OMPI_CC, "$CC", [OMPI underlying C compiler])
|
2007-12-06 14:38:35 +03:00
|
|
|
set dummy $CC
|
|
|
|
ompi_cc_argv0=[$]2
|
2007-12-14 05:39:58 +03:00
|
|
|
OMPI_WHICH([$ompi_cc_argv0], [OMPI_CC_ABSOLUTE])
|
2005-12-12 03:41:01 +03:00
|
|
|
AC_SUBST(OMPI_CC_ABSOLUTE)
|
|
|
|
])
|