📄 aclangf90.m4
字号:
# This file is part of Autoconf. -*- Autoconf -*-# Programming languages support.# Copyright 2000, 2001# Free Software Foundation, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA# 02111-1307, USA.## As a special exception, the Free Software Foundation gives unlimited# permission to copy, distribute and modify the configure scripts that# are the output of Autoconf. You need not follow the terms of the GNU# General Public License when using or distributing such scripts, even# though portions of the text of Autoconf appear in them. The GNU# General Public License (GPL) does govern all other use of the material# that constitutes the Autoconf program.## Certain portions of the Autoconf source text are designed to be copied# (in certain cases, depending on the input) into the output of# Autoconf. We call these the "data" portions. The rest of the Autoconf# source text consists of comments plus executable code that decides which# of the data portions to output in any given case. We call these# comments and executable code the "non-data" portions. Autoconf never# copies any of the non-data portions into its output.## This special exception to the GPL applies to versions of Autoconf# released by the Free Software Foundation. When you make and# distribute a modified version of Autoconf, you may extend this special# exception to the GPL to apply to your modified version as well, *unless*# your modified version has the potential to copy into its output some# of the text that was the non-data portion of the version that you started# with. (In other words, unless your change moves or copies text from# the non-data portions to the data portions.) If your modification has# such potential, you must delete any notice of this special exception# to the GPL from your modified version.## Written by David MacKenzie, with help from# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,# Roland McGrath, Noah Friedman, david d zuhn, and many others.### This file was created from aclang.m4, from the autoconf 2.52 distribution# It contains modifications that are specific to Fortran 90 support,# needed to support systems that wish to use separate Fortran compilers # for Fortran 77 and Fortran 90 programs.# Fortran 90 part written by William Gropp. ### ----------------------- #### 1. Language selection. #### ----------------------- ### ----------------------------- ## 1e. The Fortran 90 language. ## ----------------------------- ## AC_LANG(Fortran 90)# -------------------m4_define([AC_LANG(Fortran 90)],[ac_ext=${ac_f90ext-f}ac_compile='$F90 -c $F90FLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'ac_link='$F90 -o conftest$ac_exeext $F90FLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'ac_compiler_gnu=$ac_cv_f90_compiler_gnu])# AC_LANG_FORTRAN90# -----------------AU_DEFUN([AC_LANG_FORTRAN90], [AC_LANG(Fortran 90)])# _AC_LANG_ABBREV(Fortran 90)# ---------------------------m4_define([_AC_LANG_ABBREV(Fortran 90)], [f90])## ---------------------- #### 2.Producing programs. #### ---------------------- ### ------------------------ ## 2e. Fortran 90 sources. ## ------------------------ ## AC_LANG_SOURCE(Fortran 90)(BODY)# --------------------------------# FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP# directives must not be included. But AC_TRY_RUN_NATIVE was not# avoiding them, so?m4_define([AC_LANG_SOURCE(Fortran 90)],[$1])# AC_LANG_PROGRAM(Fortran 90)([PROLOGUE], [BODY])# -----------------------------------------------# Yes, we discard the PROLOGUE.m4_define([AC_LANG_PROGRAM(Fortran 90)],[m4_ifval([$1], [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl program main$2 end])# AC_LANG_CALL(Fortran 90)(PROLOGUE, FUNCTION)# --------------------------------------------# FIXME: This is a guess, help!m4_define([AC_LANG_CALL(Fortran 90)],[AC_LANG_PROGRAM([$1],[ call $2])])## -------------------------------------------- #### 3. Looking for Compilers and Preprocessors. #### -------------------------------------------- ### ----------------------------- ## 3e. The Fortran 90 compiler. ## ----------------------------- ## AC_LANG_PREPROC(Fortran 90)# ---------------------------# Find the Fortran 90 preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.AC_DEFUN([AC_LANG_PREPROC(Fortran 90)],[m4_warn([syntax], [$0: No preprocessor defined for ]_AC_LANG)])# AC_LANG_COMPILER(Fortran 90)# ----------------------------# Find the Fortran 90 compiler. Must be AC_DEFUN'd to be# AC_REQUIRE'able.AC_DEFUN([AC_LANG_COMPILER(Fortran 90)],[AC_REQUIRE([AC_PROG_F90])])# ac_cv_prog_g90# --------------# We used to name the cache variable this way.AU_DEFUN([ac_cv_prog_g90],[ac_cv_f90_compiler_gnu])# AC_PROG_F90([COMPILERS...])# ---------------------------# COMPILERS is a space separated list of Fortran 90 compilers to search# for.## Compilers are ordered by# 1. F95, F90# 2. Good/tested native compilers, bad/untested native compilers## frt is the Fujitsu Fortran compiler.# pgf90 is the Portland Group F90 compilers.# xlf90/xlf95 are IBM (AIX) F90/F95 compilers.# lf95 is the Lahey-Fujitsu compiler.# fl32 is the Microsoft Fortran "PowerStation" compiler.# epcf90 is the "Edinburgh Portable Compiler" F90.# fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha.AC_DEFUN([AC_PROG_F90],[AC_LANG_PUSH(Fortran 90)dnlAC_ARG_VAR([F90], [Fortran 90 compiler command])dnlAC_ARG_VAR([F90FLAGS], [Fortran 90 compiler flags])dnl_AC_ARG_VAR_LDFLAGS()dnlAC_CHECK_TOOLS(F90, [m4_default([$1], [f95 f90 pgf90 epcf90 fort xlf95 xlf90 xlf lf95 g95 fc])])# Provide some information about the compiler.echo "$as_me:__oline__:" \ "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FDac_compiler=`set X $ac_compile; echo $[2]`_AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])_AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])_AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])m4_expand_once([_AC_COMPILER_EXEEXT])[]dnlm4_expand_once([_AC_COMPILER_OBJEXT])[]dnl# If we don't use `.F' as extension, the preprocessor is not run on the# input file.ac_save_ext=$ac_extac_ext=F_AC_LANG_COMPILER_GNUac_ext=$ac_save_extG90=`test $ac_compiler_gnu = yes && echo yes`_AC_PROG_F90_GAC_LANG_POP(Fortran 90)dnl])# AC_PROG_F90# _AC_PROG_F90_G# --------------# Check whether -g works, even if F90FLAGS is set, in case the package# plays around with F90FLAGS (such as to build both debugging and normal# versions of a library), tasteless as that idea is.m4_define([_AC_PROG_F90_G],[ac_test_F90FLAGS=${F90FLAGS+set}ac_save_F90FLAGS=$F90FLAGSF90FLAGS=AC_CACHE_CHECK(whether $F90 accepts -g, ac_cv_prog_f90_g,[F90FLAGS=-g_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[ac_cv_prog_f90_g=yes],[ac_cv_prog_f90_g=no])])if test "$ac_test_F90FLAGS" = set; then F90FLAGS=$ac_save_F90FLAGSelif test $ac_cv_prog_f90_g = yes; then if test "$G95" = yes; then F90FLAGS="-g -O2" else F90FLAGS="-g" fielse if test "$G95" = yes; then F90FLAGS="-O2" else F90FLAGS= fifi[]dnl])# _AC_PROG_F90_G# AC_PROG_F90_C_O# ---------------# Test if the Fortran 90 compiler accepts the options `-c' and `-o'# simultaneously, and define `F90_NO_MINUS_C_MINUS_O' if it does not.## The usefulness of this macro is questionable, as I can't really see# why anyone would use it. The only reason I include it is for# completeness, since a similar test exists for the C compiler.AC_DEFUN([AC_PROG_F90_C_O],[AC_REQUIRE([AC_PROG_F90])dnlAC_CACHE_CHECK([whether $F90 understand -c and -o together], [ac_cv_prog_f90_c_o],[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])# We test twice because some compilers refuse to overwrite an existing# `.o' file with `-o', although they will create one.ac_try='$F90 $F90FLAGS -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'if AC_TRY_EVAL(ac_try) && test -f conftest.$ac_objext && AC_TRY_EVAL(ac_try); then ac_cv_prog_f90_c_o=yeselse ac_cv_prog_f90_c_o=nofirm -f conftest*])if test $ac_cv_prog_f90_c_o = no; then AC_DEFINE(F90_NO_MINUS_C_MINUS_O, 1, [Define if your Fortran 90 compiler doesn't accept -c and -o together.])fi])# AC_PROG_F90_C_O## ------------------------------- #### 4. Compilers' characteristics. #### ------------------------------- ### ---------------------------------------- ## 4d. Fortan 90 compiler characteristics. ## ---------------------------------------- ## _AC_PROG_F90_V_OUTPUT([FLAG = $ac_cv_prog_f90_v])# -------------------------------------------------# Link a trivial Fortran program, compiling with a verbose output FLAG# (which default value, $ac_cv_prog_f90_v, is computed by# _AC_PROG_F90_V), and return the output in $ac_f90_v_output. This# output is processed in the way expected by AC_F90_LIBRARY_LDFLAGS,# so that any link flags that are echoed by the compiler appear as# space-separated items.AC_DEFUN([_AC_PROG_F90_V_OUTPUT],[AC_REQUIRE([AC_PROG_F90])dnlAC_LANG_PUSH(Fortran 90)dnlAC_LANG_CONFTEST([AC_LANG_PROGRAM([])])# Compile and link our simple test program by passing a flag (argument# 1 to this macro) to the Fortran 90 compiler in order to get# "verbose" output that we can then parse for the Fortran 90 linker# flags.ac_save_F90FLAGS=$F90FLAGSF90FLAGS="$F90FLAGS m4_default([$1], [$ac_cv_prog_f90_v])"(eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FDac_f90_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`echo "$ac_f90_v_output" >&AS_MESSAGE_LOG_FDF90FLAGS=$ac_save_F90FLAGSrm -f conftest*AC_LANG_POP(Fortran 90)dnl# If we are using xlf then replace all the commas with spaces.if echo $ac_f90_v_output | grep xlfentry >/dev/null 2>&1; then ac_f90_v_output=`echo $ac_f90_v_output | sed 's/,/ /g'`fi# If we are using Cray Fortran then delete quotes.# Use "\"" instead of '"' for font-lock-mode.# FIXME: a more general fix for quoted arguments with spaces?if echo $ac_f90_v_output | grep cft90 >/dev/null 2>&1; then ac_f90_v_output=`echo $ac_f90_v_output | sed "s/\"//g"`fi[]dnl])# _AC_PROG_F90_V_OUTPUT# _AC_PROG_F90_V# --------------## Determine the flag that causes the Fortran 90 compiler to print# information of library and object files (normally -v)# Needed for AC_F90_LIBRARY_FLAGS# Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)AC_DEFUN([_AC_PROG_F90_V],[AC_CACHE_CHECK([how to get verbose linking output from $F90], [ac_cv_prog_f90_v],[AC_LANG_ASSERT(Fortran 90)AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],[ac_cv_prog_f90_v=# Try some options frequently used verbose outputfor ac_verb in -v -verbose --verbose -V -\#\#\#; do _AC_PROG_F90_V_OUTPUT($ac_verb) # look for -l* and *.a constructs in the output for ac_arg in $ac_f90_v_output; do case $ac_arg in [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*) ac_cv_prog_f90_v=$ac_verb break 2 ;; esac donedoneif test -z "$ac_cv_prog_f90_v"; then AC_MSG_WARN([cannot determine how to obtain linking information from $F90])fi], [AC_MSG_WARN([compilation failed])])])])# _AC_PROG_F90_V# AC_F90_LIBRARY_LDFLAGS# ----------------------## Determine the linker flags (e.g. "-L" and "-l") for the Fortran 90# intrinsic and run-time libraries that are required to successfully# link a Fortran 90 program or shared library. The output variable# F90LIBS is set to these flags.## This macro is intended to be used in those situations when it is# necessary to mix, e.g. C++ and Fortran 90, source code into a single# program or shared library.## For example, if object files from a C++ and Fortran 90 compiler must# be linked together, then the C++ compiler/linker must be used for# linking (since special C++-ish things need to happen at link time# like calling global constructors, instantiating templates, enabling# exception support, etc.).## However, the Fortran 90 intrinsic and run-time libraries must be# linked in as well, but the C++ compiler/linker doesn't know how to# add these Fortran 90 libraries. Hence, the macro# "AC_F90_LIBRARY_LDFLAGS" was created to determine these Fortran 90# libraries.## This macro was packaged in its current form by Matthew D. Langston.# However, nearly all of this macro came from the "OCTAVE_FLIBS" macro# in "octave-2.0.13/aclocal.m4", and full credit should go to John# W. Eaton for writing this extremely useful macro. Thank you John.AC_DEFUN([AC_F90_LIBRARY_LDFLAGS],[AC_LANG_PUSH(Fortran 90)dnl_AC_PROG_F90_VAC_CACHE_CHECK([for Fortran 90 libraries], ac_cv_f90libs,[if test "x$F90LIBS" != "x"; then ac_cv_f90libs="$F90LIBS" # Let the user override the test.else_AC_PROG_F90_V_OUTPUTac_cv_f90libs=# Save positional arguments (if any)ac_save_positional="$[@]"set X $ac_f90_v_outputwhile test $[@%:@] != 1; do shift ac_arg=$[1] case $ac_arg in [[\\/]]*.a | ?:[[\\/]]*.a) AC_LIST_MEMBER_OF($ac_arg, $ac_cv_f90libs, , ac_cv_f90libs="$ac_cv_f90libs $ac_arg") ;; -bI:*) AC_LIST_MEMBER_OF($ac_arg, $ac_cv_f90libs, , [AC_LINKER_OPTION([$ac_arg], ac_cv_f90libs)]) ;; # Ignore these flags. -lang* | -lcrt0.o | -lc | -lgcc | -LANG:=*) ;; -lkernel32) test x"$CYGWIN" != xyes && ac_cv_f90libs="$ac_cv_f90libs $ac_arg" ;; -[[LRuY]]) # These flags, when seen by themselves, take an argument. # We remove the space between option and argument and re-iterate # unless we find an empty arg or a new option (starting with -) case $[2] in "" | -*);; *) ac_arg="$ac_arg$[2]" shift; shift set X $ac_arg "$[@]" ;; esac ;; -YP,*) for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do AC_LIST_MEMBER_OF($ac_j, $ac_cv_f90libs, , [ac_arg="$ac_arg $ac_j" ac_cv_f90libs="$ac_cv_f90libs $ac_j"]) done ;; -[[lLR]]*) AC_LIST_MEMBER_OF($ac_arg, $ac_cv_f90libs, , ac_cv_f90libs="$ac_cv_f90libs $ac_arg") ;; # Ignore everything else. esacdone# restore positional argumentsset X $ac_save_positional; shift# We only consider "LD_RUN_PATH" on Solaris systems. If this is seen,# then we insist that the "run path" must be an absolute path (i.e. it# must begin with a "/").case `(uname -sr) 2>/dev/null` in "SunOS 5"*) ac_ld_run_path=`echo $ac_f90_v_output | sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'` test "x$ac_ld_run_path" != x && AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_f90libs) ;;esacfi # test "x$F90LIBS" = "x"])F90LIBS="$ac_cv_f90libs"AC_SUBST(F90LIBS)AC_LANG_POP(Fortran 90)dnl])# AC_F90_LIBRARY_LDFLAGS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -