From a4e53b9e64c73703d0b003a794eb9b6369b9efce Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Sun, 29 Sep 2019 21:48:20 -0700 Subject: [PATCH] tweak compiler identification: check GNU compatibility first & then do ID checks. --- config.h.in | 8 ++++- configure | 74 ++++++++++++++++++++++++++++++---------------- configure.ac | 83 ++++++++++++++++++++++++++++++++-------------------- 3 files changed, 106 insertions(+), 59 deletions(-) diff --git a/config.h.in b/config.h.in index d54a083..1014181 100644 --- a/config.h.in +++ b/config.h.in @@ -88,7 +88,7 @@ /* Define to 1 if you have the `fstatat' function. */ #undef HAVE_FSTATAT -/* Uses the GNU gcc compiler */ +/* Uses the GNU g++ compiler */ #undef HAVE_GCC /* Define to 1 if you have the `getaddrinfo' function. */ @@ -109,6 +109,9 @@ /* Define to 1 if you have the `getuid' function. */ #undef HAVE_GETUID +/* Compiler supports GNU C++ dialect & args */ +#undef HAVE_GNUC + /* Define to 1 if you have the header file. */ #undef HAVE_GRP_H @@ -124,6 +127,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ICONV_H +/* Uses the Intel ICC compiler */ +#undef HAVE_INTEL_ICC + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H diff --git a/configure b/configure index 1fb05a8..ed9963f 100755 --- a/configure +++ b/configure @@ -4143,7 +4143,7 @@ if test -z "$CXX"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then - for ac_prog in g++ clang++ sunCC aCC xlc++_r gxlc++ ixlc icc owcc cl KCC cfront c++ + for ac_prog in g++ clang++ sunCC aCC xlc++_r gxlc++ ixlc icpc owcc cl KCC cfront c++ do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 @@ -4187,7 +4187,7 @@ fi fi if test -z "$CXX"; then ac_ct_CXX=$CXX - for ac_prog in g++ clang++ sunCC aCC xlc++_r gxlc++ ixlc icc owcc cl KCC cfront c++ + for ac_prog in g++ clang++ sunCC aCC xlc++_r gxlc++ ixlc icpc owcc cl KCC cfront c++ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -4869,57 +4869,79 @@ fi -if test "x${CXX}" = "xg++"; then - -$as_echo "#define HAVE_GCC 1" >>confdefs.h - +if test "x${GXX}" != "x"; then CFLAGS=${CFLAGS:-"-O -pipe"} CXXFLAGS=${CXXFLAGS:-"-O -pipe"} -fi -if test "x${CXX}" = "xclang++"; then + +$as_echo "#define HAVE_GNUC 1" >>confdefs.h + + + case "${CXX}" in + *clang++*) + +$as_echo "#define HAVE_CLANG 1" >>confdefs.h + + ;; + icpc) + +$as_echo "#define HAVE_INTEL_ICC 1" >>confdefs.h + + ;; + *) + +$as_echo "#define HAVE_GCC 1" >>confdefs.h + + ;; + esac + +else + if test "x${CXX}" = "xclang++"; then $as_echo "#define HAVE_CLANG 1" >>confdefs.h - CFLAGS=${CFLAGS:-"-O -pipe"} - CXXFLAGS=${CXXFLAGS:-"-O -pipe"} -fi + CFLAGS=${CFLAGS:-"-O -pipe"} + CXXFLAGS=${CXXFLAGS:-"-O -pipe"} + fi -if test "x${CXX}" = "xgxlc++"; then + if test "x${CXX}" = "xgxlc++"; then $as_echo "#define HAVE_IBM_GXLC 1" >>confdefs.h - export OBJECT_MODE=64 - CFLAGS=${CFLAGS:-"-O -maix64 -Wx,-qinfo=all" } - CXXFLAGS=${CXXFLAGS:-"-O -maix64 -Wx,-qinfo=all"} - ARFLAGS=${ARFLAGS:-"-X 64"} -fi + export OBJECT_MODE=64 + CFLAGS=${CFLAGS:-"-O -maix64 -Wx,-qinfo=all" } + CXXFLAGS=${CXXFLAGS:-"-O -maix64 -Wx,-qinfo=all"} + ARFLAGS=${ARFLAGS:-"-X 64"} + fi -if test "x${CXX}" = "xxlc++_r"; then + if test "x${CXX}" = "xxlc++_r"; then $as_echo "#define HAVE_IBM_XLC 1" >>confdefs.h - export OBJECT_MODE=64 - CFLAGS=${CFLAGS:-"-O -q64 -qinfo=all -qsuppress=1540-5311:1540-5337:1540-5341"} - CXXFLAGS=${CXXFLAGS:-"-O -q64 -qinfo=all -qsuppress=1540-5311:1540-5337:1540-5341"} - ARFLAGS=${ARFLAGS:-"-X 64"} -fi + export OBJECT_MODE=64 + CFLAGS=${CFLAGS:-"-O -q64 -qinfo=all -qsuppress=1540-5311:1540-5337:1540-5341"} + CXXFLAGS=${CXXFLAGS:-"-O -q64 -qinfo=all -qsuppress=1540-5311:1540-5337:1540-5341"} + ARFLAGS=${ARFLAGS:-"-X 64"} + fi -if test "x${CXX}" = "xsunCC"; then + if test "x${CXX}" = "xsunCC"; then $as_echo "#define HAVE_ORACLE_SUNCC 1" >>confdefs.h -fi + fi -if test "x${CXX}" = "xaCC"; then + if test "x${CXX}" = "xaCC"; then $as_echo "#define HAVE_HP_ACC 1" >>confdefs.h + fi + + fi diff --git a/configure.ac b/configure.ac index 362a39c..154e84f 100644 --- a/configure.ac +++ b/configure.ac @@ -29,7 +29,7 @@ dnl ################### dnl Checks for programs dnl ################### AC_PROG_CC([gcc clang suncc aCC xlc_r gxlc cl]) -AC_PROG_CXX([g++ clang++ sunCC aCC xlc++_r gxlc++ ixlc icc owcc cl KCC cfront c++]) +AC_PROG_CXX([g++ clang++ sunCC aCC xlc++_r gxlc++ ixlc icpc owcc cl KCC cfront c++]) AC_PROG_RANLIB AC_PROG_YACC AC_PROG_LN_S @@ -46,49 +46,68 @@ dnl ######################################### dnl Set up per-compiler constants & base args dnl ######################################### -dnl if test "x${GXX}" != "x"; then -if test "x${CXX}" = "xg++"; then - AC_DEFINE(HAVE_GCC, 1, [Uses the GNU gcc compiler]) +dnl first look at compilers that define __GNUC__ +dnl since automake is good at that. +dnl +if test "x${GXX}" != "x"; then CFLAGS=${CFLAGS:-"-O -pipe"} CXXFLAGS=${CXXFLAGS:-"-O -pipe"} -fi -if test "x${CXX}" = "xclang++"; then - AC_DEFINE(HAVE_CLANG, 1, [Uses the Clang compiler]) + AC_DEFINE(HAVE_GNUC, 1, [Compiler supports GNU C++ dialect & args]) + + case "${CXX}" in + *clang++*) + AC_DEFINE(HAVE_CLANG, 1, [Uses the Clang++ compiler]) + ;; + icpc) + AC_DEFINE(HAVE_INTEL_ICC, 1, [Uses the Intel ICC compiler]) + ;; + *) + AC_DEFINE(HAVE_GCC, 1, [Uses the GNU g++ compiler]) + ;; + esac - CFLAGS=${CFLAGS:-"-O -pipe"} - CXXFLAGS=${CXXFLAGS:-"-O -pipe"} -fi +else + dnl in case Clang stops defining __GNUC__ or user undefines it + if test "x${CXX}" = "xclang++"; then + AC_DEFINE(HAVE_CLANG, 1, [Uses the Clang compiler]) -if test "x${CXX}" = "xgxlc++"; then - AC_DEFINE(HAVE_IBM_GXLC, 1, [Uses the gxlc++ compiler]) + CFLAGS=${CFLAGS:-"-O -pipe"} + CXXFLAGS=${CXXFLAGS:-"-O -pipe"} + fi -dnl OBJECT_MODE needs to be set while compiling - export OBJECT_MODE=64 - CFLAGS=${CFLAGS:-"-O -maix64 -Wx,-qinfo=all" } - CXXFLAGS=${CXXFLAGS:-"-O -maix64 -Wx,-qinfo=all"} - ARFLAGS=${ARFLAGS:-"-X 64"} -fi + if test "x${CXX}" = "xgxlc++"; then + AC_DEFINE(HAVE_IBM_GXLC, 1, [Uses the gxlc++ compiler]) -if test "x${CXX}" = "xxlc++_r"; then - AC_DEFINE(HAVE_IBM_XLC, 1, [Uses the IBM XL C++ compiler]) + dnl OBJECT_MODE needs to be set while compiling + export OBJECT_MODE=64 + CFLAGS=${CFLAGS:-"-O -maix64 -Wx,-qinfo=all" } + CXXFLAGS=${CXXFLAGS:-"-O -maix64 -Wx,-qinfo=all"} + ARFLAGS=${ARFLAGS:-"-X 64"} + fi -dnl OBJECT_MODE needs to be set while compiling - export OBJECT_MODE=64 - CFLAGS=${CFLAGS:-"-O -q64 -qinfo=all -qsuppress=1540-5311:1540-5337:1540-5341"} - CXXFLAGS=${CXXFLAGS:-"-O -q64 -qinfo=all -qsuppress=1540-5311:1540-5337:1540-5341"} - ARFLAGS=${ARFLAGS:-"-X 64"} -fi + if test "x${CXX}" = "xxlc++_r"; then + AC_DEFINE(HAVE_IBM_XLC, 1, [Uses the IBM XL C++ compiler]) -dnl *** TODO these compilers need work on default args **** + dnl OBJECT_MODE needs to be set while compiling + export OBJECT_MODE=64 + CFLAGS=${CFLAGS:-"-O -q64 -qinfo=all -qsuppress=1540-5311:1540-5337:1540-5341"} + CXXFLAGS=${CXXFLAGS:-"-O -q64 -qinfo=all -qsuppress=1540-5311:1540-5337:1540-5341"} + ARFLAGS=${ARFLAGS:-"-X 64"} + fi -if test "x${CXX}" = "xsunCC"; then - AC_DEFINE(HAVE_ORACLE_SUNCC, 1, [Uses the sunCC compiler]) -fi + dnl *** TODO these compilers need work on default args **** + + if test "x${CXX}" = "xsunCC"; then + AC_DEFINE(HAVE_ORACLE_SUNCC, 1, [Uses the sunCC compiler]) + fi + + if test "x${CXX}" = "xaCC"; then + AC_DEFINE(HAVE_HP_ACC, 1, [Uses the aCC compiler]) + fi + -if test "x${CXX}" = "xaCC"; then - AC_DEFINE(HAVE_HP_ACC, 1, [Uses the aCC compiler]) fi dnl ######################