compiler.m4 35.7 KB
Newer Older
1 2 3 4 5 6 7
#######################################################################################
# Get libtool configuration variable
# Arguments:
#  libtool config tag (e.g CXX)
#  libtool variable name
#  variable in which to store result
#######################################################################################
8
AC_DEFUN([FATHOM_LIBTOOL_VAR], [
9
  $3=`./libtool --tag=$1 --config | sed -e 's/^$2=//p' -e 'd' | tr -d '"\n'`
10 11
])

12

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#######################################################################################
# Check if the C++ compiler works.
# Arguments: action on success and action on failure
#######################################################################################
AC_DEFUN([FATHOM_CHECK_CXX_WORKS], [
  AC_LANG_PUSH([C++])
  AC_MSG_CHECKING([if $CXX works])
  AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM( [class Cl { int i; public: Cl(int x) : i(x) {} };] [Cl x(5);])],
   [AC_COMPILE_IFELSE( 
      [AC_LANG_PROGRAM( [],
[#ifdef __cplusplus
   choke me
 #endif])],
      [AC_MSG_RESULT([no (accepted invalid input)]); $2], [AC_MSG_RESULT([yes]); $1])],
    [AC_MSG_RESULT([no (failed on trival valid C++ source)]); $2])

  AC_LANG_POP([C++])
])


34
AC_DEFUN([FATHOM_CHECK_MPI_ENABLED], [
35 36 37 38
  AC_AFTER([$0], [AC_PROG_CC])dnl
  AC_REQUIRE([AC_PROG_CC])dnl
  AC_LANG_PUSH([C])
  AC_MSG_CHECKING([if $CC works with MPI])
39 40 41
  AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM( [#include <mpi.h>]
   [int i=MPI_SUCCESS;] )],
42 43 44
   [AC_MSG_RESULT([yes]); $1=yes],
    [AC_MSG_RESULT([no]); $1=no])
  AC_LANG_POP([C])
45 46
])

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
########## Helper function for FATHOM_CHECK_COMPILERS #############
# args: compiler variable, compiler list, path
AC_DEFUN([FATHOM_SET_MPI_COMPILER], [
  if test "x" = "x${$1}"; then
    if test "x" = "x$3"; then
      AC_CHECK_PROGS([$1], [$2], [false])
    else
      $1=false
      for prog in $2 ; do
        if test -x "$3/$prog"; then
          $1="$3/$prog"
          AC_SUBST($1)
          export $1
          break
        fi
      done
    fi
    
    if test "x${$1}" = "xfalse"; then
      AC_MSG_ERROR([Cannot find MPI compiler.  Try specifying \$$1])
    fi
  fi
])

71 72 73 74 75 76 77
#######################################################################################
# Implement checks for C and C++ compilers, with all corresponding options
#
# Sets the following variables:
#  CPP      - The C preprocessor
#  CC       - The C compiler
#  CXX      - The C++ compiler
78
#  FC       - The Fortran compiler
79 80
#  CFLAGS   - C compiler flags
#  CXXFLAGS - C++ compiler flags
81 82
#  enablempi- 'yes' if parallel support, 'no' otherwise
#  WITH_MPI - if enablempi=yes, then path to MPI installation
83
#
84 85 86 87
# Arguments:  three strings that msut be either "yes" or "no".
#             - test for C compiler
#             - test for C++ compiler
#             - test for Fortran compiler
88
#######################################################################################
's avatar
committed
89
AC_DEFUN([FATHOM_CHECK_COMPILERS], [
90

91 92 93 94 95 96 97 98 99
CHECK_CC="$1"
CHECK_CXX="$2"
CHECK_FC="$3"

# If not specified or invalid value, change to yes.
test "xno" = "x$CHECK_CC" || CHECK_CC=yes 
test "xno" = "x$CHECK_CXX" || CHECK_CXX=yes 
test "xno" = "x$CHECK_FC" || CHECK_FC=yes 

100 101 102 103 104 105
  # Save these before calling AC_PROG_CC or AC_PROG_CXX
  # because those macros will modify them, and we want
  # the original user values, not the autoconf defaults.
USER_CXXFLAGS="$CXXFLAGS"
USER_CFLAGS="$CFLAGS"

106 107 108 109 110 111
  # Save these before calling AC_PROG_FC or AC_PROG_F77
  # because those macros will modify them, and we want
  # the original user values, not the autoconf defaults.
USER_FCFLAGS="$FCFLAGS"
USER_FFLAGS="$FFLAGS"

112 113
# Check for Parallel
# Need to check this early so we can look for the correct compiler
114
AC_ARG_WITH( [mpi], AS_HELP_STRING([[--with-mpi@<:@=DIR@:>@]], [Enable parallel support]),
115 116 117
             [WITH_MPI=$withval; enablempi=yes],[enablempi=no;WITH_MPI=$MPI_DIR] )

if test "xno" != "x$enablempi"; then
118

119
  CC_LIST="mpixlc mpicc mpcc"
120
  CXX_LIST="mpixlcxx mpicxx mpiCC mpCC"
121 122
  FC_LIST="mpixlf95 mpixlf90 mpif90"
  F77_LIST="mpixlf77 mpif77"
123
  DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-mpi=\"${WITH_MPI}\""
124

125
fi
126

127 128 129
CC_LIST="$CC $CC_LIST gcc icc clang"
CXX_LIST="$CXX $CXX_LIST g++ icpc clang++"
FC_LIST="$FC $FC_LIST gfortran ifort pgf90 nag xlf"
130
F77_LIST="$F77 $F77_LIST $FC gfortran ifort pgf77 nag xlf g77 f77"
131

132 133 134
COMPILERPATHS=""
if test "xno" != "x$enablempi"; then
  COMPILERPATHS="${WITH_MPI}/bin"
135
fi
136

137 138 139 140 141
FATHOM_SET_MPI_COMPILER([CC],  [$CC_LIST], [$COMPILERPATHS])
FATHOM_SET_MPI_COMPILER([CXX],[$CXX_LIST],[$COMPILERPATHS])

# FATHOM_CHECK_MPI_ENABLED([compiler_supports_mpi])
# AC_SUBST(compiler_supports_mpi)
142 143 144 145 146 147 148 149 150 151 152 153 154

# C support
AC_PROG_CC
AC_PROG_CPP

# C++ support
AC_PROG_CXX
AC_PROG_CXXCPP

# Fortran support
if (test "x$CHECK_FC" != "xno"); then
  FATHOM_SET_MPI_COMPILER([F77],[$F77_LIST],[$COMPILERPATHS])
  AC_PROG_F77
155
  FATHOM_SET_MPI_COMPILER([FC],  [$FC_LIST],[$COMPILERPATHS])
156
  AC_PROG_FC
157
fi
158

's avatar
committed
159
]) # FATHOM_CHECK_COMPILERS
160 161 162 163 164 165 166 167



#######################################################################################
# Implement checks for C and C++ compiler options
#
#  CFLAGS   - C compiler flags
#  CXXFLAGS - C++ compiler flags
168
#  DEBUG - yes if specified, no otherwise
169 170
#
#######################################################################################
's avatar
committed
171
AC_DEFUN([FATHOM_COMPILER_FLAGS], [
172

173 174 175
CHECK_CC="$1"
CHECK_CXX="$2"
CHECK_FC="$3"
176

177 178 179 180 181
# If not specified or invalid value, change to yes.
test "xno" = "x$CHECK_CC" || CHECK_CC=yes 
test "xno" = "x$CHECK_CXX" || CHECK_CXX=yes 
test "xno" = "x$CHECK_FC" || CHECK_FC=yes 

182 183 184 185 186 187 188 189
# Check for debug flags
AC_ARG_ENABLE( debug, AS_HELP_STRING([--enable-debug],[Debug symbols (-g)]),
               [enable_debug=$enableval], [enable_debug="no"] )
AC_ARG_ENABLE( optimize, AS_HELP_STRING([--enable-optimize],[Compile optimized (-O2)]),
               [enable_optimize=$enableval; enable_cxx_optimize=$enableval; enable_cc_optimize=$enableval; enable_fc_optimize=$enableval;],
               [enable_optimize=""; enable_cxx_optimize="no"; enable_cc_optimize="no"; enable_fc_optimize="no";	]
             )

Fathom's avatar
Fathom committed
190
EXTRA_PGI_ONLY_FCFLAGS="-Mfree"
191 192
if (test "x$enable_debug" != "xno"); then # debug flags
# GNU
193
EXTRA_GNU_CXXFLAGS="-Wall -Wno-long-long -pipe -pedantic -Wshadow -Wunused-parameter -Wpointer-arith -Wformat -Wformat-security -Wextra -Wno-variadic-macros -Wno-unknown-pragmas"
vijaysm's avatar
vijaysm committed
194
EXTRA_GNU_FCFLAGS="-pipe -pedantic -ffree-line-length-0"
vijaysm's avatar
vijaysm committed
195 196 197
# CLANG
EXTRA_CLANG_CXXFLAGS="$EXTRA_GNU_CXXFLAGS"
EXTRA_CLANG_FCFLAGS="$EXTRA_GNU_FCFLAGS"
198 199
# Intel
EXTRA_INTEL_CXXFLAGS="-pipe -C"
200
EXTRA_INTEL_FCFLAGS="-C"
201
# PGI
Fathom's avatar
Fathom committed
202
EXTRA_PGI_CXXFLAGS="-traceback --diag_suppress 236 --diag_suppress=unrecognized_gcc_pragma -C"
Fathom's avatar
Fathom committed
203
EXTRA_PGI_FCFLAGS="-traceback -Mbounds -Ktrap=inv,divz,ovf"
204
# XLC
vijaysm's avatar
vijaysm committed
205 206
EXTRA_BG_CXXFLAGS="-qarch=qp -qpic=large -qdebug=except"
EXTRA_BG_FCFLAGS="-qarch=qp -qpic=large -qdebug=except"
207 208 209 210
fi

if (test "x$enable_cxx_optimize" != "xno"); then  # optimization flags
#GNU
211
EXTRA_GNU_CXXFLAGS="$EXTRA_GNU_CXXFLAGS -fprefetch-loop-arrays -finline-functions -march=native"
vijaysm's avatar
vijaysm committed
212
EXTRA_GNU_FCFLAGS="$EXTRA_GNU_FCFLAGS -ffree-line-length-0 -finline-functions"
vijaysm's avatar
vijaysm committed
213
#CLANG
214
EXTRA_CLANG_CXXFLAGS="$EXTRA_CLANG_CXXFLAGS -march=native"
vijaysm's avatar
vijaysm committed
215
EXTRA_CLANG_FCFLAGS="$EXTRA_CLANG_FCFLAGS -ffree-line-length-0 -finline-functions"
216 217 218 219
# Intel
EXTRA_INTEL_CXXFLAGS="$EXTRA_INTEL_CXXFLAGS -xHost -ip -no-prec-div" # -fast
EXTRA_INTEL_FCFLAGS="$EXTRA_INTEL_FCFLAGS -xHost -ip -no-prec-div" # -fast
# PGI
220 221
EXTRA_PGI_CXXFLAGS="$EXTRA_PGI_CXXFLAGS -fast"
EXTRA_PGI_FCFLAGS="$EXTRA_PGI_FCFLAGS -fast"
222
# XLC
vijaysm's avatar
vijaysm committed
223 224
EXTRA_BG_CXXFLAGS="$EXTRA_BG_CXXFLAGS -qarch=qp -qtune=auto -qpic=large -qenablevmx"
EXTRA_BG_FCFLAGS="$EXTRA_BG_FCFLAGS -qarch=qp -qtune=auto -qpic=large -qenablevmx"
225 226
fi

227 228 229 230 231 232 233 234 235 236
if (test "x$GXX" = "xyes"); then # G++ specific flags
  if (test "x$enable_debug" != "xno"); then
    EXTRA_GNU_ONLY_CXXFLAGS="$EXTRA_GNU_CXXFLAGS"
    EXTRA_GNU_ONLY_FCFLAGS="$EXTRA_GNU_FCFLAGS"
  else
    EXTRA_GNU_ONLY_CXXFLAGS="$EXTRA_GNU_CXXFLAGS -ftree-vectorize"
    EXTRA_GNU_ONLY_FCFLAGS="$EXTRA_GNU_FCFLAGS -ftree-vectorize"
  fi
fi

237
# this is just a test comment
238
if test "xno" != "x$CHECK_CC"; then
's avatar
committed
239
  FATHOM_CC_FLAGS
240 241
fi
if test "xno" != "x$CHECK_CXX"; then
's avatar
committed
242
  FATHOM_CXX_FLAGS
243 244
fi

245 246
# Try to determine compiler-specific flags.  This must be done
# before setting up libtool so that it can override libtool settings.
's avatar
committed
247 248
CFLAGS="$USER_CFLAGS $FATHOM_CC_SPECIAL"
CXXFLAGS="$USER_CXXFLAGS $FATHOM_CXX_SPECIAL"
249 250
FFLAGS="$USER_FFLAGS $FATHOM_F77_SPECIAL"
FCFLAGS="$USER_FCFLAGS $FATHOM_FC_SPECIAL"
251 252
FLIBS=""
FCLIBS=""
253 254 255

# Do enable_optimize by default, unless user has specified
# custom CXXFLAGS or CFLAGS
256
DEBUG=no
257
if (test "x$enable_debug" != "xyes"); then
258
  if (test "x$enable_optimize" == "x"); then
259 260 261
    enable_cxx_optimize=yes
    enable_cc_optimize=yes
    enable_fc_optimize=yes
262
  fi
263
fi
vijaysm's avatar
vijaysm committed
264
enable_f77_optimize=$enable_fc_optimize
265 266 267

# Choose compiler flags from CLI args
if test "xyes" = "x$enable_debug"; then
268
  DEBUG=yes
269
  CXXFLAGS="$CXXFLAGS -g"
270
  CFLAGS="$CFLAGS -g"
271
  if (test "x$CHECK_FC" != "xno"); then
272 273 274
    FCFLAGS="$FCFLAGS -g"
    FFLAGS="$FFLAGS -g"
  fi
275
  # Add -fstack-protector-all option for g++ in debug mode
276
  if (test "x$cxx_compiler" = "xGNU"); then
277 278
    CXXFLAGS="$CXXFLAGS -fstack-protector-all"
    CFLAGS="$CFLAGS -fstack-protector-all"
279 280 281 282 283
    LDFLAGS="$LDFLAGS -fstack-protector-all"
    if (test "x$CHECK_FC" != "xno"); then
      FCFLAGS="$FCFLAGS -fstack-protector-all"
      FFLAGS="$FFLAGS -fstack-protector-all"
    fi
284
  fi
285 286 287
  DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --enable-debug=yes"
else
  DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --enable-debug=no"
288
fi
289
if (test "xno" != "x$enable_cxx_optimize"); then
290
  CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
291 292 293
  DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --enable-optimize=yes"
else
  DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --enable-optimize=no"
294
fi
295
if (test "xno" != "x$enable_cc_optimize"); then
296 297
  CFLAGS="$CFLAGS -O2 -DNDEBUG"
fi
298
if (test "x$ENABLE_FORTRAN" != "xno"); then
299
  if (test "xno" != "x$enable_fc_optimize"); then
300 301
    FCFLAGS="$FCFLAGS -O2"
  fi
302
  if (test "xno" != "x$enable_f77_optimize"); then
303 304
    FFLAGS="$FFLAGS -O2"
  fi
305
  AC_FC_PP_DEFINE
306
fi
307

308 309
# Check for 32/64 bit.
# This requires FATHOM_CXX_FLAGS and FATHOM_CC_FLAGS to have been called first
310
AC_ARG_ENABLE(32bit, AS_HELP_STRING([--enable-32bit],[Force 32-bit objects]),
311
[
312
  if (test "xyes" != "x$enableval" && test "xno" != "x$enableval"); then
313 314
    AC_MSG_ERROR([Unknown argument --enable-32bit=$enableval])
  fi
315 316 317 318 319 320 321 322
  if (test "xno" != "x$enableval"); then
    if test "x" = "x$FATHOM_CXX_32BIT"; then
      AC_MSG_ERROR([Don't know how to force 32-bit C++ on this platform.  Try setting CXXFLAGS manually])
    elif test "x" = "x$FATHOM_CC_32BIT"; then
      AC_MSG_ERROR([Don't know how to force 32-bit C on this platform.  Try setting CFLAGS manually])
    fi
  fi
  enable_32bit=$enableval
323 324
], [enable_32bit=no])

's avatar
committed
325
# This requires FATHOM_CXX_FLAGS and FATHOM_CC_FLAGS to have been called first
326
AC_ARG_ENABLE(64bit, AS_HELP_STRING([--enable-64bit],[Force 64-bit objects]),
327
[
328
  if (test "xyes" != "x$enableval" && test "xno" != "x$enableval"); then
329 330
    AC_MSG_ERROR([Unknown argument --enable-64bit=$enableval])
  fi
331 332 333 334 335 336 337 338 339 340
  if (test "xno" != "x$enableval"); then
    if test "x" = "x$FATHOM_CXX_64BIT"; then
      AC_MSG_ERROR([Don't know how to force 64-bit C++ on this platform.  Try setting CXXFLAGS manually])
    elif test "x" = "x$FATHOM_CC_64BIT"; then
      AC_MSG_ERROR([Don't know how to force 64-bit C on this platform.  Try setting CFLAGS manually])
    elif test "xyes" = "x$enable_32bit"; then
      AC_MSG_ERROR([Cannot do both --enable-32bit and --enable-64bit])
    fi
  fi
  enable_64bit=$enableval
341 342
], [enable_64bit=no])

343
if (test "xno" != "x$enable_32bit"); then
344 345
  CXXFLAGS="$CXXFLAGS $FATHOM_CXX_32BIT"
  CFLAGS="$CFLAGS $FATHOM_CC_32BIT"
346
  LDFLAGS="$LDFLAGS $FATHOM_CC_32BIT"
347
fi
348
if (test "xno" != "x$enable_64bit"); then
's avatar
committed
349 350
  CXXFLAGS="$CXXFLAGS $FATHOM_CXX_64BIT"
  CFLAGS="$CFLAGS $FATHOM_CC_64BIT"
351
  LDFLAGS="$LDFLAGS $FATHOM_CC_64BIT"
352
fi
353 354
# Distcheck flags for 32-bit and 64-bit builds
DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --enable-32bit=$enable_32bit --enable-64bit=$enable_64bit"
355

356 357 358 359 360 361 362 363
# Check if platform is BlueGene
AC_MSG_CHECKING([if platform is IBM BlueGene])
FATHOM_TRY_COMPILER_DEFINE([__bg__],
  [MB_DEFS="$MB_DEFS -DBLUEGENE"
   MB_BLUEGENE_CONF=yes],
  [MB_BLUEGENE_CONF=no])
AC_MSG_RESULT([$MB_BLUEGENE_CONF])

364
# Special overrides flags for BG/Q
365
if (test "x$enable_static" != "xno" && test "x$MB_BLUEGENE_CONF" != "xno" && test "x$GXX" != "xyes"); then
vijaysm's avatar
vijaysm committed
366
  LDFLAGS="$LDFLAGS -qnostaticlink=libgcc"
367 368
fi

369
# Check if we are using new Darwin kernels with Clang -- needs libc++ instead of libstdc++
370
if (test "x$ENABLE_FORTRAN" != "xno" && test "x$CHECK_FC" != "xno"); then
371

372
  # check how to link against C++ runtime for fortran programs correctly
373
  AC_F77_MAIN
374
  AC_FC_MAIN
375
  FAC_FC_WRAPPERS
376
  fcxxlinkage=no
377 378 379 380 381 382 383 384 385

  # Check if we are on IBM ANL BG/Q system
  # Default location on Vesta/Mira: /soft/compilers/ibmcmp-feb2015/vacpp/bg/12.1/bglib64/libibmc++.a
  # Other location for stdc++ libraries: /bgsys/drivers/ppcfloor/gnu-linux/powerpc64-bgq-linux/lib/libstdc++.a
  case "`hostname`" in
    *vesta*)  LIBS="$LIBS /soft/compilers/ibmcmp-feb2015/vacpp/bg/12.1/bglib64/libibmc++.a"; fcxxlinkage=yes ;;
    *mira*)  LIBS="$LIBS /soft/compilers/ibmcmp-feb2015/vacpp/bg/12.1/bglib64/libibmc++.a"; fcxxlinkage=yes ;;
  esac

386
  if (test "$cxx_compiler" == "Intel"); then
387 388 389 390 391
    my_save_ldflags="$LDFLAGS"
    LDFLAGS="$LDFLAGS -cxxlib"
    AC_MSG_CHECKING([whether $FC supports -cxxlib])
    AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
        [AC_MSG_RESULT([yes])]
392
        [fcxxlinkage=yes; FFLAGS="$FFLAGS -cxxlib"; FCFLAGS="$FCFLAGS -cxxlib"; FLIBS="$FLIBS -cxxlib"; FCLIBS="$FCLIBS -cxxlib"],
393 394 395
        [AC_MSG_RESULT([no])]
    )
    LDFLAGS="$my_save_ldflags"
396
  elif (test "$cxx_compiler" == "PortlandGroup"); then
Fathom's avatar
Fathom committed
397
    my_save_ldflags="$LDFLAGS"
398 399
    LDFLAGS="$LDFLAGS -pgc++libs"
    AC_MSG_CHECKING([whether $FC supports -pgc++libs])
Fathom's avatar
Fathom committed
400 401
    AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
        [AC_MSG_RESULT([yes])]
402
        [fcxxlinkage=yes; FLIBS="$FLIBS -pgc++libs"; FCLIBS="$FCLIBS -pgc++libs"],
Fathom's avatar
Fathom committed
403 404 405
        [AC_MSG_RESULT([no])]
    )
    LDFLAGS="$my_save_ldflags"
406 407 408 409 410 411 412 413 414 415
    if (test "$fcxxlinkage" != "yes"); then
      LDFLAGS="$LDFLAGS -pgcpplibs -lstd -lC"
      AC_MSG_CHECKING([whether $FC supports -pgcpplibs -lstd -lC])
      AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
          [AC_MSG_RESULT([yes])]
          [fcxxlinkage=yes; FLIBS="$FLIBS -pgcpplibs -lstd -lC"; FCLIBS="$FCLIBS -pgcpplibs -lstd -lC"],
          [AC_MSG_RESULT([no])]
      )
      LDFLAGS="$my_save_ldflags"
    fi
416 417 418
  else

    if (test "$fcxxlinkage" != "yes"); then
419 420 421 422
      # With Clang compilers, we specifically look at two cases: OSX and Ubuntu
      # On OSX (Mavericks and beyond), -lc++ provides the standard C++ library definitions
      # But on Ubuntu, we need -lstdc++, so "fcxxlinkage" will not be set to "yes" below
      if (test "$cc_compiler" == "Clang"); then
vijaysm's avatar
vijaysm committed
423
        my_save_ldflags="$LDFLAGS"
424 425
        LDFLAGS="$LDFLAGS -lc++"
        AC_MSG_CHECKING([whether $FC supports -stdlib=libc++])
426 427
        AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
            [AC_MSG_RESULT([yes])]
428
            [fcxxlinkage=yes; FLIBS="$FLIBS -lc++"; FCLIBS="$FCLIBS -lc++"],
429 430
            [AC_MSG_RESULT([no])]
        )
vijaysm's avatar
vijaysm committed
431
        LDFLAGS="$my_save_ldflags"
432 433 434 435
      fi

      # GNU and other non-intel compilers will use the standard -lstdc++ linkage
      # This case also includes the Ubuntu+Clang combination as mentioned before
436
      if (test "$cxx_compiler" != "Clang" || test "$fcxxlinkage" != "yes"); then
vijaysm's avatar
vijaysm committed
437
        my_save_ldflags="$LDFLAGS"
438 439
        LDFLAGS="$LDFLAGS -lstdc++"
        AC_MSG_CHECKING([whether $FC supports -stdlib=libstdc++])
440 441
        AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
            [AC_MSG_RESULT([yes])]
442
            [fcxxlinkage=yes; FLIBS="$FLIBS -lstdc++"; FCLIBS="$FCLIBS -lstdc++"],
443 444
            [AC_MSG_RESULT([no])]
        )
vijaysm's avatar
vijaysm committed
445
        LDFLAGS="$my_save_ldflags"
446
      fi
447 448 449 450
    fi

  fi

451 452 453 454
  if (test "$fcxxlinkage" != "yes"); then
    AC_MSG_WARN([Unrecognized C++ linkage for C/Fortran programs])
  fi

455 456
fi

457 458 459
AC_SUBST(FLIBS)
AC_SUBST(FCLIBS)

's avatar
committed
460
]) # FATHOM_COMPILER_FLAGS
461 462 463 464 465 466 467 468 469 470 471 472 473 474

#######################################################################################
# *******************************************************************************
# **************************** INTERNAL STUFF ***********************************
# *******************************************************************************
#######################################################################################

#################################################################################
# Check if the compiler defines a specific preprocessor macro
# Arguments:
#  - preprocessor define to check for
#  - action upon success
#  - action upon failure
#################################################################################
's avatar
committed
475
AC_DEFUN([FATHOM_TRY_COMPILER_DEFINE], [
476 477 478 479 480
 AC_COMPILE_IFELSE([
 AC_LANG_PROGRAM( [[#ifndef $1
   choke me
 #endif]], []) ],
 [$2],[$3])
481 482
])

's avatar
committed
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
#################################################################################
# Check if the compiler defines a specific preprocessor macro with an integer
# value greater than or equal to the passed value
# Arguments:
#  - preprocessor define to check for
#  - numeric value to test
#  - action upon success
#  - action upon failure
#################################################################################
AC_DEFUN([FATHOM_TRY_COMPILER_DEFINE_GE], [
 AC_COMPILE_IFELSE([
 AC_LANG_PROGRAM( [[#if !defined($1) || $1 < $2
   choke me
 #endif]], []) ],
 [$3],[$4])
])

500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
# FAC_FC_NAME_MANGLING
# ---------------------
# Test for the name mangling scheme used by the Fortran compiler.
#
# Sets ac_cv_{f77,fc}_mangling. The value contains three fields, separated
# by commas:
#
# lower case / upper case:
#    case translation of the Fortran symbols
# underscore / no underscore:
#    whether the compiler appends "_" to symbol names
# extra underscore / no extra underscore:
#    whether the compiler appends an extra "_" to symbol names already
#    containing at least one underscore
#
AC_DEFUN([FAC_FC_NAME_MANGLING],
[_AC_FORTRAN_ASSERT()dnl
AC_CACHE_CHECK([for Fortran name-mangling scheme],
               ac_cv_[]_AC_LANG_ABBREV[]_mangling,
[AC_COMPILE_IFELSE(
[      subroutine foobar()
      return
      end
      subroutine foo_bar()
      return
      end],
[mv conftest.$ac_objext cfortran_test.$ac_objext

  ac_save_LIBS=$LIBS
529
  LIBS="cfortran_test.$ac_objext $LIBS $[]_AC_LANG_PREFIX[]LIBS $ac_cv_fc_libs"
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594

  AC_LANG_PUSH(C)dnl
  ac_success=no
  for ac_foobar in foobar FOOBAR; do
    for ac_underscore in "" "_"; do
      ac_func="$ac_foobar$ac_underscore"
      AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
         [ac_success=yes; break 2])
    done
  done
  AC_LANG_POP(C)dnl

  if test "$ac_success" = "yes"; then
     case $ac_foobar in
  foobar)
     ac_case=lower
     ac_foo_bar=foo_bar
     ;;
  FOOBAR)
     ac_case=upper
     ac_foo_bar=FOO_BAR
     ;;
     esac

     AC_LANG_PUSH(C)dnl
     ac_success_extra=no
     for ac_extra in "" "_"; do
  ac_func="$ac_foo_bar$ac_underscore$ac_extra"
  AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
           [ac_success_extra=yes; break])
     done
     AC_LANG_POP(C)dnl

     if test "$ac_success_extra" = "yes"; then
  ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_case case"
        if test -z "$ac_underscore"; then
           ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no underscore"
  else
           ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, underscore"
        fi
        if test -z "$ac_extra"; then
           ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no extra underscore"
  else
           ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, extra underscore"
        fi
      else
  ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
      fi
  else
     ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
  fi

  LIBS=$ac_save_LIBS
  rm -f cfortran_test* conftest*],
  [AC_MSG_FAILURE([cannot compile a simple Fortran program])])
])
])# FAC_FC_NAME_MANGLING

# FAC_FC_WRAPPERS
# ---------------
# Defines C macros {F77,FC}_FUNC(name,NAME) and {F77,FC}_FUNC_(name,NAME) to
# properly mangle the names of C identifiers, and C identifiers with
# underscores, respectively, so that they match the name mangling
# scheme used by the Fortran compiler.
AC_DEFUN([FAC_FC_WRAPPERS],
595 596 597
[
AC_LANG_PUSH([Fortran])
_AC_FORTRAN_ASSERT()dnl
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
FAC_FC_NAME_MANGLING
AH_TEMPLATE(_AC_FC[_FUNC],
    [Define to a macro mangling the given C identifier (in lower and upper
     case), which must not contain underscores, for linking with Fortran.])dnl
AH_TEMPLATE(_AC_FC[_FUNC_],
    [As ]_AC_FC[_FUNC, but for C identifiers containing underscores.])dnl
case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
  "lower case, no underscore, no extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name]) ;;
  "lower case, no underscore, extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
  "lower case, underscore, no extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name ## _])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
  "lower case, underscore, extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name ## _])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __]) ;;
  "upper case, no underscore, no extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME]) ;;
  "upper case, no underscore, extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
  "upper case, underscore, no extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME ## _])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
  "upper case, underscore, extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME ## _])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __]) ;;
  *)
          AC_MSG_WARN([unknown Fortran name-mangling scheme])
          ;;
esac
633
AC_LANG_POP([Fortran])
634
])# FAC_FC_WRAPPERS
635 636 637 638

#######################################################################################
# Check for compiler-specific flags.
# Sets the following environmental variables:
's avatar
committed
639 640 641
#   FATHOM_CXX_SPECIAL : Any compiler-specific flags which must be specified
#   FATHOM_CXX_32BIT   : Flag to force compilation of 32-bit code
#   FATHOM_CXX_64BIT   : Flag to force compilation of 64-bit code
642
#######################################################################################
's avatar
committed
643
AC_DEFUN([FATHOM_CXX_FLAGS], [
644
AC_LANG_PUSH([C++])
645 646 647 648 649 650

# Detect compiler 
AC_MSG_CHECKING([for known c++ compilers])
# Autoconf does G++ for us
if test x$GXX = xyes; then
  cxx_compiler=GNU
651
  # Intel and Clang claims to be GCC, check for it here
's avatar
committed
652
  FATHOM_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cxx_compiler=Intel])
653
  FATHOM_TRY_COMPILER_DEFINE([__clang__],[cxx_compiler=Clang])
654
  FATHOM_TRY_COMPILER_DEFINE([__PGI],[cxx_compiler=PortlandGroup])
655 656 657 658 659 660
# Search for other compiler types
# For efficiency, limit checks to relevant OSs
else
  cxx_compiler=unknown
  case "$target_os" in
    aix*)
's avatar
committed
661
      FATHOM_TRY_COMPILER_DEFINE_GE([__IBMCPP__],[800],[cxx_compiler=VisualAge8],
's avatar
committed
662
        [FATHOM_TRY_COMPILER_DEFINE([__IBMCPP__],[cxx_compiler=VisualAge])])
663 664
      ;;
    solaris*|sunos*)
's avatar
committed
665
      FATHOM_TRY_COMPILER_DEFINE([__SUNPRO_CC],[cxx_compiler=SunWorkshop])
666
      ;;
667 668 669
    darwin*)
      FATHOM_TRY_COMPILER_DEFINE([__clang__],[cxx_compiler=Clang])
      ;;
670
    irix*)
's avatar
committed
671
      FATHOM_TRY_COMPILER_DEFINE([__sgi],[cxx_compiler=MIPSpro])
672 673
      ;;
    linux*)
's avatar
committed
674
      FATHOM_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cxx_compiler=Intel])
's avatar
committed
675 676
      FATHOM_TRY_COMPILER_DEFINE_GE([__IBMCPP__],[800],[cxx_compiler=VisualAge8],
        [FATHOM_TRY_COMPILER_DEFINE([__IBMCPP__],[cxx_compiler=VisualAge])])
's avatar
committed
677 678
      FATHOM_TRY_COMPILER_DEFINE([__DECCXX_VER],[cxx_compiler=Compaq])
      FATHOM_TRY_COMPILER_DEFINE([__SUNPRO_CC],[cxx_compiler=SunWorkshop])
679
      FATHOM_TRY_COMPILER_DEFINE([__PGI],[cxx_compiler=PortlandGroup])
680 681
      ;;
    hpux*)
's avatar
committed
682
      FATHOM_TRY_COMPILER_DEFINE([__HP_aCC],[cxx_compiler=HP])
683 684
      ;;
    windows*)
's avatar
committed
685 686 687 688 689 690
      FATHOM_TRY_COMPILER_DEFINE([__MSC_VER],[cxx_compiler=VisualStudio])
      FATHOM_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cxx_compiler=Intel])
      FATHOM_TRY_COMPILER_DEFINE([__DECCXX_VER],[cxx_compiler=Compaq])
      FATHOM_TRY_COMPILER_DEFINE([__BORLANDC__],[cxx_compiler=Borland])
      FATHOM_TRY_COMPILER_DEFINE([__CYGWIN__],[cxx_compiler=Cygwin])
      FATHOM_TRY_COMPILER_DEFINE([__MINGW32__],[cxx_compiler=MinGW])
691 692
      ;;
    *)
693
      FATHOM_TRY_COMPILER_DEFINE([__PGI],[cxx_compiler=PortlandGroup])
694 695 696
      ;;
  esac
fi
697 698

AC_LANG_POP([C++])
699 700 701 702 703 704
AC_MSG_RESULT([$cxx_compiler])
if test "x$cxx_compiler" = "xunknown"; then
  AC_MSG_WARN([Unrecognized C++ compiler: $CXX])
fi

# Now decide special compiler flags using compiler/cpu combination
705
AC_MSG_CHECKING([for known compiler/CPU/OS combinations])
706 707
case "$cxx_compiler:$host_cpu" in
  GNU:sparc*)
's avatar
committed
708 709
    FATHOM_CXX_32BIT=-m32
    FATHOM_CXX_64BIT=-m64
710
    FATHOM_CXX_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
711 712
    ;;
  GNU:powerpc*)
's avatar
committed
713 714
    FATHOM_CXX_32BIT=-m32
    FATHOM_CXX_64BIT=-m64
715
    FATHOM_CXX_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
716 717
    ;;
  GNU:i?86|GNU:x86_64)
's avatar
committed
718 719
    FATHOM_CXX_32BIT=-m32
    FATHOM_CXX_64BIT=-m64
720
    FATHOM_CXX_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
721 722
    ;;
  GNU:mips*)
's avatar
committed
723 724
    FATHOM_CXX_32BIT="-mips32 -mabi=32"
    FATHOM_CXX_64BIT="-mips64 -mabi=64"
725
    FATHOM_CXX_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
726 727
    ;;
  GNU:*)
728
    FATHOM_CXX_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
729
    ;;
730
  Intel:*)
's avatar
committed
731 732
    FATHOM_CXX_32BIT=-m32
    FATHOM_CXX_64BIT=-m64
733
    FATHOM_CXX_SPECIAL="$EXTRA_INTEL_CXXFLAGS -wd981 -wd279 -wd1418 -wd383 -wd1572 -wd2259"
734
    ;;
735
  VisualAge:*)
's avatar
committed
736 737
    FATHOM_CXX_32BIT=-q32
    FATHOM_CXX_64BIT=-q64
vijaysm's avatar
vijaysm committed
738
    FATHOM_CXX_SPECIAL="$EXTRA_BG_CXXFLAGS -qminimaltoc -qmaxmem=-1 -qlanglvl=variadictemplates"
739
    AR="ar"
's avatar
committed
740 741 742 743 744
    NM="nm -B -X 32_64"
    ;;
  VisualAge8:*)
    FATHOM_CXX_32BIT=-q32
    FATHOM_CXX_64BIT=-q64
vijaysm's avatar
vijaysm committed
745
    FATHOM_CXX_SPECIAL="$EXTRA_BG_CXXFLAGS -qminimaltoc -qmaxmem=-1 -qlanglvl=variadictemplates"
's avatar
committed
746
    NM="nm -B -X 32_64"
747 748
    ;;
  MIPSpro:mips)
's avatar
committed
749 750 751
    FATHOM_CXX_32BIT=-n32
    FATHOM_CXX_64BIT=-64
    FATHOM_CXX_SPECIAL=-LANG:std
752 753
    ;;
  MIPSpro:*)
's avatar
committed
754
    FATHOM_CXX_SPECIAL=-LANG:std
755 756
    ;;
  SunWorkshop:sparc*)
's avatar
committed
757 758
    FATHOM_CXX_32BIT=-xarch=generic
    FATHOM_CXX_64BIT=-xarch=generic64
759
    ;;
Fathom's avatar
Fathom committed
760 761 762
  PortlandGroup:*)
    FATHOM_CXX_SPECIAL="$EXTRA_PGI_CXXFLAGS"
    ;;
763
  Clang:*)
vijaysm's avatar
vijaysm committed
764
    FATHOM_CXX_SPECIAL="$EXTRA_CLANG_CXXFLAGS"
765 766
    FATHOM_CXX_32BIT=-m32
    FATHOM_CXX_64BIT=-m64
767
    ;;
768
  SunWorkshop:i?86|SunWorkshop:x86_64)
's avatar
committed
769 770
    FATHOM_CXX_32BIT=-m32
    FATHOM_CXX_64BIT=-m64
771 772 773 774
    ;;
  *)
    ;;
esac
775
AC_MSG_RESULT([$cxx_compiler:$host_os:$host_cpu])
776 777

# Check for specific overrides
778
CXX_LDFLAGS=""
779
if (test "$cxx_compiler:${host_os:0:6}" == "Clang:darwin"); then
780
  CXX_LDFLAGS="$CXX_LDFLAGS -stdlib=libc++"
781 782
  LIBS="$LIBS -lc++"
fi
783 784
AC_SUBST(CXX_LDFLAGS)

's avatar
committed
785
]) # end FATHOM_CXX_FLAGS
786 787 788 789

#######################################################################################
# Check for compiler-specific flags.
# Sets the following environmental variables:
's avatar
committed
790 791 792
#   FATHOM_CC_SPECIAL : Any compiler-specific flags which must be specified
#   FATHOM_CC_32BIT   : Flag to force compilation of 32-bit code
#   FATHOM_CC_64BIT   : Flag to force compilation of 64-bit code
793
#######################################################################################
's avatar
committed
794
AC_DEFUN([FATHOM_CC_FLAGS], [
795
AC_LANG_PUSH([C])
796 797 798 799 800 801 802

# Detect compiler 

AC_MSG_CHECKING([for known C compilers])
# Autoconf does gcc for us
if test x$GCC = xyes; then
  cc_compiler=GNU
803
  # Intel claims to be GCC, check for it here
's avatar
committed
804
  FATHOM_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cc_compiler=Intel])
805
  FATHOM_TRY_COMPILER_DEFINE([__clang__],[cc_compiler=Clang])
806
  FATHOM_TRY_COMPILER_DEFINE([__PGI],[cc_compiler=PortlandGroup])
807 808 809 810 811 812
# Search for other compiler types
# For efficiency, limit checks to relevant OSs
else
  cc_compiler=unknown
  case "$target_os" in
    aix*)
's avatar
committed
813
      FATHOM_TRY_COMPILER_DEFINE([__IBMC__],[cc_compiler=VisualAge])
814 815
      ;;
    solaris*|sunos*)
's avatar
committed
816
      FATHOM_TRY_COMPILER_DEFINE([__SUNPRO_C],[cc_compiler=SunWorkshop])
817
      ;;
818 819 820
    darwin*)
      FATHOM_TRY_COMPILER_DEFINE([__clang__],[cc_compiler=Clang])
      ;;
821
    irix*)
's avatar
committed
822
      FATHOM_TRY_COMPILER_DEFINE([__sgi],[cc_compiler=MIPSpro])
823 824
      ;;
    linux*)
's avatar
committed
825 826 827 828
      FATHOM_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cc_compiler=Intel])
      FATHOM_TRY_COMPILER_DEFINE([__IBMC__],[cc_compiler=VisualAge])
      FATHOM_TRY_COMPILER_DEFINE([__DECC_VER],[cc_compiler=Compaq])
      FATHOM_TRY_COMPILER_DEFINE([__SUNPRO_C],[cc_compiler=SunWorkshop])
829
      FATHOM_TRY_COMPILER_DEFINE([__PGI],[cc_compiler=PortlandGroup])
830 831
      ;;
    hpux*)
's avatar
committed
832
      FATHOM_TRY_COMPILER_DEFINE([__HP_cc],[cc_compiler=HP])
833 834
      ;;
    windows*)
's avatar
committed
835 836 837 838 839 840 841
      FATHOM_TRY_COMPILER_DEFINE([__MSC_VER],[cc_compiler=VisualStudio])
      FATHOM_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cc_compiler=Intel])
      FATHOM_TRY_COMPILER_DEFINE([__DECC_VER],[cc_compiler=Compaq])
      FATHOM_TRY_COMPILER_DEFINE([__BORLANDC__],[cc_compiler=Borland])
      FATHOM_TRY_COMPILER_DEFINE([__TURBOC__],[cc_compiler=TurboC])
      FATHOM_TRY_COMPILER_DEFINE([__CYGWIN__],[cc_compiler=Cygwin])
      FATHOM_TRY_COMPILER_DEFINE([__MINGW32__],[cc_compiler=MinGW])
842 843
      ;;
    *)
844
      FATHOM_TRY_COMPILER_DEFINE([__PGI],[cc_compiler=PortlandGroup])
845 846 847
      ;;
  esac
fi
848
AC_LANG_POP([C])
849 850 851 852 853 854 855 856 857
AC_MSG_RESULT([$cc_compiler])
if test "x$cc_compiler" = "xunknown"; then
  AC_MSG_WARN([Unrecognized C compiler: $CXX])
fi

# Now decide special compiler flags using compiler/cpu combination
AC_MSG_CHECKING([for known compiler/OS combinations])
case "$cc_compiler:$host_cpu" in
  GNU:sparc*)
's avatar
committed
858 859
    FATHOM_CC_32BIT=-m32
    FATHOM_CC_64BIT=-m64
860 861
    FATHOM_CC_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
    FATHOM_FC_SPECIAL="$EXTRA_GNU_ONLY_FCFLAGS"
Fathom's avatar
Fathom committed
862
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
863 864
    ;;
  GNU:powerpc*)
's avatar
committed
865 866
    FATHOM_CC_32BIT=-m32
    FATHOM_CC_64BIT=-m64
867 868
    FATHOM_CC_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
    FATHOM_FC_SPECIAL="$EXTRA_GNU_ONLY_FCFLAGS"
Fathom's avatar
Fathom committed
869
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
870 871
    ;;
  GNU:i?86|GNU:x86_64)
's avatar
committed
872 873
    FATHOM_CC_32BIT=-m32
    FATHOM_CC_64BIT=-m64
874 875
    FATHOM_CC_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
    FATHOM_FC_SPECIAL="$EXTRA_GNU_ONLY_FCFLAGS"
Fathom's avatar
Fathom committed
876
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
877
    ;;
878
  GNU:mips*)
's avatar
committed
879 880
    FATHOM_CC_32BIT="-mips32 -mabi=32"
    FATHOM_CC_64BIT="-mips64 -mabi=64"
881 882
    FATHOM_CC_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
    FATHOM_FC_SPECIAL="$EXTRA_GNU_ONLY_FCFLAGS"
Fathom's avatar
Fathom committed
883
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
884 885
    ;;
  GNU:*)
886 887
    FATHOM_CC_SPECIAL="$EXTRA_GNU_ONLY_CXXFLAGS"
    FATHOM_FC_SPECIAL="$EXTRA_GNU_ONLY_FCFLAGS"
Fathom's avatar
Fathom committed
888
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
889 890 891 892 893 894
    ;;
  Intel:*)
    FATHOM_CC_32BIT=-m32
    FATHOM_CC_64BIT=-m64
    FATHOM_CC_SPECIAL="$EXTRA_INTEL_CXXFLAGS -wd981 -wd279 -wd1418 -wd383 -wd1572"
    FATHOM_FC_SPECIAL="$EXTRA_INTEL_FCFLAGS"
Fathom's avatar
Fathom committed
895
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
896 897
    ;;
  VisualAge:*)
898 899
    case "$target_vendor" in
      bgp)
's avatar
committed
900
        FATHOM_CC_32BIT=-q32
901 902 903
        FATHOM_CC_64BIT=-q64
        AR="ar"
        NM="nm -B"
Rajeev Jain's avatar
Rajeev Jain committed
904 905 906
        ;;
      bgq)
        FATHOM_CC_32BIT=-q32
's avatar
committed
907
        FATHOM_CC_64BIT=-q64
908 909
        FATHOM_CC_SPECIAL="$EXTRA_BG_CXXFLAGS -qmaxmem=-1 -qminimaltoc"
        FATHOM_FC_SPECIAL="$EXTRA_BG_FCFLAGS -qnoescape -WF,-C! -qddim -qalias=intptr"
Fathom's avatar
Fathom committed
910
        FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
911 912 913 914
        AR="ar"
        NM="nm -B"
        ;;
      *)
's avatar
committed
915 916
        FATHOM_CC_32BIT=-q32
        FATHOM_CC_64BIT=-q64
917 918
        FATHOM_CC_SPECIAL="$EXTRA_BG_CXXFLAGS -qmaxmem=-1 -qminimaltoc"
        FATHOM_FC_SPECIAL="$EXTRA_BG_FCFLAGS -qnoescape -WF,-C! -qddim -qalias=intptr"
Fathom's avatar
Fathom committed
919
        FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
920
        AR="ar"
921 922 923
        NM="nm -B -X 32_64"
        ;;
    esac
924 925
    ;;
  MIPSpro:mips)
's avatar
committed
926 927 928
    FATHOM_CC_32BIT=-n32
    FATHOM_CC_64BIT=-64
    FATHOM_CC_SPECIAL=-LANG:std
929
    FATHOM_FC_SPECIAL=-LANG:std
Fathom's avatar
Fathom committed
930
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
931 932
    ;;
  MIPSpro:*)
's avatar
committed
933
    FATHOM_CC_SPECIAL=-LANG:std
934
    FATHOM_FC_SPECIAL=-LANG:std
Fathom's avatar
Fathom committed
935
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
936
    ;;
Fathom's avatar
Fathom committed
937 938
  PortlandGroup:*)
    FATHOM_CC_SPECIAL="-traceback -C"
Fathom's avatar
Fathom committed
939 940
    FATHOM_FC_SPECIAL="$EXTRA_PGI_FCFLAGS $EXTRA_PGI_ONLY_FCFLAGS"
    FATHOM_F77_SPECIAL="$EXTRA_PGI_FCFLAGS"
Fathom's avatar
Fathom committed
941
    ;;
942
  Clang:*)
vijaysm's avatar
vijaysm committed
943 944
    FATHOM_CC_SPECIAL="$EXTRA_CLANG_CXXFLAGS"
    FATHOM_FC_SPECIAL="$EXTRA_CLANG_FCFLAGS"
Fathom's avatar
Fathom committed
945
    FATHOM_F77_SPECIAL="$FATHOM_FC_SPECIAL"
946 947
    FATHOM_CC_32BIT=-m32
    FATHOM_CC_64BIT=-m64
948
    ;;
949
  SunWorkshop:sparc*)
's avatar
committed
950 951
    FATHOM_CC_32BIT=-xarch=generic
    FATHOM_CC_64BIT=-xarch=generic64
952 953
    ;;
  SunWorkshop:i?86|SunWorkshop:x86_64)
's avatar
committed
954 955
    FATHOM_CC_32BIT=-m32
    FATHOM_CC_64BIT=-m64
956 957 958 959 960
    ;;
  *)
    ;;
esac
AC_MSG_RESULT([$cc_compiler:$host_cpu])
961

's avatar
committed
962
]) # end FATHOM_CC_FLAGS
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006


#######################################################################################
# Check for Fortran compiler-specific flags.
#######################################################################################

dnl PAC_PROG_F77_CRAY_POINTER - Check if Fortran 77 supports Cray-style pointer.
dnl                             If so, set pac_cv_prog_f77_has_pointer to yes
dnl                             and find out if any extra compiler flag is
dnl                             needed and set it as CRAYPTR_FFLAGS.
dnl                             i.e. CRAYPTR_FFLAGS is meaningful only if
dnl                             pac_cv_prog_f77_has_pointer = yes.
dnl
dnl Synopsis:
dnl   PAC_PROG_F77_CRAY_POINTER([action-if-true],[action-if-false])
dnl D*/
AC_DEFUN([PAC_PROG_F77_CRAY_POINTER],[
AC_CACHE_CHECK([whether Fortran 77 supports Cray-style pointer],
pac_cv_prog_f77_has_pointer,[
AC_LANG_PUSH([Fortran 77])
AC_LANG_CONFTEST([
    AC_LANG_PROGRAM([],[
        integer M
        pointer (MPTR,M)
        data MPTR/0/
    ])
])
saved_FFLAGS="$FFLAGS"
pac_cv_prog_f77_has_pointer=no
CRAYPTR_FFLAGS=""
for ptrflag in '' '-fcray-pointer' ; do
    FFLAGS="$saved_FFLAGS $ptrflag"
    AC_COMPILE_IFELSE([], [
        pac_cv_prog_f77_has_pointer=yes
        CRAYPTR_FFLAGS="$ptrflag"
        break
    ])
done
dnl Restore FFLAGS first, since user may not want to modify FFLAGS
FFLAGS="$saved_FFLAGS"
dnl remove conftest after ac_lang_conftest
rm -f conftest.$ac_ext
AC_LANG_POP([Fortran 77])
])
1007

1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
if test "$pac_cv_prog_f77_has_pointer" = "yes" ; then
    AC_MSG_CHECKING([for Fortran 77 compiler flag for Cray-style pointer])
    if test "X$CRAYPTR_FFLAGS" != "X" ; then
        AC_MSG_RESULT([$CRAYPTR_FFLAGS])
    else
        AC_MSG_RESULT([none])
    fi
    ifelse([$1],[],[:],[$1])
else
    ifelse([$2],[],[:],[$2])
fi
])

dnl PAC_PROG_FC_CRAY_POINTER - Check if Fortran supports Cray-style pointer.
dnl                            If so, set pac_cv_prog_fc_has_pointer to yes
dnl                            and find out if any extra compiler flag is
dnl                            needed and set it as CRAYPTR_FCFLAGS.
dnl                            i.e. CRAYPTR_FCFLAGS is meaningful only if
dnl                            pac_cv_prog_fc_has_pointer = yes.
dnl
dnl Synopsis:
dnl   PAC_PROG_FC_CRAY_POINTER([action-if-true],[action-if-false])
dnl D*/
AC_DEFUN([PAC_PROG_FC_CRAY_POINTER],[
AC_CACHE_CHECK([whether Fortran 90 supports Cray-style pointer],
pac_cv_prog_fc_has_pointer,[
AC_LANG_PUSH([Fortran])
AC_LANG_CONFTEST([
    AC_LANG_PROGRAM([],[
        integer M
        pointer (MPTR,M)
        data MPTR/0/
    ])
])
saved_FCFLAGS="$FCFLAGS"
pac_cv_prog_fc_has_pointer=no
CRAYPTR_FCFLAGS=""
for ptrflag in '' '-fcray-pointer' ; do
    FCFLAGS="$saved_FCFLAGS $ptrflag"
    AC_COMPILE_IFELSE([],[
        pac_cv_prog_fc_has_pointer=yes
        CRAYPTR_FCFLAGS="$ptrflag"
        break
    ])
done
1053

1054 1055 1056 1057 1058 1059
dnl Restore FCFLAGS first, since user may not want to modify FCFLAGS
FCFLAGS="$saved_FCFLAGS"
dnl remove conftest after ac_lang_conftest
rm -f conftest.$ac_ext
AC_LANG_POP([Fortran])
])
1060

1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
if test "$pac_cv_prog_fc_has_pointer" = "yes" ; then
    AC_MSG_CHECKING([for Fortran 90 compiler flag for Cray-style pointer])
    if test "X$CRAYPTR_FCFLAGS" != "X" ; then
        AC_MSG_RESULT([$CRAYPTR_FCFLAGS])
    else
        AC_MSG_RESULT([none])
    fi
    ifelse([$1],[],[:],[$1])
else
    ifelse([$2],[],[:],[$2])
fi