1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
|
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2006 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2006 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2006 Los Alamos National Security, LLC. All rights
dnl reserved.
dnl Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved.
dnl Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
# This macro is necessary to get the title to be displayed first. :-)
AC_DEFUN([OMPI_SETUP_CXX_BANNER],[
ompi_show_subtitle "C++ compiler and preprocessor"
])
# This macro is necessary because PROG_CXX* is REQUIREd by multiple
# places in SETUP_CXX.
AC_DEFUN([OMPI_PROG_CXX],[
OMPI_VAR_SCOPE_PUSH([ompi_cxxflags_save])
ompi_cxxflags_save="$CXXFLAGS"
AC_PROG_CXX
AC_PROG_CXXCPP
CXXFLAGS="$ompi_cxxflags_save"
OMPI_VAR_SCOPE_POP
])
# OMPI_SETUP_CXX()
# ----------------
# Do everything required to setup the C++ compiler. Safe to AC_REQUIRE
# this macro.
AC_DEFUN([OMPI_SETUP_CXX],[
AC_REQUIRE([OMPI_SETUP_CXX_BANNER])
_OMPI_SETUP_CXX_COMPILER
_OMPI_CXX_CHECK_EXCEPTIONS
AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
[OMPI_CXX_FIND_TEMPLATE_REPOSITORY
OMPI_CXX_FIND_TEMPLATE_PARAMETERS
OMPI_CHECK_IDENT([CXX], [CXXFLAGS], [cc], [C++])])
_OMPI_CXX_CHECK_BUILTIN
_OMPI_CXX_CHECK_2D_CONST_CAST
AM_CONDITIONAL(WANT_MPI_CXX_BINDINGS, [test "$WANT_MPI_CXX_SUPPORT" = 1])
AC_DEFINE_UNQUOTED(OMPI_WANT_CXX_BINDINGS, $WANT_MPI_CXX_SUPPORT,
[Whether we want MPI C++ support or not])
])
# _OMPI_SETUP_CXX_COMPILER()
# --------------------------
# Setup the CXX compiler
AC_DEFUN([_OMPI_SETUP_CXX_COMPILER],[
OMPI_VAR_SCOPE_PUSH(ompi_cxx_compiler_works)
# There's a few cases here:
#
# 1. --enable-mpi-cxx was supplied: error if we don't find a C++
# compiler
# 2. --disable-mpi-cxx was supplied: check for a C++ compiler anyway
# (so we can have a functional mpic++ wrapper compiler), but
# don't error if we don't find one.
# 3. neither was specified: same was #2
#
# Then only proceed to do all the rest of the C++ checks if we
# both found a c++ compiler and want the C++ bindings (i.e., either
# case #1 or #3)
# Must REQUIRE the PROG_CXX macro and not call it directly here for
# reasons well-described in the AC2.64 (and beyond) docs.
AC_REQUIRE([OMPI_PROG_CXX])
BASECXX="`basename $CXX`"
AS_IF([test "x$CXX" = "x"], [CXX=none])
set dummy $CXX
ompi_cxx_argv0=[$]2
OMPI_WHICH([$ompi_cxx_argv0], [OMPI_CXX_ABSOLUTE])
AS_IF([test "x$OMPI_CXX_ABSOLUTE" = "x"], [OMPI_CXX_ABSOLUTE=none])
AC_DEFINE_UNQUOTED(OMPI_CXX, "$CXX", [OMPI underlying C++ compiler])
AC_SUBST(OMPI_CXX_ABSOLUTE)
# Make sure that the C++ compiler both works and is actually a C++
# compiler (if not cross-compiling). Don't just use the AC macro
# so that we can have a pretty message. Do something here that
# should force the linking of C++-specific things (e.g., STL
# strings) so that we can force a hard check of compiling,
# linking, and running a C++ application. Note that some C
# compilers, such as at least some versions of the GNU and Intel
# compilers, will detect that the file extension is ".cc" and
# therefore switch into a pseudo-C++ personality which works for
# *compiling*, but does not work for *linking*. So in this test,
# we want to cover the entire spectrum (compiling, linking,
# running). Note that it is not a fatal error if the C++ compiler
# does not work unless the user specifically requested the C++
# bindings.
AS_IF([test "$CXX" = "none"],
[ompi_cxx_compiler_works=no],
[AS_IF([test "$ompi_cv_cxx_compiler_vendor" = "microsoft" ],
[ompi_cxx_compiler_works=yes],
[OMPI_CHECK_COMPILER_WORKS([C++], [#include <string>
],
[std::string foo = "Hello, world"],
[ompi_cxx_compiler_works=yes],
[ompi_cxx_compiler_works=no])])])
AS_IF([test "$ompi_cxx_compiler_works" = "yes"],
[_OMPI_SETUP_CXX_COMPILER_BACKEND],
[AS_IF([test "$enable_mpi_cxx" = "yes"],
[AC_MSG_WARN([Could not find functional C++ compiler, but])
AC_MSG_WARN([support for the C++ MPI bindings was requested.])
AC_MSG_ERROR([Cannot continue])],
[WANT_MPI_CXX_SUPPORT=0])])
AC_MSG_CHECKING([if able to build the MPI C++ bindings])
AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AS_IF([test "$enable_mpi_cxx" = "yes"],
[AC_MSG_WARN([MPI C++ binding support requested but not delivered])
AC_MSG_ERROR([Cannot continue])])])
AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
[OMPI_CXX_COMPILER_VENDOR([ompi_cxx_vendor])])
OMPI_VAR_SCOPE_POP
])
# _OMPI_SETUP_CXX_COMPILER_BACKEND()
# ----------------------------------
# Back end of _OMPI_SETUP_CXX_COMPILER_BACKEND()
AC_DEFUN([_OMPI_SETUP_CXX_COMPILER_BACKEND],[
# Do we want code coverage
if test "$WANT_COVERAGE" = "1"; then
if test "$ompi_cxx_vendor" = "gnu" ; then
AC_MSG_WARN([$OMPI_COVERAGE_FLAGS has been added to CFLAGS (--enable-coverage)])
WANT_DEBUG=1
CXXFLAGS="${CXXFLAGS} $OMPI_COVERAGE_FLAGS"
WRAPPER_EXTRA_CXXFLAGS="${WRAPPER_EXTRA_CXXFLAGS} $OMPI_COVERAGE_FLAGS"
else
AC_MSG_WARN([Code coverage functionality is currently available only with GCC suite])
AC_MSG_ERROR([Configure: cannot continue])
fi
fi
# Do we want debugging?
if test "$WANT_DEBUG" = "1" -a "$enable_debug_symbols" != "no" ; then
CXXFLAGS="$CXXFLAGS -g"
OMPI_UNIQ(CXXFLAGS)
AC_MSG_WARN([-g has been added to CXXFLAGS (--enable-debug)])
fi
# These flags are generally g++-specific; even the g++-impersonating
# compilers won't accept them.
OMPI_CXXFLAGS_BEFORE_PICKY="$CXXFLAGS"
if test "$WANT_PICKY_COMPILER" = 1 -a "$ompi_cxx_vendor" = "gnu"; then
add="-Wall -Wundef -Wno-long-long"
# see if -Wno-long-double works...
AC_LANG_PUSH(C++)
CXXFLAGS_orig="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $add -Wno-long-double -fstrict-prototype"
AC_CACHE_CHECK([if $CXX supports -Wno-long-double],
[ompi_cv_cxx_wno_long_double],
[AC_TRY_COMPILE([], [],
[ompi_cv_cxx_wno_long_double="yes"],
[ompi_cv_cxx_wno_long_double="no"])])
CXXFLAGS="$CXXFLAGS_orig"
AC_LANG_POP(C++)
if test "$ompi_cv_cxx_wno_long_double" = "yes" ; then
add="$add -Wno-long-double"
fi
CXXFLAGS="$CXXFLAGS $add"
OMPI_UNIQ(CXXFLAGS)
if test "$add" != "" ; then
AC_MSG_WARN([$add has been added to CXXFLAGS (--enable-picky)])
fi
unset add
fi
# See if this version of g++ allows -finline-functions
if test "$GXX" = "yes"; then
CXXFLAGS_orig="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -finline-functions"
add=
AC_CACHE_CHECK([if $CXX supports -finline-functions],
[ompi_cv_cxx_finline_functions],
[AC_TRY_COMPILE([], [],
[ompi_cv_cxx_finline_functions="yes"],
[ompi_cv_cxx_finline_functions="no"])])
if test "$ompi_cv_cxx_finline_functions" = "yes" ; then
add=" -finline-functions"
fi
CXXFLAGS="$CXXFLAGS_orig$add"
OMPI_UNIQ(CXXFLAGS)
if test "$add" != "" ; then
AC_MSG_WARN([$add has been added to CXXFLAGS])
fi
unset add
fi
# Make sure we can link with the C compiler
if[ test "$ompi_cv_cxx_compiler_vendor" != "microsoft" ]; then
OMPI_LANG_LINK_WITH_C([C++], [],
[cat <<EOF >&2
**********************************************************************
* It appears that your C++ compiler is unable to link against object
* files created by your C compiler. This generally indicates either
* a conflict between the options specified in CFLAGS and CXXFLAGS
* or a problem with the local compiler installation. More
* information (including exactly what command was given to the
* compilers and what error resulted when the commands were executed) is
* available in the config.log file in this directory.
**********************************************************************
EOF
AC_MSG_ERROR([C and C++ compilers are not link compatible. Can not continue.])])
fi
# If we are on HP-UX, ensure that we're using aCC
case "$host" in
*hpux*)
if test "$BASECXX" = "CC"; then
AC_MSG_WARN([*** You will probably have problems compiling the MPI 2])
AC_MSG_WARN([*** C++ bindings with the HP-UX CC compiler. You should])
AC_MSG_WARN([*** probably be using the aCC compiler. Re-run configure])
AC_MSG_WARN([*** with the environment variable "CXX=aCC".])
fi
;;
esac
# Note: gcc-imperonating compilers accept -O3
if test "$WANT_DEBUG" = "1"; then
OPTFLAGS=
else
if test "$GXX" = yes; then
OPTFLAGS="-O3"
else
OPTFLAGS="-O"
fi
fi
# config/ompi_ensure_contains_optflags.m4
OMPI_ENSURE_CONTAINS_OPTFLAGS(["$CXXFLAGS"])
AC_MSG_CHECKING([for C++ optimization flags])
AC_MSG_RESULT([$co_result])
CXXFLAGS="$co_result"
# bool type size and alignment
AC_LANG_PUSH(C++)
AC_CHECK_SIZEOF(bool)
OMPI_C_GET_ALIGNMENT(bool, OPAL_ALIGNMENT_CXX_BOOL)
AC_LANG_POP(C++)
])
# _OMPI_CXX_CHECK_EXCEPTIONS()
# ----------------------------
# Check for exceptions, skipping the test if we don't want the C++
# bindings
AC_DEFUN([_OMPI_CXX_CHECK_EXCEPTIONS],[
# Check for special things due to C++ exceptions
ENABLE_CXX_EXCEPTIONS=no
HAVE_CXX_EXCEPTIONS=0
AC_ARG_ENABLE([cxx-exceptions],
[AC_HELP_STRING([--enable-cxx-exceptions],
[enable support for C++ exceptions (default: disabled)])],
[ENABLE_CXX_EXCEPTIONS="$enableval"])
AC_MSG_CHECKING([if want C++ exception handling])
AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "0"],
[AS_IF([test "$$enable_cxx_exceptions" = "yes"],
[AC_MSG_RESULT([error])
AC_MSG_WARN([--enable-cxx-exceptions was specified, but the MPI C++ bindings were disabled])
AC_MSG_ERROR([Cannot continue])],
[AC_MSG_RESULT([skipped])])],
[_OMPI_CXX_CHECK_EXCEPTIONS_BACKEND])
AC_DEFINE_UNQUOTED(OMPI_HAVE_CXX_EXCEPTION_SUPPORT, $HAVE_CXX_EXCEPTIONS,
[Whether or not we have compiled with C++ exceptions support])
])
# _OMPI_CXX_CHECK_EXCEPTIONS_BACKEND()
# ------------------------------------
# Back end of _OMPI_CXX_CHECK_EXCEPTIONS
AC_DEFUN([_OMPI_CXX_CHECK_EXCEPTIONS_BACKEND],[
AC_MSG_RESULT([$ENABLE_CXX_EXCEPTIONS])
if test "$ENABLE_CXX_EXCEPTIONS" = "yes"; then
# config/cxx_have_exceptions.m4
OMPI_CXX_HAVE_EXCEPTIONS
# config/cxx_find_exception_flags.m4
OMPI_CXX_FIND_EXCEPTION_FLAGS
if test "$OMPI_CXX_EXCEPTIONS" = "1"; then
HAVE_CXX_EXCEPTIONS=1
# Test to see if the C compiler likes these flags
AC_MSG_CHECKING([to see if C compiler likes the exception flags])
CFLAGS="$CFLAGS $OMPI_CXX_EXCEPTIONS_CXXFLAGS"
AC_LANG_SAVE
AC_LANG_C
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int i = 0;]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_WARN([C++ exception flags are different between the C and C++ compilers; this configure script cannot currently handle this scenario. Either disable C++ exception support or send mail to the Open MPI users list.])
AC_MSG_ERROR([*** Cannot continue])])
AC_LANG_RESTORE
# We can't test the F77 and F90 compilers now because we
# haven't found/set the up yet. So just save the flags
# and test them later (in ompi_setup_f77.m4 and
# ompi_setup_f90.m4).
CXXFLAGS="$CXXFLAGS $OMPI_CXX_EXCEPTIONS_CXXFLAGS"
LDFLAGS="$LDFLAGS $OMPI_CXX_EXCEPTIONS_LDFLAGS"
WRAPPER_EXTRA_CFLAGS="$OMPI_CXX_EXCEPTIONS_CXXFLAGS ${WRAPPER_EXTRA_CFLAGS}"
WRAPPER_EXTRA_FFLAGS="$OMPI_CXX_EXCEPTIONS_CXXFLAGS ${WRAPPER_EXTRA_FFLAGS}"
WRAPPER_EXTRA_FCFLAGS="$OMPI_CXX_EXCEPTIONS_CXXFLAGS ${WRAPPER_EXTRA_FCFLAGS}"
WRAPPER_EXTRA_CXXFLAGS="$OMPI_CXX_EXCEPTIONS_CXXFLAGS ${WRAPPER_EXTRA_CXXFLAGS}"
fi
fi
])
# _OMPI_CXX_CHECK_BUILTIN
# -----------------------
# Check for __builtin_* stuff
AC_DEFUN([_OMPI_CXX_CHECK_BUILTIN],[
OMPI_VAR_SCOPE_PUSH([have_cxx_builtin_expect have_cxx_builtin_prefetch])
have_cxx_builtin_expect=0
have_cxx_builtin_prefetch=0
AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
[_OMPI_CXX_CHECK_BUILTIN_BACKEND])
AC_DEFINE_UNQUOTED([OMPI_CXX_HAVE_BUILTIN_EXPECT],
[$have_cxx_builtin_expect],
[Whether C++ compiler supports __builtin_expect])
AC_DEFINE_UNQUOTED([OMPI_CXX_HAVE_BUILTIN_PREFETCH],
[$have_cxx_builtin_prefetch],
[Whether C++ compiler supports __builtin_prefetch])
OMPI_VAR_SCOPE_POP
])
# _OMPI_CXX_CHECK_BUILTIN_BACKEND
# -------------------------------
# Back end of _OMPI_CXX_CHECK_BUILTIN
AC_DEFUN([_OMPI_CXX_CHECK_BUILTIN_BACKEND],[
# see if the C++ compiler supports __builtin_expect
AC_LANG_PUSH(C++)
AC_CACHE_CHECK([if $CXX supports __builtin_expect],
[ompi_cv_cxx_supports___builtin_expect],
[AC_TRY_LINK([],
[void *ptr = (void*) 0;
if (__builtin_expect (ptr != (void*) 0, 1)) return 0;],
[ompi_cv_cxx_supports___builtin_expect="yes"],
[ompi_cv_cxx_supports___builtin_expect="no"])])
if test "$ompi_cv_cxx_supports___builtin_expect" = "yes" ; then
have_builtin_expect=1
fi
AC_LANG_POP(C++)
# see if the C compiler supports __builtin_prefetch
AC_LANG_PUSH(C++)
AC_CACHE_CHECK([if $CXX supports __builtin_prefetch],
[ompi_cv_cxx_supports___builtin_prefetch],
[AC_TRY_LINK([],
[int ptr;
__builtin_prefetch(&ptr,0,0);],
[ompi_cv_cxx_supports___builtin_prefetch="yes"],
[ompi_cv_cxx_supports___builtin_prefetch="no"])])
if test "$ompi_cv_cxx_supports___builtin_prefetch" = "yes" ; then
have_builtin_prefetch=1
fi
AC_LANG_POP(C++)
])
# _OMPI_CXX_CHECK_2D_CONST_CAST
# -----------------------------
# Check for compiler support of 2D const casts
AC_DEFUN([_OMPI_CXX_CHECK_2D_CONST_CAST],[
OMPI_VAR_SCOPE_PUSH([use_2d_const_cast])
use_2d_const_cast=0
AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
[_OMPI_CXX_CHECK_2D_CONST_CAST_BACKEND])
AC_DEFINE_UNQUOTED([OMPI_CXX_SUPPORTS_2D_CONST_CAST],
[$use_2d_const_cast],
[Whether a const_cast on a 2-d array will work with the C++ compiler])
OMPI_VAR_SCOPE_POP
])
# _OMPI_CXX_CHECK_2D_CONST_CAST_BACKEND
# ---------------------------------
# Back end of _OMPI_CHECK_2D_CONST_CAST
AC_DEFUN([_OMPI_CXX_CHECK_2D_CONST_CAST_BACKEND],[
# see if the compiler supports const_cast of 2-dimensional arrays
AC_LANG_PUSH(C++)
AC_CACHE_CHECK([if $CXX supports const_cast<> properly],
[ompi_cv_cxx_supports_2d_const_cast],
[AC_TRY_COMPILE([int non_const_func(int ranges[][3]);
int cast_test(const int ranges[][3]) {
return non_const_func(const_cast<int(*)[3]>(ranges));
}],
[],
[ompi_cv_cxx_supports_2d_const_cast="yes"],
[ompi_cv_cxx_supports_2d_const_cast="no"])])
if test "$ompi_cv_cxx_supports_2d_const_cast" = "yes" ; then
use_2d_const_cast=1
fi
AC_LANG_POP(C++)
])
|