diff options
author | Kevin Ryde <user42@zip.com.au> | 2001-07-24 01:43:46 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2001-07-24 01:43:46 +0200 |
commit | 77ca02d155d612a2e5fc83a34f2275e5205d8a02 (patch) | |
tree | 67a9c4297f893535bc4f5349e76ba18a425b6689 /acinclude.m4 | |
parent | fbf3d397185ab7e22c5bee5e752ff300e1166b98 (diff) | |
download | gmp-77ca02d155d612a2e5fc83a34f2275e5205d8a02.tar.gz |
Change from:
* configure.in, acinclude.m4 (GMP_OPTION_CXX): New macro.
To:
* configure.in, acinclude.m4 (GMP_PROG_CXX): New macro.
Diffstat (limited to 'acinclude.m4')
-rw-r--r-- | acinclude.m4 | 97 |
1 files changed, 42 insertions, 55 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index 4dd7ae5ae..1d9011189 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1632,17 +1632,15 @@ AC_SUBST(TAL_OBJECT) ]) -dnl GMP_OPTION_CXX -dnl -------------- -dnl Handle the --enable-cxx option. +dnl GMP_PROG_CXX +dnl ------------ +dnl Attempt to locate a C++ compiler. -AC_DEFUN(GMP_OPTION_CXX, -[have_cxx=no -if test $enable_cxx != no; then - test_CXXFLAGS=${CXXFLAGS+set} - AC_PROG_CXX +AC_DEFUN(GMP_PROG_CXX, +[test_CXXFLAGS=${CXXFLAGS+set} +AC_PROG_CXX - cat >conftest.cc <<EOF +cat >conftest.cc <<EOF #include <iostream.h> int main (void) @@ -1652,63 +1650,52 @@ main (void) return 0; } EOF - echo "configure: C++ test program:" >&AC_FD_CC - cat conftest.cc >&AC_FD_CC +echo "configure: C++ test program:" >&AC_FD_CC +cat conftest.cc >&AC_FD_CC + +if test "$test_CXXFLAGS" = set; then + # User specified $CXXFLAGS, just check the compiler works + AC_MSG_CHECKING([C++ compiler $CXX $CXXFLAGS]) gmp_cxxcompile="$CXX $CXXFLAGS conftest.cc" + if AC_TRY_EVAL(gmp_cxxcompile); then + AC_MSG_RESULT(yes) + have_cxx=yes + fi + AC_MSG_RESULT(no) + +else + # User didn't specify $CXXFLAGS, try $CFLAGS (possibly with -g removed) + # or what AC_PROG_CXX decided (which is either "-g -O2" or "-O2"). + # + # $CFLAGS stands a good chance of working, eg. on a GNU system where + # CC=gcc and CXX=g++, but no need to worry if it doesn't. + + if test "$ac_prog_cxx_g" = no; then + cxxflags_cflags=`echo "$CFLAGS" | sed -e 's/ -g //' -e 's/^-g //' -e 's/ -g$//'` + else + cxxflags_cflags=$CFLAGS + fi - if test "$test_CXXFLAGS" = set; then - # User specified $CXXFLAGS, just check the compiler works + echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC + cxxflags_ac_prog_cxx="$CXXFLAGS" + + for CXXFLAGS in "$cxxflags_cflags" "$cxxflags_ac_prog_cxx" ""; do AC_MSG_CHECKING([C++ compiler $CXX $CXXFLAGS]) + gmp_cxxcompile="$CXX $CXXFLAGS conftest.cc" if AC_TRY_EVAL(gmp_cxxcompile); then AC_MSG_RESULT(yes) have_cxx=yes + break fi AC_MSG_RESULT(no) - - else - # User didn't specify $CXXFLAGS, try $CFLAGS (possibly with -g removed) - # or what AC_PROG_CXX decided (which is either "-g -O2" or "-O2"). - # - # $CFLAGS stands a good chance of working, eg. on a GNU system where - # CC=gcc and CXX=g++, but no need to worry if it doesn't. - - if test "$ac_prog_cxx_g" = no; then - cxxflags_cflags=`echo "$CFLAGS" | sed -e 's/ -g //' -e 's/^-g //' -e 's/ -g$//'` - else - cxxflags_cflags=$CFLAGS - fi - - echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC - cxxflags_ac_prog_cxx="$CXXFLAGS" - - for CXXFLAGS in "$cxxflags_cflags" "$cxxflags_ac_prog_cxx" ""; do - AC_MSG_CHECKING([C++ compiler $CXX $CXXFLAGS]) - if AC_TRY_EVAL(gmp_cxxcompile); then - AC_MSG_RESULT(yes) - have_cxx=yes - break - fi - AC_MSG_RESULT(no) - done - fi - rm -f conftest* a.out - - # an error if C++ was requested but doesn't work - if test $have_cxx = no && test $enable_cxx = yes; then - AC_MSG_ERROR([C++ compiler not available]) - fi + done fi +rm -f conftest* a.out -AM_CONDITIONAL(HAVE_CXX, test $have_cxx = yes) - -# FIXME: This hack is because automake doesn't seem to like AM_CONDITIONAL -# defined variables in libgmp_la_DEPENDENCIES. -if test $have_cxx = yes; then - PRINTF_CXX_OBJECTS='$(PRINTF_CXX_OBJECTS)' -else - PRINTF_CXX_OBJECTS= +# an error if C++ was requested but doesn't work +if test $have_cxx = no && test $enable_cxx = yes; then + AC_MSG_ERROR([C++ compiler not available]) fi -AC_SUBST(PRINTF_CXX_OBJECTS) ]) |