From: Ben Elliston Date: Fri, 2 Oct 1998 21:25:58 +0000 (+0000) Subject: 1998-10-03 Ben Elliston X-Git-Tag: autoconf-2-13-rc1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f98edc0d071412aead53c9b113ced0fefbcb49d4;p=thirdparty%2Fautoconf.git 1998-10-03 Ben Elliston * acconfig.h (FC_NO_MINUS_C_MINUS_O): Add to complete the Fortran 77 support. Tue Sep 8 14:06:04 1998 Matthew D. Langston * acgeneral.m4: Make the following macros Fortran 77 aware (i.e. conditionalize whether to `#include "confdefs.h"', etc.): (AC_TRY_COMPILE) (AC_TRY_LINK) (AC_CHECK_LIB) * acgeneral.m4 (AC_LANG_FORTRAN77): Rename `AC_LANG_FORTRAN' to `AC_LANG_FORTRAN77'. Change the Fortran 77 language macro from `FORTRAN' to `FORTRAN77'. (AC_LANG_RESTORE): Change the Fortran 77 language macro from `FORTRAN' to `FORTRAN77' * autoconf.texi: Updated Fortran 77 documentation, particularly for `AC_TRY_COMPILE', `AC_TRY_LINK' and `AC_CHECK_LIB'. Thu Sep 3 09:34:39 1998 Matthew D. Langston * autoconf.texi: Added Fortran 77 documentation. * acspecific.m4 (AC_PROG_FC): New macro. Determine a Fortran compiler to use. (AC_PROG_FC_WORKS): New macro. (AC_PROG_FC_GNU): New macro. (AC_PROG_FC_G): New macro. (AC_PROG_FC_C_O): New macro. * acgeneral.m4: Add FFLAGS (Fortran 77 flags). (AC_LANG_FORTRAN): New macro. (AC_LANG_RESTORE): Make Fortran 77 aware. (AC_TRY_COMPILER): Make Fortran 77 aware (i.e. conditionalize whether to `#include "confdefs.h"'). --- diff --git a/ChangeLog b/ChangeLog index a8b696fe..d22494fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 1998-10-03 Ben Elliston + * acconfig.h (FC_NO_MINUS_C_MINUS_O): Add to complete the Fortran + 77 support. + * README: Update bug reporting address. Include maintainer info. 1998-10-02 Ben Elliston @@ -87,7 +90,41 @@ Sat Sep 12 16:25:00 1998 Aaron Crane * acgeneral.m4 (AC_CHECK_TYPE): Changed the egrep regex to avoid incorrectly assuming that if foobar_t is defined, then so is bar_t. - + +Tue Sep 8 14:06:04 1998 Matthew D. Langston + + * acgeneral.m4: Make the following macros Fortran 77 aware + (i.e. conditionalize whether to `#include "confdefs.h"', etc.): + (AC_TRY_COMPILE) + (AC_TRY_LINK) + (AC_CHECK_LIB) + + * acgeneral.m4 (AC_LANG_FORTRAN77): Rename `AC_LANG_FORTRAN' to + `AC_LANG_FORTRAN77'. Change the Fortran 77 language macro from + `FORTRAN' to `FORTRAN77'. + (AC_LANG_RESTORE): Change the Fortran 77 language macro from + `FORTRAN' to `FORTRAN77' + + * autoconf.texi: Updated Fortran 77 documentation, particularly + for `AC_TRY_COMPILE', `AC_TRY_LINK' and `AC_CHECK_LIB'. + +Thu Sep 3 09:34:39 1998 Matthew D. Langston + + * autoconf.texi: Added Fortran 77 documentation. + + * acspecific.m4 (AC_PROG_FC): New macro. Determine a Fortran + compiler to use. + (AC_PROG_FC_WORKS): New macro. + (AC_PROG_FC_GNU): New macro. + (AC_PROG_FC_G): New macro. + (AC_PROG_FC_C_O): New macro. + + * acgeneral.m4: Add FFLAGS (Fortran 77 flags). + (AC_LANG_FORTRAN): New macro. + (AC_LANG_RESTORE): Make Fortran 77 aware. + (AC_TRY_COMPILER): Make Fortran 77 aware (i.e. conditionalize + whether to `#include "confdefs.h"'). + Thu Jun 18 12:13:27 1998 Ian Lance Taylor * acspecific.m4 (AC_EXEEXT): Correct setting of ac_exeext when diff --git a/acconfig.h b/acconfig.h index dd3a6650..4a816cca 100644 --- a/acconfig.h +++ b/acconfig.h @@ -169,6 +169,9 @@ /* Define if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O +/* Define if your Fortran 77 compiler doesn't accept -c and -o together. */ +#undef FC_NO_MINUS_C_MINUS_O + /* Define to `long' if doesn't define. */ #undef off_t diff --git a/acgeneral.m4 b/acgeneral.m4 index 608b5882..61ad88cb 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -700,6 +700,7 @@ AC_SUBST(SHELL)dnl AC_SUBST(CFLAGS)dnl AC_SUBST(CPPFLAGS)dnl AC_SUBST(CXXFLAGS)dnl +AC_SUBST(FFLAGS)dnl AC_SUBST(DEFS)dnl AC_SUBST(LDFLAGS)dnl AC_SUBST(LIBS)dnl @@ -1244,6 +1245,15 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross ]) +dnl AC_LANG_FORTRAN77() +AC_DEFUN([AC_LANG_FORTRAN77], +[define([AC_LANG], [FORTRAN77])dnl +ac_ext=f +ac_compile='$FC $FFLAGS -c conftest.$ac_ext 1>&AC_FD_CC' +ac_link='$FC $FFLAGS $LDFLAGS -c conftest.$ac_ext -o conftest $LIBS 1>&AC_FD_CC' +cross_compiling=$ac_cv_prog_fc_cross +]) + dnl Push the current language on a stack. dnl AC_LANG_SAVE() define(AC_LANG_SAVE, @@ -1251,8 +1261,10 @@ define(AC_LANG_SAVE, dnl Restore the current language from the stack. dnl AC_LANG_RESTORE() -define(AC_LANG_RESTORE, -[ifelse(AC_LANG_STACK, C, [ifelse(AC_LANG, C, , [AC_LANG_C])], [ifelse(AC_LANG, CPLUSPLUS, , [AC_LANG_CPLUSPLUS])])[]popdef([AC_LANG_STACK])]) +pushdef([AC_LANG_RESTORE], +[ifelse(AC_LANG_STACK, [C], [AC_LANG_C],dnl +AC_LANG_STACK, [CPLUSPLUS], [AC_LANG_CPLUSPLUS],dnl +AC_LANG_STACK, [FORTRAN77], [MDL_LANG_FORTRAN77])[]popdef([AC_LANG_STACK])]) dnl ### Compiler-running mechanics @@ -1479,14 +1491,21 @@ fi undefine([AC_VAR_NAME])dnl ]) -dnl Sets WORKING_VAR to yes if the current compiler works, else no; -dnl sets CROSS-VAR to yes if it produces non-native executables, else no. -dnl Before calling this, call AC_LANG_* to set the right language. +dnl Try to compile, link and execute TEST-PROGRAM. Set WORKING-VAR to +dnl `yes' if the current compiler works, otherwise set it ti `no'. Set +dnl CROSS-VAR to `yes' if the compiler and linker produce non-native +dnl executables, otherwise set it to `no'. Before calling +dnl `AC_TRY_COMPILER()', call `AC_LANG_*' to set-up for the right +dnl language. +dnl dnl AC_TRY_COMPILER(TEST-PROGRAM, WORKING-VAR, CROSS-VAR) AC_DEFUN(AC_TRY_COMPILER, -[cat > conftest.$ac_ext < conftest.$ac_ext << EOF +ifelse(AC_LANG, [FORTRAN77], , +[ [#]line __oline__ "configure" #include "confdefs.h" +]) [$1] EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then @@ -1546,6 +1565,7 @@ AC_CACHE_VAL(ac_cv_lib_$ac_lib_var, [ac_save_LIBS="$LIBS" LIBS="-l$1 $5 $LIBS" AC_TRY_LINK(dnl +ifelse(AC_LANG, [FORTRAN77], , ifelse([$2], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus @@ -1555,7 +1575,7 @@ extern "C" [/* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $2(); -]), +])), [$2()], eval "ac_cv_lib_$ac_lib_var=yes", eval "ac_cv_lib_$ac_lib_var=no") @@ -1681,7 +1701,11 @@ dnl AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) AC_DEFUN(AC_TRY_COMPILE, [cat > conftest.$ac_ext < conftest.$ac_ext < conftest.fpp </dev/null 2>&1; then + ac_cv_prog_g77=yes +else + ac_cv_prog_g77=no +fi])]) + AC_DEFUN(AC_PROG_CC_G, [AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g, [echo 'void f(){}' > conftest.c @@ -234,6 +326,24 @@ fi rm -f conftest* ])]) +dnl Test whether the Fortran compiler can accept the `-g' option to +dnl enable debugging. +dnl +dnl AC_PROG_FC_G() +AC_DEFUN(AC_PROG_FC_G, +[AC_CACHE_CHECK(whether $FC accepts -g, ac_cv_prog_fc_g, +[cat > conftest.f << EOF + program conftest + end +EOF +if test -z "`$FC -g -c conftest.f 2>&1`"; then + ac_cv_prog_fc_g=yes +else + ac_cv_prog_fc_g=no +fi +rm -f conftest* +])]) + AC_DEFUN(AC_PROG_GCC_TRADITIONAL, [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_CPP])dnl @@ -304,6 +414,45 @@ else fi ]) +dnl Test if the Fortran compiler accepts the options `-c' and `-o' +dnl simultaneously, and define `FC_NO_MINUS_C_MINUS_O' if it does not. +dnl +dnl The usefulness of this macro is questionable, as I can't really see +dnl why anyone would use it. The only reason I include it is for +dnl completeness, since a similar test exists for the C compiler. +dnl +dnl AC_PROG_FC_C_O +AC_DEFUN(AC_PROG_FC_C_O, +[AC_BEFORE([$0], [AC_PROG_FC])dnl +AC_MSG_CHECKING(whether $FC understand -c and -o together) +set dummy $FC; ac_fc="`echo [$]2 | +changequote(, )dnl +sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`" +changequote([, ])dnl +AC_CACHE_VAL(ac_cv_prog_fc_${ac_fc}_c_o, +[cat > conftest.f << EOF + program conftest + end +EOF +# We do the `AC_TRY_EVAL' test twice because some compilers refuse to +# overwrite an existing `.o' file with `-o', although they will create +# one. +ac_try='$FC $FFLAGS -c conftest.f -o conftest.o 1>&AC_FD_CC' +if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then + eval ac_cv_prog_fc_${ac_fc}_c_o=yes +else + eval ac_cv_prog_fc_${ac_fc}_c_o=no +fi +rm -f conftest* +])dnl +if eval "test \"`echo '$ac_cv_prog_fc_'${ac_fc}_c_o`\" = yes"; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) + AC_DEFINE(FC_NO_MINUS_C_MINUS_O) +fi +]) + dnl Define SET_MAKE to set ${MAKE} if make doesn't. AC_DEFUN(AC_PROG_MAKE_SET, [AC_MSG_CHECKING(whether ${MAKE-make} sets \${MAKE}) diff --git a/autoconf.texi b/autoconf.texi index d0ba46df..021cced3 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -1048,6 +1048,15 @@ set when you call @code{AC_PROG_CXX} (or empty if you don't). C++ features. @end defvar +@defvar FFLAGS +@ovindex FFLAGS +Debugging and optimization options for the Fortran 77 compiler. If it +is not set in the environment when @code{configure} runs, the default +value is set when you call @code{AC_PROG_FC} (or empty if you don't). +@code{configure} uses this variable when compiling programs to test for +Fortran 77 features. +@end defvar + @defvar DEFS @ovindex DEFS @samp{-D} options to pass to the C compiler. If @code{AC_CONFIG_HEADER} @@ -1609,6 +1618,32 @@ calling @code{AC_TRY_CPP}, @code{AC_CHECK_HEADER}, @code{AC_EGREP_HEADER}, or @code{AC_EGREP_CPP}. @end defmac +@defmac AC_PROG_FC +@maindex PROG_FORTRAN +@ovindex FC +@ovindex FFLAGS +Determine a Fortran 77 compiler to use. If @code{FC} is not already set +in the environment, check for @code{g77}, @code{f77} and @code{f2c}, in +that order. Set the output variable @code{FC} to the name of the +compiler found. + +If using @code{g77} (the GNU Fortran 77 compiler), then +@code{AC_PROG_FC} will set the shell variable @code{G77} to @samp{yes}, +and empty otherwise. If the output variable @code{FFLAGS} was not +already set in the environment, then set it to @samp{-g -02} for +@code{g77} (or @samp{-O2} where @code{g77} does not accept @samp{-g}). +Otherwise, set @code{FFLAGS} to @samp{-g} for all other Fortran 77 +compilers. +@end defmac + +@defmac AC_PROG_FC_C_O +@maindex PROG_FC_C_O +@cvindex FC_NO_MINUS_C_MINUS_O +Test if the Fortran 77 compiler accepts the options @samp{-c} and +@samp{-o} simultaneously, and define @code{FC_NO_MINUS_C_MINUS_O} if it +does not. +@end defmac + @defmac AC_PROG_GCC_TRADITIONAL @maindex PROG_GCC_TRADITIONAL @ovindex CC @@ -1774,15 +1809,17 @@ found. @node Libraries, Library Functions, Alternative Programs, Existing Tests @section Library Files -The following macros check for the presence of certain C library archive -files. +The following macros check for the presence of certain C, C++ or Fortran +77 library archive files. @defmac AC_CHECK_LIB (@var{library}, @var{function} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]}) @maindex CHECK_LIB -Try to ensure that C function @var{function} is available by checking -whether a test C program can be linked with the library @var{library} to -get the function. @var{library} is the base name of the library; e.g., -to check for @samp{-lmp}, use @samp{mp} as the @var{library} argument. +Depending on the current language(@pxref{Language Choice}), try to +ensure that the C, C++ or Fortran 77 function @var{function} is +available by checking whether a test program can be linked with the +library @var{library} to get the function. @var{library} is the base +name of the library; e.g., to check for @samp{-lmp}, use @samp{mp} as +the @var{library} argument. @var{action-if-found} is a list of shell commands to run if the link with the library succeeds; @var{action-if-not-found} is a list of shell @@ -2883,22 +2920,31 @@ been called already. @node Examining Syntax, Examining Libraries, Examining Declarations, Writing Tests @section Examining Syntax -To check for a syntax feature of the C or C++ compiler, such as whether -it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to try to -compile a small program that uses that feature. You can also use it to -check for structures and structure members that are not present on all -systems. +To check for a syntax feature of the C, C++ or Fortran 77 compiler, such +as whether it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to +try to compile a small program that uses that feature. You can also use +it to check for structures and structure members that are not present on +all systems. @defmac AC_TRY_COMPILE (@var{includes}, @var{function-body}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]}) @maindex TRY_COMPILE -Create a test C program to see whether a function whose body consists of -@var{function-body} can be compiled; @var{includes} is any -@code{#include} statements needed by the code in @var{function-body}. +Create a C, C++ or Fortran 77 test program (depending on which language +is current, @pxref{Language Choice}), to see whether a function whose +body consists of @var{function-body} can be compiled. + +For C and C++, @var{includes} is any @code{#include} statements needed +by the code in @var{function-body} (@var{includes} will be ignored if +the currently selected language is Fortran 77). This macro also uses +@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently +selected language, as well as @code{CPPFLAGS}, when compiling. If +Fortran 77 is the currently selected language then @code{FFLAGS} will be +used when compiling. + If the file compiles successfully, run shell commands -@var{action-if-found}, otherwise run @var{action-if-not-found}. This -macro uses @code{CFLAGS} or @code{CXXFLAGS}, and @code{CPPFLAGS}, when -compiling. It does not try to link; use @code{AC_TRY_LINK} if you need -to do that (@pxref{Examining Libraries}). +@var{action-if-found}, otherwise run @var{action-if-not-found}. + +This macro does not try to link; use @code{AC_TRY_LINK} if you need to +do that (@pxref{Examining Libraries}). @end defmac @node Examining Libraries, Run Time, Examining Syntax, Writing Tests @@ -2925,28 +2971,37 @@ solve it by setting @code{LDFLAGS} in the environment to pass whatever options the linker needs (for example, @samp{-Wl,-dn} on MIPS RISC/OS). @code{AC_TRY_LINK} is used to compile test programs to test for -functions and global variables. It is also used (by -@code{AC_CHECK_LIB}) to check for libraries, by adding the library being +functions and global variables. It is also used by @code{AC_CHECK_LIB} +to check for libraries (@pxref{Libraries}), by adding the library being checked for to @code{LIBS} temporarily and trying to link a small program. @defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]}) @maindex TRY_LINK -Create a test C program to see whether a function whose body consists of -@var{function-body} can be compiled and linked; @var{includes} is any -@code{#include} statements needed by the code in @var{function-body}. +Depending on the current language (@pxref{Language Choice}), create a +test program to see whether a function whose body consists of +@var{function-body} can be compiled and linked. + +For C and C++, @var{includes} is any @code{#include} statements needed +by the code in @var{function-body} (@var{includes} will be ignored if +the currently selected language is Fortran 77). This macro also uses +@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently +selected language, as well as @code{CPPFLAGS}, when compiling. If +Fortran 77 is the currently selected language then @code{FFLAGS} will be +used when compiling. However, both @code{LDFLAGS} and @code{LIBS} will +be used during linking in all cases. + If the file compiles and links successfully, run shell commands -@var{action-if-found}, otherwise run @var{action-if-not-found}. This -macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS}, -@code{LDFLAGS}, and @code{LIBS} when compiling. +@var{action-if-found}, otherwise run @var{action-if-not-found}. @end defmac @defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) @maindex COMPILE_CHECK -This is an obsolete version of @code{AC_TRY_LINK}, with the addition that it -prints @samp{checking for @var{echo-text}} to the standard output first, -if @var{echo-text} is non-empty. Use @code{AC_MSG_CHECKING} and -@code{AC_MSG_RESULT} instead to print messages (@pxref{Printing Messages}). +This is an obsolete version of @code{AC_TRY_LINK}, with the addition +that it prints @samp{checking for @var{echo-text}} to the standard +output first, if @var{echo-text} is non-empty. Use +@code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT} instead to print +messages (@pxref{Printing Messages}). @end defmac @node Run Time, Portable Shell, Examining Libraries, Writing Tests @@ -3224,21 +3279,29 @@ extension @file{.C} for test programs. Set the shell variable it has been run, empty otherwise. @end defmac +@defmac AC_LANG_FORTRAN77 +@maindex LANG_FORTRAN77 +Do compilation tests using @code{FC} and use extension @file{.f} for +test programs. Set the shell variable @code{cross_compiling} to the +value computed by @code{AC_PROG_FC} if it has been run, empty otherwise. +@end defmac + @defmac AC_LANG_SAVE @maindex LANG_SAVE -Remember the current language (as set by @code{AC_LANG_C} or -@code{AC_LANG_CPLUSPLUS}) on a stack. Does not change which language is -current. Use this macro and @code{AC_LANG_RESTORE} in macros that need -to temporarily switch to a particular language. +Remember the current language (as set by @code{AC_LANG_C}, +@code{AC_LANG_CPLUSPLUS} or @code{AC_LANG_FORTRAN77}) on a stack. Does +not change which language is current. Use this macro and +@code{AC_LANG_RESTORE} in macros that need to temporarily switch to a +particular language. @end defmac @defmac AC_LANG_RESTORE @maindex LANG_RESTORE Select the language that is saved on the top of the stack, as set by @code{AC_LANG_SAVE}, and remove it from the stack. This macro is -equivalent to either @code{AC_LANG_C} or @code{AC_LANG_CPLUSPLUS}, -whichever had been run most recently when @code{AC_LANG_SAVE} was last -called. +equivalent to either @code{AC_LANG_C}, @code{AC_LANG_CPLUSPLUS} or +@code{AC_LANG_FORTRAN77}, whichever had been run most recently when +@code{AC_LANG_SAVE} was last called. Do not call this macro more times than @code{AC_LANG_SAVE}. @end defmac diff --git a/doc/autoconf.texi b/doc/autoconf.texi index d0ba46df..021cced3 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -1048,6 +1048,15 @@ set when you call @code{AC_PROG_CXX} (or empty if you don't). C++ features. @end defvar +@defvar FFLAGS +@ovindex FFLAGS +Debugging and optimization options for the Fortran 77 compiler. If it +is not set in the environment when @code{configure} runs, the default +value is set when you call @code{AC_PROG_FC} (or empty if you don't). +@code{configure} uses this variable when compiling programs to test for +Fortran 77 features. +@end defvar + @defvar DEFS @ovindex DEFS @samp{-D} options to pass to the C compiler. If @code{AC_CONFIG_HEADER} @@ -1609,6 +1618,32 @@ calling @code{AC_TRY_CPP}, @code{AC_CHECK_HEADER}, @code{AC_EGREP_HEADER}, or @code{AC_EGREP_CPP}. @end defmac +@defmac AC_PROG_FC +@maindex PROG_FORTRAN +@ovindex FC +@ovindex FFLAGS +Determine a Fortran 77 compiler to use. If @code{FC} is not already set +in the environment, check for @code{g77}, @code{f77} and @code{f2c}, in +that order. Set the output variable @code{FC} to the name of the +compiler found. + +If using @code{g77} (the GNU Fortran 77 compiler), then +@code{AC_PROG_FC} will set the shell variable @code{G77} to @samp{yes}, +and empty otherwise. If the output variable @code{FFLAGS} was not +already set in the environment, then set it to @samp{-g -02} for +@code{g77} (or @samp{-O2} where @code{g77} does not accept @samp{-g}). +Otherwise, set @code{FFLAGS} to @samp{-g} for all other Fortran 77 +compilers. +@end defmac + +@defmac AC_PROG_FC_C_O +@maindex PROG_FC_C_O +@cvindex FC_NO_MINUS_C_MINUS_O +Test if the Fortran 77 compiler accepts the options @samp{-c} and +@samp{-o} simultaneously, and define @code{FC_NO_MINUS_C_MINUS_O} if it +does not. +@end defmac + @defmac AC_PROG_GCC_TRADITIONAL @maindex PROG_GCC_TRADITIONAL @ovindex CC @@ -1774,15 +1809,17 @@ found. @node Libraries, Library Functions, Alternative Programs, Existing Tests @section Library Files -The following macros check for the presence of certain C library archive -files. +The following macros check for the presence of certain C, C++ or Fortran +77 library archive files. @defmac AC_CHECK_LIB (@var{library}, @var{function} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]}) @maindex CHECK_LIB -Try to ensure that C function @var{function} is available by checking -whether a test C program can be linked with the library @var{library} to -get the function. @var{library} is the base name of the library; e.g., -to check for @samp{-lmp}, use @samp{mp} as the @var{library} argument. +Depending on the current language(@pxref{Language Choice}), try to +ensure that the C, C++ or Fortran 77 function @var{function} is +available by checking whether a test program can be linked with the +library @var{library} to get the function. @var{library} is the base +name of the library; e.g., to check for @samp{-lmp}, use @samp{mp} as +the @var{library} argument. @var{action-if-found} is a list of shell commands to run if the link with the library succeeds; @var{action-if-not-found} is a list of shell @@ -2883,22 +2920,31 @@ been called already. @node Examining Syntax, Examining Libraries, Examining Declarations, Writing Tests @section Examining Syntax -To check for a syntax feature of the C or C++ compiler, such as whether -it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to try to -compile a small program that uses that feature. You can also use it to -check for structures and structure members that are not present on all -systems. +To check for a syntax feature of the C, C++ or Fortran 77 compiler, such +as whether it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to +try to compile a small program that uses that feature. You can also use +it to check for structures and structure members that are not present on +all systems. @defmac AC_TRY_COMPILE (@var{includes}, @var{function-body}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]}) @maindex TRY_COMPILE -Create a test C program to see whether a function whose body consists of -@var{function-body} can be compiled; @var{includes} is any -@code{#include} statements needed by the code in @var{function-body}. +Create a C, C++ or Fortran 77 test program (depending on which language +is current, @pxref{Language Choice}), to see whether a function whose +body consists of @var{function-body} can be compiled. + +For C and C++, @var{includes} is any @code{#include} statements needed +by the code in @var{function-body} (@var{includes} will be ignored if +the currently selected language is Fortran 77). This macro also uses +@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently +selected language, as well as @code{CPPFLAGS}, when compiling. If +Fortran 77 is the currently selected language then @code{FFLAGS} will be +used when compiling. + If the file compiles successfully, run shell commands -@var{action-if-found}, otherwise run @var{action-if-not-found}. This -macro uses @code{CFLAGS} or @code{CXXFLAGS}, and @code{CPPFLAGS}, when -compiling. It does not try to link; use @code{AC_TRY_LINK} if you need -to do that (@pxref{Examining Libraries}). +@var{action-if-found}, otherwise run @var{action-if-not-found}. + +This macro does not try to link; use @code{AC_TRY_LINK} if you need to +do that (@pxref{Examining Libraries}). @end defmac @node Examining Libraries, Run Time, Examining Syntax, Writing Tests @@ -2925,28 +2971,37 @@ solve it by setting @code{LDFLAGS} in the environment to pass whatever options the linker needs (for example, @samp{-Wl,-dn} on MIPS RISC/OS). @code{AC_TRY_LINK} is used to compile test programs to test for -functions and global variables. It is also used (by -@code{AC_CHECK_LIB}) to check for libraries, by adding the library being +functions and global variables. It is also used by @code{AC_CHECK_LIB} +to check for libraries (@pxref{Libraries}), by adding the library being checked for to @code{LIBS} temporarily and trying to link a small program. @defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]}) @maindex TRY_LINK -Create a test C program to see whether a function whose body consists of -@var{function-body} can be compiled and linked; @var{includes} is any -@code{#include} statements needed by the code in @var{function-body}. +Depending on the current language (@pxref{Language Choice}), create a +test program to see whether a function whose body consists of +@var{function-body} can be compiled and linked. + +For C and C++, @var{includes} is any @code{#include} statements needed +by the code in @var{function-body} (@var{includes} will be ignored if +the currently selected language is Fortran 77). This macro also uses +@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently +selected language, as well as @code{CPPFLAGS}, when compiling. If +Fortran 77 is the currently selected language then @code{FFLAGS} will be +used when compiling. However, both @code{LDFLAGS} and @code{LIBS} will +be used during linking in all cases. + If the file compiles and links successfully, run shell commands -@var{action-if-found}, otherwise run @var{action-if-not-found}. This -macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS}, -@code{LDFLAGS}, and @code{LIBS} when compiling. +@var{action-if-found}, otherwise run @var{action-if-not-found}. @end defmac @defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) @maindex COMPILE_CHECK -This is an obsolete version of @code{AC_TRY_LINK}, with the addition that it -prints @samp{checking for @var{echo-text}} to the standard output first, -if @var{echo-text} is non-empty. Use @code{AC_MSG_CHECKING} and -@code{AC_MSG_RESULT} instead to print messages (@pxref{Printing Messages}). +This is an obsolete version of @code{AC_TRY_LINK}, with the addition +that it prints @samp{checking for @var{echo-text}} to the standard +output first, if @var{echo-text} is non-empty. Use +@code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT} instead to print +messages (@pxref{Printing Messages}). @end defmac @node Run Time, Portable Shell, Examining Libraries, Writing Tests @@ -3224,21 +3279,29 @@ extension @file{.C} for test programs. Set the shell variable it has been run, empty otherwise. @end defmac +@defmac AC_LANG_FORTRAN77 +@maindex LANG_FORTRAN77 +Do compilation tests using @code{FC} and use extension @file{.f} for +test programs. Set the shell variable @code{cross_compiling} to the +value computed by @code{AC_PROG_FC} if it has been run, empty otherwise. +@end defmac + @defmac AC_LANG_SAVE @maindex LANG_SAVE -Remember the current language (as set by @code{AC_LANG_C} or -@code{AC_LANG_CPLUSPLUS}) on a stack. Does not change which language is -current. Use this macro and @code{AC_LANG_RESTORE} in macros that need -to temporarily switch to a particular language. +Remember the current language (as set by @code{AC_LANG_C}, +@code{AC_LANG_CPLUSPLUS} or @code{AC_LANG_FORTRAN77}) on a stack. Does +not change which language is current. Use this macro and +@code{AC_LANG_RESTORE} in macros that need to temporarily switch to a +particular language. @end defmac @defmac AC_LANG_RESTORE @maindex LANG_RESTORE Select the language that is saved on the top of the stack, as set by @code{AC_LANG_SAVE}, and remove it from the stack. This macro is -equivalent to either @code{AC_LANG_C} or @code{AC_LANG_CPLUSPLUS}, -whichever had been run most recently when @code{AC_LANG_SAVE} was last -called. +equivalent to either @code{AC_LANG_C}, @code{AC_LANG_CPLUSPLUS} or +@code{AC_LANG_FORTRAN77}, whichever had been run most recently when +@code{AC_LANG_SAVE} was last called. Do not call this macro more times than @code{AC_LANG_SAVE}. @end defmac diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 608b5882..61ad88cb 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -700,6 +700,7 @@ AC_SUBST(SHELL)dnl AC_SUBST(CFLAGS)dnl AC_SUBST(CPPFLAGS)dnl AC_SUBST(CXXFLAGS)dnl +AC_SUBST(FFLAGS)dnl AC_SUBST(DEFS)dnl AC_SUBST(LDFLAGS)dnl AC_SUBST(LIBS)dnl @@ -1244,6 +1245,15 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross ]) +dnl AC_LANG_FORTRAN77() +AC_DEFUN([AC_LANG_FORTRAN77], +[define([AC_LANG], [FORTRAN77])dnl +ac_ext=f +ac_compile='$FC $FFLAGS -c conftest.$ac_ext 1>&AC_FD_CC' +ac_link='$FC $FFLAGS $LDFLAGS -c conftest.$ac_ext -o conftest $LIBS 1>&AC_FD_CC' +cross_compiling=$ac_cv_prog_fc_cross +]) + dnl Push the current language on a stack. dnl AC_LANG_SAVE() define(AC_LANG_SAVE, @@ -1251,8 +1261,10 @@ define(AC_LANG_SAVE, dnl Restore the current language from the stack. dnl AC_LANG_RESTORE() -define(AC_LANG_RESTORE, -[ifelse(AC_LANG_STACK, C, [ifelse(AC_LANG, C, , [AC_LANG_C])], [ifelse(AC_LANG, CPLUSPLUS, , [AC_LANG_CPLUSPLUS])])[]popdef([AC_LANG_STACK])]) +pushdef([AC_LANG_RESTORE], +[ifelse(AC_LANG_STACK, [C], [AC_LANG_C],dnl +AC_LANG_STACK, [CPLUSPLUS], [AC_LANG_CPLUSPLUS],dnl +AC_LANG_STACK, [FORTRAN77], [MDL_LANG_FORTRAN77])[]popdef([AC_LANG_STACK])]) dnl ### Compiler-running mechanics @@ -1479,14 +1491,21 @@ fi undefine([AC_VAR_NAME])dnl ]) -dnl Sets WORKING_VAR to yes if the current compiler works, else no; -dnl sets CROSS-VAR to yes if it produces non-native executables, else no. -dnl Before calling this, call AC_LANG_* to set the right language. +dnl Try to compile, link and execute TEST-PROGRAM. Set WORKING-VAR to +dnl `yes' if the current compiler works, otherwise set it ti `no'. Set +dnl CROSS-VAR to `yes' if the compiler and linker produce non-native +dnl executables, otherwise set it to `no'. Before calling +dnl `AC_TRY_COMPILER()', call `AC_LANG_*' to set-up for the right +dnl language. +dnl dnl AC_TRY_COMPILER(TEST-PROGRAM, WORKING-VAR, CROSS-VAR) AC_DEFUN(AC_TRY_COMPILER, -[cat > conftest.$ac_ext < conftest.$ac_ext << EOF +ifelse(AC_LANG, [FORTRAN77], , +[ [#]line __oline__ "configure" #include "confdefs.h" +]) [$1] EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then @@ -1546,6 +1565,7 @@ AC_CACHE_VAL(ac_cv_lib_$ac_lib_var, [ac_save_LIBS="$LIBS" LIBS="-l$1 $5 $LIBS" AC_TRY_LINK(dnl +ifelse(AC_LANG, [FORTRAN77], , ifelse([$2], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus @@ -1555,7 +1575,7 @@ extern "C" [/* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $2(); -]), +])), [$2()], eval "ac_cv_lib_$ac_lib_var=yes", eval "ac_cv_lib_$ac_lib_var=no") @@ -1681,7 +1701,11 @@ dnl AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) AC_DEFUN(AC_TRY_COMPILE, [cat > conftest.$ac_ext < conftest.$ac_ext < conftest.fpp </dev/null 2>&1; then + ac_cv_prog_g77=yes +else + ac_cv_prog_g77=no +fi])]) + AC_DEFUN(AC_PROG_CC_G, [AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g, [echo 'void f(){}' > conftest.c @@ -234,6 +326,24 @@ fi rm -f conftest* ])]) +dnl Test whether the Fortran compiler can accept the `-g' option to +dnl enable debugging. +dnl +dnl AC_PROG_FC_G() +AC_DEFUN(AC_PROG_FC_G, +[AC_CACHE_CHECK(whether $FC accepts -g, ac_cv_prog_fc_g, +[cat > conftest.f << EOF + program conftest + end +EOF +if test -z "`$FC -g -c conftest.f 2>&1`"; then + ac_cv_prog_fc_g=yes +else + ac_cv_prog_fc_g=no +fi +rm -f conftest* +])]) + AC_DEFUN(AC_PROG_GCC_TRADITIONAL, [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_CPP])dnl @@ -304,6 +414,45 @@ else fi ]) +dnl Test if the Fortran compiler accepts the options `-c' and `-o' +dnl simultaneously, and define `FC_NO_MINUS_C_MINUS_O' if it does not. +dnl +dnl The usefulness of this macro is questionable, as I can't really see +dnl why anyone would use it. The only reason I include it is for +dnl completeness, since a similar test exists for the C compiler. +dnl +dnl AC_PROG_FC_C_O +AC_DEFUN(AC_PROG_FC_C_O, +[AC_BEFORE([$0], [AC_PROG_FC])dnl +AC_MSG_CHECKING(whether $FC understand -c and -o together) +set dummy $FC; ac_fc="`echo [$]2 | +changequote(, )dnl +sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`" +changequote([, ])dnl +AC_CACHE_VAL(ac_cv_prog_fc_${ac_fc}_c_o, +[cat > conftest.f << EOF + program conftest + end +EOF +# We do the `AC_TRY_EVAL' test twice because some compilers refuse to +# overwrite an existing `.o' file with `-o', although they will create +# one. +ac_try='$FC $FFLAGS -c conftest.f -o conftest.o 1>&AC_FD_CC' +if AC_TRY_EVAL(ac_try) && test -f conftest.o && AC_TRY_EVAL(ac_try); then + eval ac_cv_prog_fc_${ac_fc}_c_o=yes +else + eval ac_cv_prog_fc_${ac_fc}_c_o=no +fi +rm -f conftest* +])dnl +if eval "test \"`echo '$ac_cv_prog_fc_'${ac_fc}_c_o`\" = yes"; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) + AC_DEFINE(FC_NO_MINUS_C_MINUS_O) +fi +]) + dnl Define SET_MAKE to set ${MAKE} if make doesn't. AC_DEFUN(AC_PROG_MAKE_SET, [AC_MSG_CHECKING(whether ${MAKE-make} sets \${MAKE})