autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking for compiler flag support


From: J. Gregory Wright
Subject: Checking for compiler flag support
Date: Wed, 17 Mar 2004 18:17:44 -0500

This is my first time trying to set up a build using autoconf and automake,
which I have chosen to deal with the fact that I must set up a bunch of
Fortran 77 code so that it can be readily ported to various *nix flavors,
with a mix of GNU and native Fortran compilers. One of the problems with
Fortran 77 is a default 72 character limit on lines in source files, which
most Fortran 77 compilers provide support to override this limit with a
compiler flag. So what I set out to do at first is [I thought] fairly simple
– check to see if the selected compiler supports a given flag. Not having
any experience with M4 or autoconf, I have been stumbling around trying to
write my own macro by looking at the macro archives and the fortran.m4 and
c.m4 files, and I have reached a point where I do not understand why I am
getting a particular error when I run configure (aclocal and autoconf
complete without errors).

That being said, I have included my brief acinclude.m4, configure.ac,
configure output and the code generated for this section in configure. Any
guidance on (a) how to fix this particular problem, or (b) a better way to
approach this, would be greatly appreciated. My apologies if this is too
long for the list - I couldn't tell what was too long from the archives.

acinclude.m4:

# Use with autoconf 2.57 or higher.

# Check for support of a compiler flag

AC_DEFUN([AX_F77_COMPILER_FLAG],
         [AC_REQUIRE([AC_PROG_F77])
          AC_LANG_PUSH([Fortran 77])
          AS_VAR_PUSHDEF([ax_save_FFLAGS],[FFLAGS])
          ax_save_FFLAGS=$FFLAGS
          FFLAGS="-$1"
          AC_CACHE_CHECK([whether $F77 accepts -$1],
                         [ac_cv_prog_${F77}_$1],
                         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
                                             [ac_cv_prog_${F77}_$1=yes],
                                             [ac_cv_prog_${F77}_$1=no]
                                            )
                         ]
                        )
          if test ac_cv_prog_${F77}_$1 = yes ; then
            AC_MSG_RESULT(yes)
          else
            AC_MSG_RESULT(no)
          fi
          FFLAGS=$ax_save_FFLAGS
          AS_VAR_POPDEF([ax_save_FFLAGS])
          AC_LANG_POP([Fortran 77])
])

configure.ac:

# Initialize Autoconf

AC_PREREQ(2.57)
AC_INIT([My Autotools Test],[1.0],address@hidden,[myat_test])
AC_CONFIG_SRCDIR([src/tool1.f])

# Initialize Automake
AM_INIT_AUTOMAKE

# Perform FORTRAN Compiler Checks
AC_LANG([Fortran 77])
AC_PROG_F77
AC_F77_LIBRARY_LDFLAGS
AC_F77_WRAPPERS
AX_F77_COMPILER_FLAG([e])

# Perform C Compiler Checks
AC_LANG([C])
AC_PROG_CC

# Set up outputs
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
address@hidden myat_test]$

output:

$ aclocal
$ autoconf
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for g77... g77
checking for Fortran 77 compiler default output... a.out
checking whether the Fortran 77 compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether g77 accepts -g... yes
checking how to get verbose linking output from g77... -v
checking for Fortran 77 libraries...
-L/usr/lib/gcc-lib/i386-redhat-linux/3.3.2
-L/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../.. -lfrtbegin -lg2c -lm
-lgcc_s
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking dependency style of gcc... none
checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... lower case, underscore,
extra underscore
checking whether g77 accepts -e... ./configure: line 3662:
ac_cv_prog_g77_e=no: command not found

no
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ANSI C... (cached) none needed
checking dependency style of gcc... (cached) none
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: executing depfiles commands
$

          FFLAGS=$FFLAGS
          FFLAGS="-e"
          echo "$as_me:$LINENO: checking whether $F77 accepts -e" >&5
echo $ECHO_N "checking whether $F77 accepts -e... $ECHO_C" >&6
if eval "test \"\${ac_cv_prog_${F77}_e+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
      program main

      end
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  echo "$as_me:$LINENO: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_prog_${F77}_e=yes
else
  echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

ac_cv_prog_${F77}_e=no

fi
   
--
J. Gregory Wright <address@hidden>
 
Integrity Applications Incorporated <http://www.integrity-apps.com>
703-378-8672 x260






reply via email to

[Prev in Thread] Current Thread [Next in Thread]