| 1 |
# -*- shell-script -*- |
| 2 |
# |
| 3 |
# This file is part of the HDF4 build script. It is processed shortly |
| 4 |
# after configure starts and defines, among other things, flags for |
| 5 |
# the various compilation modes. |
| 6 |
|
| 7 |
# Choosing C and Fortran Compilers |
| 8 |
# -------------------------------------- |
| 9 |
# |
| 10 |
# The user should be able to specify the compiler by setting the CC |
| 11 |
# and F77 environment variables to the name of the compiler and any |
| 12 |
# switches it requires for proper operation. If CC is unset then this |
| 13 |
# script may set it. If CC is unset by time this script completes then |
| 14 |
# configure will try `gcc' and `cc' in that order (perhaps some others |
| 15 |
# too). |
| 16 |
# |
| 17 |
# Note: Code later in this file may depend on the value of $CC_BASENAME |
| 18 |
# in order to distinguish between different compilers when |
| 19 |
# deciding which compiler command-line switches to use. This |
| 20 |
# variable is set based on the incoming value of $CC and is only |
| 21 |
# used within this file. |
| 22 |
|
| 23 |
# The default compiler is `gcc'. |
| 24 |
if test -z "$CC"; then |
| 25 |
CC=gcc |
| 26 |
CC_BASENAME=gcc |
| 27 |
fi |
| 28 |
|
| 29 |
# Figure out GNU C compiler flags |
| 30 |
. $srcdir/config/gnu-flags |
| 31 |
|
| 32 |
# Figure out Intel oneAPI C compiler flags |
| 33 |
. $srcdir/config/oneapi-flags |
| 34 |
|
| 35 |
# Figure out Intel classic C compiler flags |
| 36 |
. $srcdir/config/intel-flags |
| 37 |
|
| 38 |
# Figure out Clang C compiler flags |
| 39 |
. $srcdir/config/clang-flags |
| 40 |
|
| 41 |
# Figure out NVHPC C compiler flags |
| 42 |
. $srcdir/config/nvidia-flags |
| 43 |
|
| 44 |
# Use default Fortran compiler according to what C compiler is used. |
| 45 |
if test "X-$F77" = "X-"; then |
| 46 |
F77=gfortran |
| 47 |
F77_BASENAME=gfortran |
| 48 |
|
| 49 |
else |
| 50 |
case $F77 in |
| 51 |
# The PGI and Intel compilers are automatically detected below |
| 52 |
f95*|pgf90*) |
| 53 |
;; |
| 54 |
|
| 55 |
*) |
| 56 |
# Figure out which compiler we are using: pgf90 or Absoft f95 |
| 57 |
RM='rm -f' |
| 58 |
tmpfile=/tmp/cmpver.$$ |
| 59 |
$F77 -V >$tmpfile |
| 60 |
if test -s "$tmpfile"; then |
| 61 |
if( grep -s 'Absoft' $tmpfile > /dev/null) then |
| 62 |
F77_BASENAME=f95 |
| 63 |
fi |
| 64 |
if( grep -s 'g95' $tmpfile > /dev/null) then |
| 65 |
F77_BASENAME=g95 |
| 66 |
fi |
| 67 |
if( grep -s 'pgf90' $tmpfile > /dev/null) then |
| 68 |
F77_BASENAME=pgf90 |
| 69 |
fi |
| 70 |
fi |
| 71 |
$RM $tmpfile |
| 72 |
;; |
| 73 |
esac |
| 74 |
fi |
| 75 |
|
| 76 |
# Figure out GNU FC compiler flags |
| 77 |
. $srcdir/config/gnu-fflags |
| 78 |
|
| 79 |
# compiler version strings |
| 80 |
|
| 81 |
# check if the compiler_version_info is already set |
| 82 |
if test -z "$cc_version_info"; then |
| 83 |
|
| 84 |
case $CC in |
| 85 |
# whatever matches *pgcc* will also match *gcc*, so this one must come first |
| 86 |
*pgcc*) |
| 87 |
cc_version_info=`$CC $CFLAGS $H4_CFLAGS -V 2>&1 | grep 'pgcc'` |
| 88 |
;; |
| 89 |
|
| 90 |
*gcc*) |
| 91 |
cc_version_info=`$CC $CFLAGS $H4_CFLAGS --version 2>&1 | grep -v 'PathScale' |\ |
| 92 |
grep 'GCC' | sed 's/\(.*(GCC) [-a-z0-9\. ]*\).*/\1/'` |
| 93 |
;; |
| 94 |
|
| 95 |
*nvc*) |
| 96 |
cc_version_info=`$CC $CFLAGS $H4_CFLAGS -V 2>&1 | grep 'nvc'` |
| 97 |
;; |
| 98 |
|
| 99 |
*icx*) |
| 100 |
cc_version_info=`$CC $CCFLAGS $H4_CCFLAGS -V 2>&1 | grep 'Version' |\ |
| 101 |
sed 's/\(Intel.* Compiler\).*\( Version [a-z0-9\.]*\).*\( Build [0-9]*\)/\1\2\3/'` |
| 102 |
;; |
| 103 |
|
| 104 |
*icc*) |
| 105 |
cc_version_info=`$CC $CCFLAGS $H4_CCFLAGS -V 2>&1 | grep 'Version' |\ |
| 106 |
sed 's/\(Intel.* Compiler\).*\( Version [a-z0-9\.]*\).*\( Build [0-9]*\)/\1\2\3/'` |
| 107 |
;; |
| 108 |
|
| 109 |
*clang*) |
| 110 |
cc_version_info="`$CC $CFLAGS $H4_CFLAGS --version 2>&1 |\ |
| 111 |
grep 'clang version' | sed 's/.*clang version \([-a-z0-9\.]*\).*/\1/'`" |
| 112 |
;; |
| 113 |
|
| 114 |
*) |
| 115 |
echo "No match to get cc_version_info for $CC" |
| 116 |
;; |
| 117 |
esac |
| 118 |
|
| 119 |
fi |
| 120 |
|
| 121 |
# get fortran version info |
| 122 |
case $F77 in |
| 123 |
*gfortran*) |
| 124 |
fc_version_info=`$F77 $FFLAGS --version 2>&1 |\ |
| 125 |
grep 'GCC' | sed 's/\(.*(GCC) [-a-z0-9\. ]*\).*/\1/'` |
| 126 |
fc_version="`$F77 $FFLAGS -v 2>&1 |grep 'gcc version' |\ |
| 127 |
sed 's/.*gcc version \([-a-z0-9\.]*\).*/\1/'`" |
| 128 |
if test X != "X$fc_version"; then |
| 129 |
fc_version=`echo $fc_version |sed 's/[-a-z]//g'` |
| 130 |
fi |
| 131 |
;; |
| 132 |
|
| 133 |
*ifc*|*ifort*) |
| 134 |
fc_version_info=`$F77 $FFLAGS -V 2>&1 | grep 'Version' |\ |
| 135 |
sed 's/\(Intel.* Compiler\).*\( Version [a-z0-9\.]*\).*\( Build [0-9]*\)/\1\2\3/'` |
| 136 |
fc_version="`$F77 $FFLAGS -V 2>&1 |grep '^Intel'`" |
| 137 |
if test X != "X$fc_version"; then |
| 138 |
fc_version="`echo $fc_version |sed 's/.*Version \([-a-z0-9\.\-]*\).*/\1/'`" |
| 139 |
fi |
| 140 |
;; |
| 141 |
|
| 142 |
*f95*) |
| 143 |
# Figure out which compiler we are using: pgf90 or Absoft f95 |
| 144 |
RM='rm -f' |
| 145 |
tmpfile=/tmp/cmpver.$$ |
| 146 |
$F77 -V >$tmpfile |
| 147 |
if test -s "$tmpfile"; then |
| 148 |
if( grep -s 'Absoft' $tmpfile > /dev/null) then |
| 149 |
FC_BASENAME=f95 |
| 150 |
fi |
| 151 |
fi |
| 152 |
$RM $tmpfile |
| 153 |
fc_version_info=`$F77 -V | grep Absoft` |
| 154 |
;; |
| 155 |
|
| 156 |
*g95*|*g77*) |
| 157 |
fc_version_info=`$F77 $FFLAGS --version 2>&1 |\ |
| 158 |
grep 'GCC'` |
| 159 |
;; |
| 160 |
|
| 161 |
*pgf90*) |
| 162 |
fc_version_info=`$F77 $FFLAGS -V 2>&1 | grep 'pgf90'` |
| 163 |
fc_version="`$F77 $FFLAGS -V 2>&1 |grep '^pgf90 '`" |
| 164 |
if test X != "X$fc_version"; then |
| 165 |
fc_version=`echo $fc_version |sed 's/pgf90 \([-a-z0-9\.\-]*\).*/\1/'` |
| 166 |
fi |
| 167 |
;; |
| 168 |
|
| 169 |
*) |
| 170 |
echo "No match to get fc_version_info for $F77" |
| 171 |
;; |
| 172 |
esac |
| 173 |
|
| 174 |
if test X != "X$fc_version"; then |
| 175 |
# Get the compiler version numbers |
| 176 |
fc_vers_major=`echo $fc_version | cut -f1 -d.` |
| 177 |
fi |
| 178 |
|
| 179 |
# Overriding Configure Tests |
| 180 |
# -------------------------- |
| 181 |
# |
| 182 |
# Values for overriding configuration tests when cross compiling. |
| 183 |
|
| 184 |
# Set this to `yes' or `no' depending on whether the target is big |
| 185 |
# endian or little endian. |
| 186 |
#ac_cv_c_bigendian=${ac_cv_c_bigendian='yes'} |