automake-patches
[Top][All Lists]
Advanced

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

subdir-objects for Fortran


From: Ralf Wildenhues
Subject: subdir-objects for Fortran
Date: Tue, 5 Sep 2006 21:11:04 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

Automake currently assumes that '-c -o' is fine for all Fortran
dialects: output_flag is '-o' for all Fortran dialects.

So there is no reason not to have the lang_*_rewrite return the
right thing for subdir-objects support.  The patch below does that,
and also it adds some tests to ensure that this works in practice.
Please note that the tests, as written, will only work portably with
FCFLAGS_$ext support added (due soon).  So I will apply them only
after fixing that, but I'm posting it now so you can rip it apart.
:-)

(This should also help to explain naming of the tests; BTW, they
helped to uncover a couple of bugs in Autoconf and Libtool...)

OK?

The tests only exercise the Automake languages f77, fc, but not
ppf77, ppfc, ratfor.  Do you think we need tests for them, or we 
should rather not change the current settings for them?

I intend to fix subdir-object support for Assembler, too.  Also, I
plan to add AM_PROG_{CXX,F77,FC}_C_O for consistency (and to allow
users at their discretion to support even ancient systems like the
Cray-Cyber Fortran compiler that does not understand "-c -o"), but
that should not preclude this patch.

Cheers,
Ralf

        * automake.in (lang_f77_rewrite, lang_fc_rewrite)
        (lang_ppfc_rewrite, lang_ppf77_rewrite, lang_ratfor_rewrite):
        return `lang_sub_obj' to support subdir-object mode for the
        Fortran dialects.
        * tests/fort4.test, tests/fort5.test: New tests.
        * tests/Makefile.am: Update.
        * NEWS: Update.
        Report by Davyd Madeley <address@hidden>.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.315
diff -u -r1.315 NEWS
--- NEWS        5 Sep 2006 18:58:16 -0000       1.315
+++ NEWS        5 Sep 2006 19:00:24 -0000
@@ -1,5 +1,10 @@
 New in 1.9c:
 
+* Languages changes:
+
+  - subdir-object mode works now with Fortran (F77, FC, preprocessed
+    Fortran, and Ratfor).
+
 * Miscellaneous changes:
 
   - The script `install-sh' needs to have executable permissions for
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1631
diff -u -r1.1631 automake.in
--- automake.in 30 Aug 2006 20:35:56 -0000      1.1631
+++ automake.in 5 Sep 2006 18:49:09 -0000
@@ -5330,31 +5330,31 @@
 # Rewrite a single Fortran 77 file.
 sub lang_f77_rewrite
 {
-    return LANG_PROCESS;
+    return &lang_sub_obj;
 }
 
 # Rewrite a single Fortran file.
 sub lang_fc_rewrite
 {
-    return LANG_PROCESS;
+    return &lang_sub_obj;
 }
 
 # Rewrite a single preprocessed Fortran file.
 sub lang_ppfc_rewrite
 {
-    return LANG_PROCESS;
+    return &lang_sub_obj;
 }
 
 # Rewrite a single preprocessed Fortran 77 file.
 sub lang_ppf77_rewrite
 {
-    return LANG_PROCESS;
+    return &lang_sub_obj;
 }
 
 # Rewrite a single ratfor file.
 sub lang_ratfor_rewrite
 {
-    return LANG_PROCESS;
+    return &lang_sub_obj;
 }
 
 # Rewrite a single Objective C file.
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.609
diff -u -r1.609 Makefile.am
--- tests/Makefile.am   30 Aug 2006 20:35:56 -0000      1.609
+++ tests/Makefile.am   5 Sep 2006 18:49:09 -0000
@@ -245,6 +245,8 @@
 fnoc.test \
 fo.test        \
 fort1.test \
+fort4.test \
+fort5.test \
 fonly.test \
 fortdep.test \
 fpinst2.test \
--- /dev/null   2006-09-05 22:40:33.520458500 +0200
+++ tests/fort4.test    2006-09-05 20:48:22.000000000 +0200
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Copyright (C) 2006  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test mixing Fortran 77 and Fortran (FC).
+
+. ./defs || exit 1
+
+set -e
+
+mkdir sub
+
+cat >hello.f <<'END'
+      program hello
+      call foo
+      call bar
+      stop
+      end
+END
+
+cat >bye.f90 <<'END'
+program goodbye
+  call baz
+  stop
+end
+END
+
+cat >foo.f90 <<'END'
+      subroutine foo
+      return
+      end
+END
+
+sed s,foo,bar, foo.f90 > sub/bar.f90
+sed s,foo,baz, foo.f90 > sub/baz.f
+
+cat >>configure.in <<'END'
+AC_PROG_F77
+AC_PROG_FC
+AC_FC_SRCEXT([f90])
+AC_FC_LIBRARY_LDFLAGS
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello goodbye
+hello_SOURCES = hello.f foo.f90 sub/bar.f90
+goodbye_SOURCES = bye.f90 sub/baz.f
+goodbye_FCFLAGS = 
+LDADD = $(FCLIBS)
+END
+
+$ACLOCAL
+$AUTOMAKE
+# The Fortran 77 linker should be preferred:
+grep '.\$(FCLINK)' Makefile.in && exit 1
+
+$AUTOCONF
+./configure  # let's hope it exits 77 if no compiler was found
+$MAKE
+subobjs=`echo sub/*.o sub/*.obj`
+test "$subobjs" = 'sub/*.o sub/*.obj'
+$MAKE distcheck
+
+$MAKE distclean
+echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
+$AUTOMAKE
+./configure
+$MAKE
+test ! -f bar.o
+test ! -f bar.obj
+test ! -f baz.o
+test ! -f baz.obj
+test ! -f goodbye-baz.o
+test ! -f goodbye-baz.obj
+$MAKE distcheck
--- /dev/null   2006-09-05 22:40:33.520458500 +0200
+++ tests/fort5.test    2006-09-05 20:48:22.000000000 +0200
@@ -0,0 +1,103 @@
+#! /bin/sh
+# Copyright (C) 2006  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test mixing Fortran 77 and Fortran (FC), libtool version.
+
+required='libtoolize'
+. ./defs || exit 1
+
+set -e
+
+mkdir sub
+
+cat >hello.f <<'END'
+      program hello
+      call foo
+      call bar
+      call goodbye
+      stop
+      end
+END
+
+cat >bye.f90 <<'END'
+subroutine goodbye
+  call baz
+  return
+end
+END
+
+cat >foo.f90 <<'END'
+      subroutine foo
+      return
+      end
+END
+
+sed s,foo,bar, foo.f90 > sub/bar.f90
+sed s,foo,baz, foo.f90 > sub/baz.f
+
+cat >>configure.in <<'END'
+AC_PROG_F77
+AC_PROG_FC
+AC_FC_SRCEXT([f90])
+AC_FC_LIBRARY_LDFLAGS
+LT_PREREQ([2.0])
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello
+lib_LTLIBRARIES = libhello.la
+noinst_LTLIBRARIES = libgoodbye.la
+hello_SOURCES = hello.f
+hello_LDADD = libhello.la
+libhello_la_SOURCES = foo.f90 sub/bar.f90
+libhello_la_LIBADD = libgoodbye.la
+libgoodbye_la_SOURCES = bye.f90 sub/baz.f
+libgoodbye_la_FCFLAGS = 
+LDADD = $(FCLIBS)
+END
+
+libtoolize --force
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# This test requires Libtool >= 2.0.  Earlier Libtool does not
+# have the LT_PREREQ macro to cause autoconf failure, so let's
+# skip in this case:
+grep LT_PREREQ configure && exit 77
+
+./configure  # let's hope it exits 77 if no compiler was found
+$MAKE
+subobjs=`echo sub/*.lo`
+test "$subobjs" = 'sub/*.lo'
+$MAKE distcheck
+
+# The following will be fixed in a later patch:
+$MAKE distclean
+echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
+$AUTOMAKE -a
+./configure
+$MAKE
+test ! -f bar.lo
+test ! -f baz.lo
+test ! -f libgoodbye_la-baz.lo
+$MAKE distcheck




reply via email to

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