Blame confdb/aclocal_cxx.m4

Packit Service c5cf8c
dnl PAC_CXX_SEARCH_LIST - expands to a whitespace separated list of C++
Packit Service c5cf8c
dnl compilers for use with AC_PROG_CXX that is more suitable for HPC software
Packit Service c5cf8c
dnl packages
Packit Service c5cf8c
AC_DEFUN([PAC_CXX_SEARCH_LIST],[$CCC icpc pgCC xlC pathCC g++ clang++ c++ cc++ cxx CC cl])
Packit Service c5cf8c
dnl PAC_PROG_CXX - reprioritize the C++ compiler search order
Packit Service c5cf8c
dnl NOTE: this macro suffers from a basically intractable "expanded before it
Packit Service c5cf8c
dnl was required" problem when libtool is also used
Packit Service c5cf8c
AC_DEFUN([PAC_PROG_CXX],[
Packit Service c5cf8c
	PAC_PUSH_FLAG([CXXFLAGS])
Packit Service c5cf8c
        # This test uses the list from a recent PROG_CXX, but with the
Packit Service c5cf8c
        # addition of the Portland group, IBM, and Intel C++ compilers
Packit Service c5cf8c
        # (While the Intel icc compiler will compile C++ programs, it will
Packit Service c5cf8c
        # not *link* C++ object files unless there is at least one C++ source
Packit Service c5cf8c
        # file present on the command that performs the linking.  icpc is the
Packit Service c5cf8c
        # Intel C++ compiler that both compiles and links C++ programs)
Packit Service c5cf8c
	AC_PROG_CXX([PAC_CXX_SEARCH_LIST])
Packit Service c5cf8c
	PAC_POP_FLAG([CXXFLAGS])
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl This is from crypt.to/autoconf-archive, slightly modified.
Packit Service c5cf8c
dnl It defines bool as int if it is not availalbe
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([AX_CXX_BOOL],
Packit Service c5cf8c
[AC_CACHE_CHECK(whether the compiler recognizes bool as a built-in type,
Packit Service c5cf8c
ac_cv_cxx_bool,
Packit Service c5cf8c
[AC_LANG_SAVE
Packit Service c5cf8c
 AC_LANG_CPLUSPLUS
Packit Service c5cf8c
 AC_TRY_COMPILE([
Packit Service c5cf8c
int f(int  x){return 1;}
Packit Service c5cf8c
int f(char x){return 1;}
Packit Service c5cf8c
int f(bool x){return 1;}
Packit Service c5cf8c
],[bool b = true; return f(b);],
Packit Service c5cf8c
 ac_cv_cxx_bool=yes, ac_cv_cxx_bool=no)
Packit Service c5cf8c
 AC_LANG_RESTORE
Packit Service c5cf8c
])
Packit Service c5cf8c
if test "$ac_cv_cxx_bool" != yes; then
Packit Service c5cf8c
  AC_DEFINE(bool,int,[define if bool is a built-in type])
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl This is from crypt.to/autoconf-archive, slightly modified (name defined)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([AX_CXX_EXCEPTIONS],
Packit Service c5cf8c
[AC_CACHE_CHECK(whether the compiler supports exceptions,
Packit Service c5cf8c
ac_cv_cxx_exceptions,
Packit Service c5cf8c
[AC_LANG_SAVE
Packit Service c5cf8c
 AC_LANG_CPLUSPLUS
Packit Service c5cf8c
 AC_TRY_COMPILE(,[try { throw  1; } catch (int i) { return i; }],
Packit Service c5cf8c
 ac_cv_cxx_exceptions=yes, ac_cv_cxx_exceptions=no)
Packit Service c5cf8c
 AC_LANG_RESTORE
Packit Service c5cf8c
])
Packit Service c5cf8c
if test "$ac_cv_cxx_exceptions" = yes; then
Packit Service c5cf8c
  AC_DEFINE(HAVE_CXX_EXCEPTIONS,,[define if the compiler supports exceptions])
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl This is from crypt.to/autoconf-archive
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([AX_CXX_NAMESPACES],
Packit Service c5cf8c
[AC_CACHE_CHECK(whether the compiler implements namespaces,
Packit Service c5cf8c
ac_cv_cxx_namespaces,
Packit Service c5cf8c
[AC_LANG_SAVE
Packit Service c5cf8c
 AC_LANG_CPLUSPLUS
Packit Service c5cf8c
 AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
Packit Service c5cf8c
                [using namespace Outer::Inner; return i;],
Packit Service c5cf8c
 ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
Packit Service c5cf8c
 AC_LANG_RESTORE
Packit Service c5cf8c
])
Packit Service c5cf8c
if test "$ac_cv_cxx_namespaces" = yes; then
Packit Service c5cf8c
  AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl Some compilers support namespaces but don't know about std
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([AX_CXX_NAMESPACE_STD],
Packit Service c5cf8c
[AC_REQUIRE([AX_CXX_NAMESPACES])
Packit Service c5cf8c
AC_CACHE_CHECK(whether the compiler implements the namespace std,
Packit Service c5cf8c
ac_cv_cxx_namespace_std,
Packit Service c5cf8c
[ac_cv_cxx_namespace_std=no
Packit Service c5cf8c
if test "$ac_cv_cxx_namespaces" = yes ; then 
Packit Service c5cf8c
   AC_LANG_SAVE
Packit Service c5cf8c
   AC_LANG_CPLUSPLUS
Packit Service c5cf8c
   AC_TRY_COMPILE([
Packit Service c5cf8c
#include <iostream>
Packit Service c5cf8c
using namespace std;],
Packit Service c5cf8c
                [cout << "message\n";],
Packit Service c5cf8c
 ac_cv_cxx_namespace_std=yes, ac_cv_cxx_namespace_std=no)
Packit Service c5cf8c
   AC_LANG_RESTORE
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
if test "$ac_cv_cxx_namespace_std" = yes; then
Packit Service c5cf8c
  AC_DEFINE(HAVE_NAMESPACE_STD,,[define if the compiler implements namespace std])
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl/*D
Packit Service c5cf8c
dnl PAC_CXX_CHECK_COMPILER_OPTION - Check that a C++ compiler option is
Packit Service c5cf8c
dnl accepted without warning messages
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Synopsis:
Packit Service c5cf8c
dnl PAC_CXX_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Output Effects:
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl If no actions are specified, a working value is added to 'CXXOPTIONS'
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Notes:
Packit Service c5cf8c
dnl This is now careful to check that the output is different, since 
Packit Service c5cf8c
dnl some compilers are noisy.
Packit Service c5cf8c
dnl 
Packit Service c5cf8c
dnl We are extra careful to prototype the functions in case compiler options
Packit Service c5cf8c
dnl that complain about poor code are in effect.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Because this is a long script, we have ensured that you can pass a 
Packit Service c5cf8c
dnl variable containing the option name as the first argument.
Packit Service c5cf8c
dnl D*/
Packit Service c5cf8c
AC_DEFUN([PAC_CXX_CHECK_COMPILER_OPTION],[
Packit Service c5cf8c
AC_MSG_CHECKING([whether C++ compiler accepts option $1])
Packit Service c5cf8c
pac_opt="$1"
Packit Service c5cf8c
AC_LANG_PUSH([C++])
Packit Service c5cf8c
CXXFLAGS_orig="$CXXFLAGS"
Packit Service c5cf8c
CXXFLAGS_opt="$pac_opt $CXXFLAGS"
Packit Service c5cf8c
pac_result="unknown"
Packit Service c5cf8c
Packit Service c5cf8c
AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
Packit Service c5cf8c
CXXFLAGS="$CXXFLAGS_orig"
Packit Service c5cf8c
rm -f pac_test1.log
Packit Service c5cf8c
PAC_LINK_IFELSE_LOG([pac_test1.log], [], [
Packit Service c5cf8c
    CXXFLAGS="$CXXFLAGS_opt"
Packit Service c5cf8c
    rm -f pac_test2.log
Packit Service c5cf8c
    PAC_LINK_IFELSE_LOG([pac_test2.log], [], [
Packit Service c5cf8c
        PAC_RUNLOG_IFELSE([diff -b pac_test1.log pac_test2.log],
Packit Service c5cf8c
                          [pac_result=yes],[pac_result=no])
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        pac_result=no
Packit Service c5cf8c
    ])
Packit Service c5cf8c
], [
Packit Service c5cf8c
    pac_result=no
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_MSG_RESULT([$pac_result])
Packit Service c5cf8c
dnl Delete the conftest created by AC_LANG_CONFTEST.
Packit Service c5cf8c
rm -f conftest.$ac_ext
Packit Service c5cf8c
Packit Service c5cf8c
if test "$pac_result" = "yes" ; then
Packit Service c5cf8c
    AC_MSG_CHECKING([whether routines compiled with $pac_opt can be linked with ones compiled without $pac_opt])
Packit Service c5cf8c
    pac_result=unknown
Packit Service c5cf8c
    CXXFLAGS="$CXXFLAGS_orig"
Packit Service c5cf8c
    rm -f pac_test3.log
Packit Service c5cf8c
    PAC_COMPILE_IFELSE_LOG([pac_test3.log], [
Packit Service c5cf8c
        AC_LANG_SOURCE([
Packit Service c5cf8c
            int foo(void);
Packit Service c5cf8c
            int foo(void){return 0;}
Packit Service c5cf8c
        ])
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit Service c5cf8c
        saved_LIBS="$LIBS"
Packit Service c5cf8c
        LIBS="pac_conftest.$OBJEXT $LIBS"
Packit Service c5cf8c
Packit Service c5cf8c
        CXXFLAGS="$CXXFLAGS_opt"
Packit Service c5cf8c
        rm -f pac_test4.log
Packit Service c5cf8c
        PAC_LINK_IFELSE_LOG([pac_test4.log], [AC_LANG_PROGRAM()], [
Packit Service c5cf8c
            PAC_RUNLOG_IFELSE([diff -b pac_test2.log pac_test4.log],
Packit Service c5cf8c
                              [pac_result=yes], [pac_result=no])
Packit Service c5cf8c
        ],[
Packit Service c5cf8c
            pac_result=no
Packit Service c5cf8c
        ])
Packit Service c5cf8c
        LIBS="$saved_LIBS"
Packit Service c5cf8c
        rm -f pac_conftest.$OBJEXT
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        pac_result=no
Packit Service c5cf8c
    ])
Packit Service c5cf8c
    AC_MSG_RESULT([$pac_result])
Packit Service c5cf8c
    rm -f pac_test3.log pac_test4.log
Packit Service c5cf8c
fi
Packit Service c5cf8c
rm -f pac_test1.log pac_test2.log
Packit Service c5cf8c
Packit Service c5cf8c
dnl Restore CXXFLAGS before 2nd/3rd argument commands are executed,
Packit Service c5cf8c
dnl as 2nd/3rd argument command could be modifying CXXFLAGS.
Packit Service c5cf8c
CXXFLAGS="$CXXFLAGS_orig"
Packit Service c5cf8c
if test "$pac_result" = "yes" ; then
Packit Service c5cf8c
     ifelse([$2],[],[CXXOPTIONS="$CXXOPTIONS $1"],[$2])
Packit Service c5cf8c
else
Packit Service c5cf8c
     ifelse([$3],[],[:],[$3])
Packit Service c5cf8c
fi
Packit Service c5cf8c
AC_LANG_POP([C++])
Packit Service c5cf8c
])