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