1dnl -*- shell-script -*- 2dnl 3dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 4dnl University Research and Technology 5dnl Corporation. All rights reserved. 6dnl Copyright (c) 2004-2005 The University of Tennessee and The University 7dnl of Tennessee Research Foundation. All rights 8dnl reserved. 9dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 10dnl University of Stuttgart. All rights reserved. 11dnl Copyright (c) 2004-2005 The Regents of the University of California. 12dnl All rights reserved. 13dnl Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. 14dnl $COPYRIGHT$ 15dnl 16dnl Additional copyrights may follow 17dnl 18dnl $HEADER$ 19dnl 20 21AC_DEFUN([OMPI_CXX_FIND_EXCEPTION_FLAGS],[ 22# 23# Arguments: none 24# 25# Dependencies: none 26# 27# Get the exception handling flags for the C++ compiler. Leaves 28# CXXFLAGS undisturbed. 29# Provides --with-exflags command line argument for configure as well. 30# 31# Sets OMPI_CXX_EXCEPTION_CXXFLAGS and OMPI_CXX_EXCEPTION_LDFLAGS as 32# appropriate. 33# Must call AC_SUBST manually 34# 35 36# Command line flags 37 38AC_ARG_WITH(exflags, 39 AC_HELP_STRING([--with-exflags], 40 [Specify flags necessary to enable C++ exceptions]), 41 ompi_force_exflags="$withval") 42 43ompi_CXXFLAGS_SAVE="$CXXFLAGS" 44AC_MSG_CHECKING([for compiler exception flags]) 45 46# See which flags to use 47 48if test "$ompi_force_exflags" != ""; then 49 50 # If the user supplied flags, use those 51 52 ompi_exflags="$ompi_force_exflags" 53elif test "$GXX" = "yes"; then 54 55 # g++ has changed their flags a few times. Sigh. 56 57 CXXFLAGS="$CXXFLAGS -fexceptions" 58 59 AC_LANG_SAVE 60 AC_LANG_CPLUSPLUS 61 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[try { int i = 0; } catch(...) { int j = 2; }]])], ompi_happy=1, ompi_happy=0) 62 63 if test "$ompi_happy" = "1"; then 64 ompi_exflags="-fexceptions"; 65 else 66 CXXFLAGS="$CXXFLAGS_SAVE -fhandle-exceptions" 67 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[try { int i = 0; } catch(...) { int j = 2; }]])], ompi_happy=1, ompi_happy=0) 68 if test "$ompi_happy" = "1"; then 69 ompi_exflags="-fhandle-exceptions"; 70 fi 71 fi 72 AC_LANG_RESTORE 73elif test "`basename $CXX`" = "KCC"; then 74 75 # KCC flags 76 77 ompi_exflags="--exceptions" 78fi 79CXXFLAGS="$ompi_CXXFLAGS_SAVE" 80 81# Save the result 82 83OMPI_CXX_EXCEPTIONS_CXXFLAGS="$ompi_exflags" 84OMPI_CXX_EXCEPTIONS_LDFLAGS="$ompi_exflags" 85if test "$ompi_exflags" = ""; then 86 AC_MSG_RESULT([none necessary]) 87else 88 AC_MSG_RESULT([$ompi_exflags]) 89fi 90 91# Clean up 92 93unset ompi_force_exflags ompi_CXXFLAGS_SAVE ompi_exflags ompi_happy])dnl 94 95