📄 aclocal_f77.m4
字号:
dnldnl/*Ddnl PAC_PROG_F77_NAME_MANGLE - Determine how the Fortran compiler manglesdnl names dnldnl Synopsis:dnl PAC_PROG_F77_NAME_MANGLE([action])dnldnl Output Effect:dnl If no action is specified, one of the following names is defined:dnl.vbdnl If fortran names are mapped:dnl lower -> lower F77_NAME_LOWERdnl lower -> lower_ F77_NAME_LOWER_USCOREdnl lower -> UPPER F77_NAME_UPPERdnl lower_lower -> lower__ F77_NAME_LOWER_2USCOREdnl mixed -> mixed F77_NAME_MIXEDdnl mixed -> mixed_ F77_NAME_MIXED_USCOREdnl.vednl If an action is specified, it is executed instead.dnl dnl Notes:dnl We assume that if lower -> lower (any underscore), upper -> upper with thednl same underscore behavior. Previous versions did this by dnl compiling a Fortran program and running strings -a over it. Depending on dnl strings is a bad idea, so instead we try compiling and linking with a dnl C program, since that is why we are doing this anyway. A similar approachdnl is used by FFTW, though without some of the cases we check (specifically, dnl mixed name mangling)dnldnlD*/dnlAC_DEFUN(PAC_PROG_F77_NAME_MANGLE,[AC_CACHE_CHECK([for Fortran 77 name mangling],pac_cv_prog_f77_name_mangle,[ # Check for strange behavior of Fortran. For example, some FreeBSD # systems use f2c to implement f77, and the version of f2c that they # use generates TWO (!!!) trailing underscores # Currently, WDEF is not used but could be... # # Eventually, we want to be able to override the choices here and # force a particular form. This is particularly useful in systems # where a Fortran compiler option is used to force a particular # external name format (rs6000 xlf, for example). rm -f conftest* cat > conftest.f <<EOF subroutine MY_name( a ) return endEOF # This is the ac_compile line used if LANG_FORTRAN77 is selected if test "X$ac_fcompile" = "X" ; then ac_fcompile='${F77-f77} -c $FFLAGS conftest.f 1>&AC_FD_CC' fi if AC_TRY_EVAL(ac_fcompile) && test -s conftest.o ; then mv conftest.o fconftestf.o else echo "configure: failed program was:" >&AC_FD_CC cat conftest.f >&AC_FD_CC fi AC_LANG_SAVE AC_LANG_C save_LIBS="$LIBS" dnl FLIBS comes from AC_F77_LIBRARY_LDFLAGS LIBS="fconftestf.o $FLIBS $LIBS" AC_TRY_LINK(,my_name();,pac_cv_prog_f77_name_mangle="lower") if test "X$pac_cv_prog_f77_name_mangle" = "X" ; then AC_TRY_LINK(,my_name_();,pac_cv_prog_f77_name_mangle="lower underscore") fi if test "X$pac_cv_prog_f77_name_mangle" = "X" ; then AC_TRY_LINK(,MY_NAME();,pac_cv_prog_f77_name_mangle="upper") fi if test "X$pac_cv_prog_f77_name_mangle" = "X" ; then AC_TRY_LINK(,my_name__();, pac_cv_prog_f77_name_mangle="lower doubleunderscore") fi if test "X$pac_cv_prog_f77_name_mangle" = "X" ; then AC_TRY_LINK(,MY_name();,pac_cv_prog_f77_name_mangle="mixed") fi if test "X$pac_cv_prog_f77_name_mangle" = "X" ; then AC_TRY_LINK(,MY_name_();,pac_cv_prog_f77_name_mangle="mixed underscore") fi LIBS="$save_LIBS" AC_LANG_RESTORE rm -f fconftest*])# Make the actual definitionpac_namecheck=`echo X$pac_cv_prog_f77_name_mangle | sed 's/ /-/g'`ifelse([$1],,[case $pac_namecheck in X) AC_MSG_WARN([Cannot determine Fortran naming scheme]) ;; Xlower) AC_DEFINE(F77_NAME_LOWER,,[Define if Fortran names are lowercase]) F77_NAME_MANGLE="F77_NAME_LOWER" ;; Xlower-underscore) AC_DEFINE(F77_NAME_LOWER_USCORE,,[Define if Fortran names are lowercase with a trailing underscore]) F77_NAME_MANGLE="F77_NAME_LOWER_USCORE" ;; Xlower-doubleunderscore) AC_DEFINE(F77_NAME_LOWER_2USCORE,,[Define if Fortran names containing an underscore have two trailing underscores]) F77_NAME_MANGLE="F77_NAME_LOWER_2USCORE" ;; Xupper) AC_DEFINE(F77_NAME_UPPER,,[Define if Fortran names are uppercase]) F77_NAME_MANGLE="F77_NAME_UPPER" ;; Xmixed) AC_DEFINE(F77_NAME_MIXED,,[Define if Fortran names preserve the original case]) F77_NAME_MANGLE="F77_NAME_MIXED" ;; Xmixed-underscore) AC_DEFINE(F77_NAME_MIXED_USCORE,,[Define if Fortran names preserve the original case and add a trailing underscore]) F77_NAME_MANGLE="F77_NAME_MIXED_USCORE" ;; *) AC_MSG_WARN([Unknown Fortran naming scheme]) ;;esacAC_SUBST(F77_NAME_MANGLE)],[$1])])dnldnl/*Ddnl PAC_PROG_F77_CHECK_SIZEOF - Determine the size in bytes of a Fortrandnl typednldnl Synopsis:dnl PAC_PROG_F77_CHECK_SIZEOF(type,[cross-size])dnldnl Output Effect:dnl Sets SIZEOF_F77_uctype to the size if bytes of type.dnl If type is unknown, the size is set to 0.dnl If cross-compiling, the value cross-size is used (it may be a variable)dnl For example 'PAC_PROG_F77_CHECK_SIZEOF(real)' definesdnl 'SIZEOF_F77_REAL' to 4 on most systems. The variable dnl 'pac_cv_sizeof_f77_<type>' (e.g., 'pac_cv_sizeof_f77_real') is also set todnl the size of the type. dnl If the corresponding variable is already set, that value is used.dnl If the name has an '*' in it (e.g., 'integer*4'), the defined name dnl replaces that with an underscore (e.g., 'SIZEOF_F77_INTEGER_4').dnldnl Notes:dnl If the 'cross-size' argument is not given, 'autoconf' will issue an errordnl message. You can use '0' to specify undetermined.dnldnlD*/AC_DEFUN(PAC_PROG_F77_CHECK_SIZEOF,[changequote(<<, >>)dnldnl The name to #define.dnl If the arg value contains a variable, we need to update thatdefine(<<PAC_TYPE_NAME>>, translit(sizeof_f77_$1, [a-z *], [A-Z__]))dnldnl The cache variable name.define(<<PAC_CV_NAME>>, translit(pac_cv_f77_sizeof_$1, [ *], [__]))dnlchangequote([, ])dnlAC_CACHE_CHECK([for size of Fortran type $1],PAC_CV_NAME,[AC_REQUIRE([PAC_PROG_F77_NAME_MANGLE])/bin/rm -f conftest*cat <<EOF > conftest.f subroutine isize( ) $1 i(2) call cisize( i(1), i(2) ) endEOFif test "X$ac_fcompile" = "X" ; then ac_fcompile='${F77-f77} -c $FFLAGS conftest.f 1>&AC_FD_CC'fiif AC_TRY_EVAL(ac_fcompile) && test -s conftest.o ; then mv conftest.o conftestf.o AC_LANG_SAVE AC_LANG_C save_LIBS="$LIBS" dnl Add the Fortran linking libraries LIBS="conftestf.o $FLIBS $LIBS" AC_TRY_RUN([#include <stdio.h>#ifdef F77_NAME_UPPER#define cisize_ CISIZE#define isize_ ISIZE#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)#define cisize_ cisize#define isize_ isize#endifstatic int isize_val;void cisize_(char *i1p, char *i2p){ isize_val = (int)(i2p - i1p);}main(){ FILE *f = fopen("conftestval", "w"); if (!f) exit(1); isize_(); fprintf(f,"%d\n", isize_val ); exit(0);}], eval PAC_CV_NAME=`cat conftestval`,eval PAC_CV_NAME=0,ifelse([$2],,,eval PAC_CV_NAME=$2)) LIBS="$save_LIBS" AC_LANG_RESTOREelse echo "configure: failed program was:" >&AC_FD_CC cat conftest.f >&AC_FD_CC ifelse([$2],,eval PAC_CV_NAME=0,eval PAC_CV_NAME=$2)fi])AC_DEFINE_UNQUOTED(PAC_TYPE_NAME,$PAC_CV_NAME,[Define size of PAC_TYPE_NAME])undefine([PAC_TYPE_NAME])undefine([PAC_CV_NAME])])dnldnl/*Ddnl PAC_PROG_F77_EXCLAIM_COMMENTSdnldnl Synopsis:dnl PAC_PROG_F77_EXCLAIM_COMMENTS([action-if-true],[action-if-false])dnldnl Notes:dnl Check whether '!' may be used to begin comments in Fortran.dnldnl This macro requires a version of autoconf `after` 2.13; the 'acgeneral.m4'dnl file contains an error in the handling of Fortran programs in dnl 'AC_TRY_COMPILE' (fixed in our local version).dnldnlD*/AC_DEFUN(PAC_PROG_F77_EXCLAIM_COMMENTS,[AC_CACHE_CHECK([whether Fortran accepts ! for comments],pac_cv_prog_f77_exclaim_comments,[AC_LANG_SAVEAC_LANG_FORTRAN77AC_TRY_COMPILE(,[! This is a comment],pac_cv_prog_f77_exclaim_comments="yes",pac_cv_prog_f77_exclaim_comments="no")AC_LANG_RESTORE])if test "$pac_cv_prog_f77_exclaim_comments" = "yes" ; then ifelse([$1],,:,$1)else ifelse([$2],,:,$2)fi])dnldnldnl/*Ddnl PAC_F77_CHECK_COMPILER_OPTION - Check that a compiler option is accepteddnl without warning messagesdnldnl Synopsis:dnl PAC_F77_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)dnldnl Output Effects:dnldnl If no actions are specified, a working value is added to 'FOPTIONS'dnldnl Notes:dnl This is now careful to check that the output is different, since dnl some compilers are noisy.dnl dnl We are extra careful to prototype the functions in case compiler optionsdnl that complain about poor code are in effect.dnldnl Because this is a long script, we have ensured that you can pass a dnl variable containing the option name as the first argument.dnlD*/AC_DEFUN(PAC_F77_CHECK_COMPILER_OPTION,[AC_MSG_CHECKING([that Fortran 77 compiler accepts option $1])ac_result="no"save_FFLAGS="$FFLAGS"FFLAGS="$1 $FFLAGS"rm -f conftest.outcat >conftest2.f <<EOF subroutine try() endEOFcat >conftest.f <<EOF program main endEOFdnl It is important to use the AC_TRY_EVAL in case F77 is not a single worddnl but is something like "f77 -64" (where the switch has changed thednl compiler)ac_fscompilelink='${F77-f77} $save_FFLAGS -o conftest conftest.f $LDFLAGS >conftest.bas 2>&1'ac_fscompilelink2='${F77-f77} $FFLAGS -o conftest conftest.f $LDFLAGS >conftest.out 2>&1'if AC_TRY_EVAL(ac_fscompilelink) && test -x conftest ; then if AC_TRY_EVAL(ac_fscompilelink2) && test -x conftest ; then if diff -b conftest.out conftest.bas >/dev/null 2>&1 ; then AC_MSG_RESULT(yes) AC_MSG_CHECKING([that routines compiled with $1 can be linked with ones compiled without $1]) /bin/rm -f conftest2.out /bin/rm -f conftest.bas ac_fscompile3='${F77-f77} -c $save_FFLAGS conftest2.f >conftest2.out 2>&1' ac_fscompilelink4='${F77-f77} $FFLAGS -o conftest conftest2.o conftest.f $LDFLAGS >conftest.bas 2>&1' if AC_TRY_EVAL(ac_fscompile3) && test -s conftest2.o ; then if AC_TRY_EVAL(ac_fscompilelink4) && test -x conftest ; then if diff -b conftest.out conftest.bas >/dev/null 2>&1 ; then ac_result="yes" else echo "configure: Compiler output differed in two cases" >&AC_FD_CC diff -b conftest.out conftest.bas >&AC_FD_CC fi else echo "configure: failed program was:" >&AC_FD_CC cat conftest.f >&AC_FD_CC fi else echo "configure: failed program was:" >&AC_FD_CC cat conftest2.f >&AC_FD_CC fi else # diff echo "configure: Compiler output differed in two cases" >&AC_FD_CC diff -b conftest.out conftest.bas >&AC_FD_CC fi else # try_eval(fscompilelink2) echo "configure: failed program was:" >&AC_FD_CC cat conftest.f >&AC_FD_CC fi if test "$ac_result" != "yes" -a -s conftest.out ; then cat conftest.out >&AC_FD_CC fielse # Could not compile without the option! echo "configure: Could not compile program" >&AC_FD_CC cat conftest.f >&AC_FD_CC cat conftest.bas >&AC_FD_CCfiif test "$ac_result" = "yes" ; then AC_MSG_RESULT(yes) ifelse([$2],,FOPTIONS="$FOPTIONS $1",$2)else AC_MSG_RESULT(no) $3fiFFLAGS="$save_FFLAGS"rm -f conftest*])dnldnl/*Ddnl PAC_PROG_F77_CMDARGS - Determine how to access the command line fromdnl Fortran 77dnldnl Output Effects:dnl The following variables are set:dnl.vbdnl F77_GETARG - Statement to get an argument i into string sdnl F77_IARGC - Routine to return the number of argumentsdnl FXX_MODULE - Module command when using Fortran 90 compilerdnl F77_GETARGDECL - Declaration of routine used for F77_GETARGdnl F77_GETARG_FFLAGS - Flags needed when compiling/linkingdnl F77_GETARG_LDFLAGS - Flags needed when linkingdnl.vednl If 'F77_GETARG' has a value, then that value and the values for thesednl other symbols will be used instead. If no approach is found, all of thesednl variables will have empty values.dnl If no other approach works and a file 'f77argdef' is in the directory, dnl that file will be sourced for the values of the above four variables.dnldnl In most cases, you should add F77_GETARG_FFLAGS to the FFLAGS variablednl and F77_GETARG_LDFLAGS to the LDFLAGS variable, to ensure that tests arednl performed on the compiler version that will be used.dnldnl 'AC_SUBST' is called for all six variables.dnldnl One complication is that on systems with multiple Fortran compilers, dnl some libraries used by one Fortran compiler may have been (mis)placeddnl in a common location. We have had trouble with libg2c in particular.dnl To work around this, we test whether iargc etc. work first. Thisdnl will catch most systems and will speed up the tests.dnldnl Next, the libraries are only added if they are needed to complete a dnl link; they aren't added just because they exist.dnldnl f77argdefdnlD*/dnldnl Random notesdnl You can export the command line arguments from C to the g77 compiler
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -