Commit a81d47d8 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r7155] Reprioritize the compiler order used by autoconf. This allows us to

use more recent compilers when available instead of relying on older
compilers by default: gfortran vs. g77 is one motivating example
(autoconf prefers g77 for Fortran 77). Also remove MPD specific
macros, allowing it to use confdb directly, so MPD can take advantage
of this change as well.

Reviewed by goodell.
parent 01c3c360
dnl
dnl This is a replacement for AC_PROG_CC that does not prefer gcc and
dnl that does not mess with CFLAGS. See acspecific.m4 for the original defn.
dnl
dnl/*D
dnl PAC_PROG_CC - Find a working C compiler
dnl
dnl Synopsis:
dnl PAC_PROG_CC
dnl
dnl Output Effect:
dnl Sets the variable CC if it is not already set
dnl
dnl Notes:
dnl Unlike AC_PROG_CC, this does not prefer gcc and does not set CFLAGS.
dnl It does check that the compiler can compile a simple C program.
dnl It also sets the variable GCC to yes if the compiler is gcc. It does
dnl not yet check for some special options needed in particular for
dnl parallel computers, such as -Tcray-t3e, or special options to get
dnl full ANSI/ISO C, such as -Aa for HP.
dnl
dnl D*/
dnl 2.52 doesn't have AC_PROG_CC_GNU
dnl AC_PROG_CC_GNU
ifdef([AC_PROG_CC_GNU],,[AC_DEFUN([AC_PROG_CC_GNU],)])
dnl PAC_PROG_CC - reprioritize the C compiler search order
AC_DEFUN([PAC_PROG_CC],[
AC_CHECK_PROGS(CC, cc xlC xlc pgcc icc pathcc gcc )
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
PAC_PROG_CC_WORKS
AC_PROG_CC_GNU
if test "$ac_cv_prog_gcc" = yes; then
GCC=yes
else
GCC=
fi
PAC_PUSH_ALL_FLAGS
AC_PROG_CC([gcc icc pgcc xlc xlC pathcc cc])
PAC_POP_ALL_FLAGS
])
dnl
dnl/*D
dnl PAC_C_CHECK_COMPILER_OPTION - Check that a compiler option is accepted
......
dnl PAC_PROG_CXX - reprioritize the C++ compiler search order
AC_DEFUN([PAC_PROG_CXX],[
PAC_PUSH_ALL_FLAGS
AC_PROG_CXX([g++ icpc pgCC xlC pathCC cl])
PAC_POP_ALL_FLAGS
])
dnl This is from crypt.to/autoconf-archive, slightly modified.
dnl It defines bool as int if it is not availalbe
dnl
......
dnl PAC_PROG_F77 - reprioritize the F77 compiler search order
AC_DEFUN([PAC_PROG_F77],[
PAC_PUSH_ALL_FLAGS
AC_PROG_F77([gfortran ifort pgf77 pgf90 af77 g77 xlf f77 frt cf77 fort77 \
fl32 xlf90 f90 pghpf epcf90 g95 xlf95 f95 fort ifc efc pgf95 lf95 ftn])
PAC_POP_ALL_FLAGS
])
dnl
dnl/*D
dnl PAC_PROG_F77_NAME_MANGLE - Determine how the Fortran compiler mangles
......
......@@ -30,8 +30,11 @@ dnl it may also be the name of a command for something other than
dnl the Fortran compiler (e.g., fc=file system check!)
dnl D*/
AC_DEFUN([PAC_PROG_FC],[
PAC_PUSH_ALL_FLAGS
AC_PROG_FC([m4_default([$1],
[f90 xlf90 pgf90 ifort epcf90 f95 fort xlf95 lf95 pathf95 pathf90 gfortran g95 ifc efc])])
[gfortran ifort pgf90 pathf90 pathf95 xlf90 xlf95 f90 epcf90 f95 \
fort lf95 g95 ifc efc])])
PAC_POP_ALL_FLAGS
])
dnl
dnl PAC_FC_EXT checks for the default Fortran 90 program extension, f90 then f.
......
......@@ -280,8 +280,8 @@ LIBS="$LIBS $MPICH2LIB_LIBS"
# Find a C compiler.
# We also need to do this before the F77 and FC test to ensure that we
# find the C preprocessor reliably.
PAC_PROG_CC
PAC_PUSH_FLAG([CFLAGS])
AC_PROG_CC
AC_PROG_CPP
# Bug in autoconf. Restore cross settings
if test "$pac_cross_compiling" = "yes" -a "$ac_cv_prog_cc_cross" = "no" ; then
......@@ -1702,17 +1702,13 @@ if test "$enable_f77" = "default" ; then
# check to see if it works (which the PROG_F77 command does as well)
# It also prefers g77 to f77, and doesn't know about other compilers
# Also handle the bug that autoconf sets FFLAGS for you
saveFFLAGS=$FFLAGS
AC_PROG_F77
FFLAGS=$saveFFLAGS
PAC_PROG_F77
if test -n "$F77" ; then
enable_f77_wasdefault=yes
enable_f77=yes
fi
elif test "$enable_f77" = "yes" ; then
saveFFLAGS=$FFLAGS
AC_PROG_F77
FFLAGS=$saveFFLAGS
PAC_PROG_F77
fi
if test "$enable_f77" = yes ; then
......@@ -1863,9 +1859,7 @@ if test "$enable_fc" = "default" -a "$enable_f77" = yes ; then
FCFLAGS=$saveFCFLAGS
if test -n "$FC" ; then
if test -z "$F77" ; then
saveFFLAGS=$FFLAGS
AC_PROG_F77
FFLAGS=$saveFFLAGS
PAC_PROG_F77
fi
#
# If we allow multiple weak symbols, we should test a name
......@@ -2319,29 +2313,7 @@ if test "$enable_cxx" = "default" ; then
fi
if test "$enable_cxx" = "yes" ; then
# Save the current CXXFLAGS (see below for the reason)
saveCXXFLAGS=$CXXFLAGS
# Misfeature in autoconf. While the macro name is PROG_CXX, it
# looks at the CCC environment variable, not CXX, even though it
# *sets* CXX!!!!
if test -z "$CCC" -a -n "$CXX" ; then
CCC="$CXX"
fi
AC_PROG_CXX
# Misfeature in autoconf. When using gcc, PROG_CXX insists on setting
# CXXFLAGS to -g -O2 if CXXFLAGS is not set. This may be appropriate for
# many tools built with configure and gcc, but not always. In particular,
# there seems to be no way to get gcc to use no extra flags if that is
# desired.
if test -z "$saveCXXFLAGS" -a -n "$CXXFLAGS" ; then
# restore CXXFLAGS
# Note: This may not be correct if PROG_CXX decided to add other
# flags to CXXFLAGS to enforce some behavior (such as ANSI/ISO C++),
# But we haven't seen that in practice. It would be better
# if the CXXFLAGS were decomposed into flags-that-change-the-language
# that the compiler accepts from optimizations
CXXFLAGS=$saveCXXFLAGS
fi
PAC_PROG_CXX
# Another bug in autoconf. The checks for the C++ compiler do not
# ensure that you can link a program that is built with the C++
# compiler. We've seen this error with gcc and icc, particularly
......
......@@ -146,9 +146,7 @@ pac_fc_f77_init="no"
# This produces a table of range,kind
if test -z "$CROSS_F90_ALL_INTEGER_MODELS" ; then
if test "$pac_fc_f77_init" != "yes" ; then
saveFFLAGS=$FFLAGS
AC_PROG_F77
FFLAGS=$saveFFLAGS
PAC_PROG_F77
# We assume that the Fortran 77 and Fortran 90 linkers are compatible
PAC_PROG_F77_LINKER_WITH_C
# For name mangle, we need the library flags
......@@ -168,9 +166,7 @@ AC_SUBST(FC_ALL_INTEGER_MODELS)
#
if test -z "$CROSS_F90_INTEGER_MODEL_MAP" ; then
if test "$pac_fc_f77_init" != "yes" ; then
saveFFLAGS=$FFLAGS
AC_PROG_F77
FFLAGS=$saveFFLAGS
PAC_PROG_F77
# We assume that the Fortran 77 and Fortran 90 linkers are compatible
PAC_PROG_F77_LINKER_WITH_C
# For name mangle, we need the library flags
......
dnl
dnl This is a replacement for AC_PROG_CC that does not prefer gcc and
dnl that does not mess with CFLAGS. See acspecific.m4 for the original defn.
dnl
dnl/*D
dnl PAC_PROG_CC - Find a working C compiler
dnl
dnl Synopsis:
dnl PAC_PROG_CC
dnl
dnl Output Effect:
dnl Sets the variable CC if it is not already set
dnl
dnl Notes:
dnl Unlike AC_PROG_CC, this does not prefer gcc and does not set CFLAGS.
dnl It does check that the compiler can compile a simple C program.
dnl It also sets the variable GCC to yes if the compiler is gcc. It does
dnl not yet check for some special options needed in particular for
dnl parallel computers, such as -Tcray-t3e, or special options to get
dnl full ANSI/ISO C, such as -Aa for HP.
dnl
dnl D*/
dnl 2.52 doesn't have AC_PROG_CC_GNU
dnl AC_PROG_CC_GNU
ifdef([AC_PROG_CC_GNU],,[AC_DEFUN([AC_PROG_CC_GNU],)])
dnl PAC_PROG_CC - reprioritize the C compiler search order
AC_DEFUN([PAC_PROG_CC],[
AC_CHECK_PROGS(CC, cc xlC xlc pgcc icc pathcc gcc )
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
PAC_PROG_CC_WORKS
AC_PROG_CC_GNU
if test "$ac_cv_prog_gcc" = yes; then
GCC=yes
else
GCC=
fi
PAC_PUSH_ALL_FLAGS
AC_PROG_CC([gcc icc pgcc xlc xlC pathcc cc])
PAC_POP_ALL_FLAGS
])
dnl
dnl/*D
dnl PAC_C_CHECK_COMPILER_OPTION - Check that a compiler option is accepted
......
dnl PAC_PROG_CXX - reprioritize the C++ compiler search order
AC_DEFUN([PAC_PROG_CXX],[
PAC_PUSH_ALL_FLAGS
AC_PROG_CXX([g++ icpc pgCC xlC pathCC cl])
PAC_POP_ALL_FLAGS
])
dnl This is from crypt.to/autoconf-archive, slightly modified.
dnl It defines bool as int if it is not availalbe
dnl
......
dnl PAC_PROG_F77 - reprioritize the F77 compiler search order
AC_DEFUN([PAC_PROG_F77],[
PAC_PUSH_ALL_FLAGS
AC_PROG_F77([gfortran ifort pgf77 pgf90 af77 g77 xlf f77 frt cf77 fort77 \
fl32 xlf90 f90 pghpf epcf90 g95 xlf95 f95 fort ifc efc pgf95 lf95 ftn])
PAC_POP_ALL_FLAGS
])
dnl
dnl/*D
dnl PAC_PROG_F77_NAME_MANGLE - Determine how the Fortran compiler mangles
......
......@@ -30,8 +30,11 @@ dnl it may also be the name of a command for something other than
dnl the Fortran compiler (e.g., fc=file system check!)
dnl D*/
AC_DEFUN([PAC_PROG_FC],[
PAC_PUSH_ALL_FLAGS
AC_PROG_FC([m4_default([$1],
[f90 xlf90 pgf90 ifort epcf90 f95 fort xlf95 lf95 pathf95 pathf90 gfortran g95 ifc efc])])
[gfortran ifort pgf90 pathf90 pathf95 xlf90 xlf95 f90 epcf90 f95 \
fort lf95 g95 ifc efc])])
PAC_POP_ALL_FLAGS
])
dnl
dnl PAC_FC_EXT checks for the default Fortran 90 program extension, f90 then f.
......
......@@ -411,13 +411,13 @@ case $ARCH in
;;
esac
AC_PROG_CC
PAC_PROG_CC
if test "$NOF77" != 1 ; then
# Grrr. The autoconf test for F77 will abort the configure
# if no compiler is found. We'd prefer to simply turn off
# support for Fortran, and/or give a more informative message.
AC_PROG_F77
PAC_PROG_F77
fi
if test "$CC" = "gcc" -a -z "$C_DEBUG_FLAG" ; then
C_DEBUG_FLAG="-g -O -Wall -Wstrict-prototypes -Wmissing-prototypes"
......
dnl
dnl This is a replacement for AC_PROG_CC that does not prefer gcc and
dnl that does not mess with CFLAGS. See acspecific.m4 for the original defn.
dnl
dnl/*D
dnl PAC_PROG_CC - Find a working C compiler
dnl
dnl Synopsis:
dnl PAC_PROG_CC
dnl
dnl Output Effect:
dnl Sets the variable CC if it is not already set
dnl
dnl Notes:
dnl Unlike AC_PROG_CC, this does not prefer gcc and does not set CFLAGS.
dnl It does check that the compiler can compile a simple C program.
dnl It also sets the variable GCC to yes if the compiler is gcc. It does
dnl not yet check for some special options needed in particular for
dnl parallel computers, such as -Tcray-t3e, or special options to get
dnl full ANSI/ISO C, such as -Aa for HP.
dnl
dnl D*/
dnl 2.52 doesn't have AC_PROG_CC_GNU
dnl AC_PROG_CC_GNU
ifdef([AC_PROG_CC_GNU],,[AC_DEFUN([AC_PROG_CC_GNU],)])
dnl PAC_PROG_CC - reprioritize the C compiler search order
AC_DEFUN([PAC_PROG_CC],[
AC_CHECK_PROGS(CC, cc xlC xlc pgcc icc pathcc gcc )
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
PAC_PROG_CC_WORKS
AC_PROG_CC_GNU
if test "$ac_cv_prog_gcc" = yes; then
GCC=yes
else
GCC=
fi
PAC_PUSH_ALL_FLAGS
AC_PROG_CC([gcc icc pgcc xlc xlC pathcc cc])
PAC_POP_ALL_FLAGS
])
dnl
dnl/*D
dnl PAC_C_CHECK_COMPILER_OPTION - Check that a compiler option is accepted
......
dnl PAC_PROG_CXX - reprioritize the C++ compiler search order
AC_DEFUN([PAC_PROG_CXX],[
PAC_PUSH_ALL_FLAGS
AC_PROG_CXX([g++ icpc pgCC xlC pathCC cl])
PAC_POP_ALL_FLAGS
])
dnl This is from crypt.to/autoconf-archive, slightly modified.
dnl It defines bool as int if it is not availalbe
dnl
......
dnl PAC_PROG_F77 - reprioritize the F77 compiler search order
AC_DEFUN([PAC_PROG_F77],[
PAC_PUSH_ALL_FLAGS
AC_PROG_F77([gfortran ifort pgf77 pgf90 af77 g77 xlf f77 frt cf77 fort77 \
fl32 xlf90 f90 pghpf epcf90 g95 xlf95 f95 fort ifc efc pgf95 lf95 ftn])
PAC_POP_ALL_FLAGS
])
dnl
dnl/*D
dnl PAC_PROG_F77_NAME_MANGLE - Determine how the Fortran compiler mangles
......
......@@ -30,8 +30,11 @@ dnl it may also be the name of a command for something other than
dnl the Fortran compiler (e.g., fc=file system check!)
dnl D*/
AC_DEFUN([PAC_PROG_FC],[
PAC_PUSH_ALL_FLAGS
AC_PROG_FC([m4_default([$1],
[f90 xlf90 pgf90 ifort epcf90 f95 fort xlf95 lf95 pathf95 pathf90 gfortran g95 ifc efc])])
[gfortran ifort pgf90 pathf90 pathf95 xlf90 xlf95 f90 epcf90 f95 \
fort lf95 g95 ifc efc])])
PAC_POP_ALL_FLAGS
])
dnl
dnl PAC_FC_EXT checks for the default Fortran 90 program extension, f90 then f.
......
......@@ -29,10 +29,7 @@ AX_PREFIX_CONFIG_H([include/mplconfig.h],[MPL])
# Non-verbose make
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Bug in autoconf adds -O2 and -g by default
save_cflags=$CFLAGS
AC_PROG_CC
CFLAGS=$save_cflags
PAC_PROG_CC
AC_C_CONST
AC_C_RESTRICT
......
......@@ -74,8 +74,9 @@ dnl Determine the executable and object file extensions. These
dnl are needed for some operations under cygwin
AC_EXEEXT
AC_OBJEXT
dnl Find a C compiler (choose gcc first)
AC_PROG_CC
dnl Find a C compiler
PAC_PROG_CC
PAC_ARG_STRICT
AC_PROG_INSTALL
......
dnl
dnl This is a replacement for AC_PROG_CC that does not prefer gcc and
dnl that does not mess with CFLAGS. See acspecific.m4 for the original defn.
dnl
dnl/*D
dnl PAC_PROG_CC - Find a working C compiler
dnl
dnl Synopsis:
dnl PAC_PROG_CC
dnl
dnl Output Effect:
dnl Sets the variable CC if it is not already set
dnl
dnl Notes:
dnl Unlike AC_PROG_CC, this does not prefer gcc and does not set CFLAGS.
dnl It does check that the compiler can compile a simple C program.
dnl It also sets the variable GCC to yes if the compiler is gcc. It does
dnl not yet check for some special options needed in particular for
dnl parallel computers, such as -Tcray-t3e, or special options to get
dnl full ANSI/ISO C, such as -Aa for HP.
dnl
dnl D*/
dnl 2.52 doesn't have AC_PROG_CC_GNU
dnl AC_PROG_CC_GNU
ifdef([AC_PROG_CC_GNU],,[AC_DEFUN([AC_PROG_CC_GNU],)])
dnl PAC_PROG_CC - reprioritize the C compiler search order
AC_DEFUN([PAC_PROG_CC],[
AC_CHECK_PROGS(CC, cc xlC xlc pgcc icc pathcc gcc )
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
PAC_PROG_CC_WORKS
AC_PROG_CC_GNU
if test "$ac_cv_prog_gcc" = yes; then
GCC=yes
else
GCC=
fi
PAC_PUSH_ALL_FLAGS
AC_PROG_CC([gcc icc pgcc xlc xlC pathcc cc])
PAC_POP_ALL_FLAGS
])
dnl
dnl/*D
dnl PAC_C_CHECK_COMPILER_OPTION - Check that a compiler option is accepted
......
dnl PAC_PROG_CXX - reprioritize the C++ compiler search order
AC_DEFUN([PAC_PROG_CXX],[
PAC_PUSH_ALL_FLAGS
AC_PROG_CXX([g++ icpc pgCC xlC pathCC cl])
PAC_POP_ALL_FLAGS
])
dnl This is from crypt.to/autoconf-archive, slightly modified.
dnl It defines bool as int if it is not availalbe
dnl
......
dnl PAC_PROG_F77 - reprioritize the F77 compiler search order
AC_DEFUN([PAC_PROG_F77],[
PAC_PUSH_ALL_FLAGS
AC_PROG_F77([gfortran ifort pgf77 pgf90 af77 g77 xlf f77 frt cf77 fort77 \
fl32 xlf90 f90 pghpf epcf90 g95 xlf95 f95 fort ifc efc pgf95 lf95 ftn])
PAC_POP_ALL_FLAGS
])
dnl
dnl/*D
dnl PAC_PROG_F77_NAME_MANGLE - Determine how the Fortran compiler mangles
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment