]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* m4/libtool.m4 (_LT_PROG_FC, _LT_LANG_FC_CONFIG): New macros
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Mon, 8 Aug 2005 09:27:09 +0000 (09:27 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Mon, 8 Aug 2005 09:27:09 +0000 (09:27 +0000)
for modern Fortran.
(LT_LANG, _LT_LANG_DEFAULT_CONFIG, _LT_SYS_DYNAMIC_LINKER,
_LT_SYS_HIDDEN_LIBDEPS): Adjusted.
* tests/fcdemo-conf.test, tests/fcdemo-exec.test,
tests/fcdemo-make.test, tests/fcdemo-shared.test,
tests/fcdemo-static.test, tests/fcdemo/Makefile.am, tests/fcdemo/README,
tests/fcdemo/configure.ac, tests/fcdemo/cprogram.c, tests/fcdemo/foo.h,
tests/fcdemo/fooc.c, tests/fcdemo/foof.f90, tests/fcdemo/foof2.f90,
tests/fcdemo/foof3.f90, tests/fcdemo/fprogram.f90: New tests for Fortran.
* Makefile.am, configure.ac: Adjusted.
* NEWS: Updated.

21 files changed:
ChangeLog
Makefile.am
NEWS
configure.ac
m4/libtool.m4
tests/fcdemo-conf.test [new file with mode: 0755]
tests/fcdemo-exec.test [new file with mode: 0755]
tests/fcdemo-make.test [new file with mode: 0755]
tests/fcdemo-shared.test [new file with mode: 0755]
tests/fcdemo-static.test [new file with mode: 0755]
tests/fcdemo/.cvsignore [new file with mode: 0644]
tests/fcdemo/Makefile.am [new file with mode: 0644]
tests/fcdemo/README [new file with mode: 0644]
tests/fcdemo/configure.ac [new file with mode: 0644]
tests/fcdemo/cprogram.c [new file with mode: 0644]
tests/fcdemo/foo.h [new file with mode: 0644]
tests/fcdemo/fooc.c [new file with mode: 0644]
tests/fcdemo/foof.f90 [new file with mode: 0644]
tests/fcdemo/foof2.f90 [new file with mode: 0644]
tests/fcdemo/foof3.f90 [new file with mode: 0644]
tests/fcdemo/fprogram.f90 [new file with mode: 0644]

index b872b49071aa175836c5d10376d734ccb41c4e2c..a081dfc7e07d62dc4f0c67b226e64258c7edb9a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2005-08-08  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       * m4/libtool.m4 (_LT_PROG_FC, _LT_LANG_FC_CONFIG): New macros
+       for modern Fortran.
+       (LT_LANG, _LT_LANG_DEFAULT_CONFIG, _LT_SYS_DYNAMIC_LINKER,
+       _LT_SYS_HIDDEN_LIBDEPS): Adjusted.
+       * tests/fcdemo-conf.test, tests/fcdemo-exec.test,
+       tests/fcdemo-make.test, tests/fcdemo-shared.test,
+       tests/fcdemo-static.test, tests/fcdemo/Makefile.am, tests/fcdemo/README,
+       tests/fcdemo/configure.ac, tests/fcdemo/cprogram.c, tests/fcdemo/foo.h,
+       tests/fcdemo/fooc.c, tests/fcdemo/foof.f90, tests/fcdemo/foof2.f90,
+       tests/fcdemo/foof3.f90, tests/fcdemo/fprogram.f90: New tests for Fortran.
+       * Makefile.am, configure.ac: Adjusted.
+       * NEWS: Updated.
+
        * AUTHORS, HACKING: Updated.
 
 2005-08-05  Albert Chin-A-Young  <china@thewrittenword.com>
index b32e6d88357f0169b8035076cc596d7210880cb7..d31ae1fc775378fc2ee9cfffa2b01fbb6510ecf6 100644 (file)
@@ -276,9 +276,9 @@ TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
        OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" CONFIG_SHELL="$(SHELL)" \
        CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" CXXCPP="$(CXXCPP)" \
        F77="$(F77)" FFLAGS="$(FFLAGS)" \
+       FC="$(FC)" FCFLAGS="$(FCFLAGS)" \
        GCJ="$(GCJ)" GCJFLAGS="$(GCJFLAGS)"
 
-
 CXX_TESTS = \
        tests/tagdemo-static.test tests/tagdemo-make.test \
        tests/tagdemo-exec.test tests/tagdemo-conf.test \
@@ -294,6 +294,13 @@ F77_TESTS = \
        tests/f77demo-shared.test tests/f77demo-make.test \
        tests/f77demo-exec.test
 
+FC_TESTS = \
+       tests/fcdemo-static.test tests/fcdemo-make.test \
+       tests/fcdemo-exec.test tests/fcdemo-conf.test \
+       tests/fcdemo-make.test tests/fcdemo-exec.test \
+       tests/fcdemo-shared.test tests/fcdemo-make.test \
+       tests/fcdemo-exec.test
+
 COMMON_TESTS = \
        tests/link.test tests/link-2.test tests/nomode.test \
        tests/objectlist.test tests/quote.test tests/sh.test \
@@ -336,24 +343,21 @@ COMMON_TESTS = \
        tests/cdemo-undef.test tests/cdemo-make.test tests/cdemo-exec.test \
        tests/duplicate_members.test
 
+TESTS = $(COMMON_TESTS)
 if HAVE_CXX
-if HAVE_F77
-TESTS = $(COMMON_TESTS) $(CXX_TESTS) $(F77_TESTS)
-else
-TESTS = $(COMMON_TESTS) $(CXX_TESTS)
+TESTS += $(CXX_TESTS)
 endif
-else
 if HAVE_F77
-TESTS = $(COMMON_TESTS) $(F77_TESTS)
-else
-TESTS = $(COMMON_TESTS)
+TESTS += $(F77_TESTS)
 endif
+if HAVE_FC
+TESTS += $(FC_TESTS)
 endif
 
 tests/demo-conf.test: libtool
 
 EXTRA_DIST     += tests/defs.in tests/defs.m4sh \
-                 $(COMMON_TESTS) $(CXX_TESTS) $(F77_TESTS)
+                 $(COMMON_TESTS) $(CXX_TESTS) $(F77_TESTS) $(FC_TESTS)
 DIST_SUBDIRS   += $(CONF_SUBDIRS)
 
 # The defs script shouldn't be recreated whenever the Makefile is
@@ -376,7 +380,7 @@ $(srcdir)/tests/defs.in: config/general.m4sh tests/defs.m4sh Makefile.am
 # We need to remove any files that the above tests created.
 clean-local:
        -cd tests; \
-       for dir in cdemo demo depdemo f77demo mdemo mdemo2 pdemo tagdemo; \
+       for dir in cdemo demo depdemo f77demo fcdemo mdemo mdemo2 pdemo tagdemo; \
        do \
            test -f $$dir/Makefile && ( cd $$dir && $(MAKE) distclean; ); \
        done
diff --git a/NEWS b/NEWS
index 3db63a19da4f6606a51abaadf1749e34be1ea75d..aeb219c467b4590743b2f3b973993bf102071f10 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ New in 1.9h: 2004-??-??; CVS version 1.9g, Libtool team:
 * Allow shell special characters like `$' in source file names, but not
   in object names, to enhance GCJ support.
 * Detection of compiler wrappers like distcc/ccache and $host_alias prefix.
+* Initial Support for FC (modern Fortran).
 \f
 New in 1.9f: 2004-10-23; CVS version 1.9e, Libtool team:
 * Calculate dllsearchpath correctly for wrapper scripts on cygwin.
index a7d16726c3d8999fc8607470adcfcea493a8bd11..814175d713bf1592f93259710f6e115cf82e16cd 100644 (file)
@@ -137,8 +137,8 @@ fi
 
 # All subdirectories that are configured on demand, but that must be
 # included in the distribution.
-CONF_SUBDIRS="tests/cdemo tests/demo tests/depdemo tests/f77demo tests/mdemo \
-       tests/mdemo2 tests/pdemo tests/tagdemo"
+CONF_SUBDIRS="tests/cdemo tests/demo tests/depdemo tests/f77demo tests/fcdemo \
+       tests/mdemo tests/mdemo2 tests/pdemo tests/tagdemo"
 AC_SUBST([CONF_SUBDIRS])
 
 DIST_MAKEFILE_LIST=
@@ -168,6 +168,7 @@ LTDL_INIT
 # Enable all the language support we can
 LT_LANG(C++)
 LT_LANG(Fortran 77)
+LT_LANG(Fortran)
 LT_LANG(Java)
 LT_LANG(Windows Resource)
 
@@ -177,6 +178,7 @@ LT_LANG(Windows Resource)
 ## --------------------------- ##
 AM_CONDITIONAL(HAVE_CXX,[test -n "[$]_LT_TAGVAR(compiler, CXX)"])
 AM_CONDITIONAL(HAVE_F77,[test -n "[$]_LT_TAGVAR(compiler, F77)"])
+AM_CONDITIONAL(HAVE_FC,[test -n "[$]_LT_TAGVAR(compiler, FC)"])
 AM_CONDITIONAL(HAVE_GCJ, [test -n "[$]_LT_TAGVAR(compiler, GCJ)"])
 AM_CONDITIONAL(HAVE_RC, [test -n "[$]_LT_TAGVAR(compiler, RC)"])
 
index d88ef6df895e33a827c806ec5a08f718819e0e49..a6ae69121b512abf3af32173d7eb2605efff768b 100644 (file)
@@ -608,6 +608,7 @@ AC_DEFUN([LT_LANG],
   [C++],               [_LT_LANG(CXX)],
   [Java],              [_LT_LANG(GCJ)],
   [Fortran 77],                [_LT_LANG(F77)],
+  [Fortran],           [_LT_LANG(FC)],
   [Windows Resource],  [_LT_LANG(RC)],
   [m4_ifdef([_LT_LANG_]$1[_CONFIG],
     [_LT_LANG($1)],
@@ -635,6 +636,10 @@ AC_PROVIDE_IFELSE([AC_PROG_F77],
   [LT_LANG(F77)],
   [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
 
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+  [LT_LANG(FC)],
+  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
 dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
 dnl pulling things in needlessly.
 AC_PROVIDE_IFELSE([AC_PROG_GCJ],
@@ -658,10 +663,12 @@ AC_PROVIDE_IFELSE([LT_PROG_RC],
 # Obsolete macros:
 AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
 AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
 AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
 dnl aclocal-1.4 backwards compatibility:
 dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
 dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
 dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
 
 
@@ -1683,6 +1690,7 @@ m4_case([$1],
        [C], [withGCC=$GCC],
        [CXX], [withGCC=$GXX],
        [F77], [withGCC=$G77],
+       [FC], [withGCC=$ac_cv_fc_compiler_gnu],
        [withGCC=$GCC])
 library_names_spec=
 libname_spec='lib$name'
@@ -5671,6 +5679,14 @@ _LT_EOF
       return
       end
 _LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer a
+      a=0
+      return
+      end
+_LT_EOF
 ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
 public class foo {
   private int a;
@@ -5916,6 +5932,140 @@ AC_LANG_POP
 ])# _LT_LANG_F77_CONFIG
 
 
+# _LT_PROG_FC
+# -----------
+# Since AC_PROG_FC is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_FC],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
+AC_PROG_FC
+if test -z "$FC" || test "X$FC" = "Xno"; then
+  _lt_disable_FC=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_FC
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_REQUIRE([_LT_PROG_FC])dnl
+AC_LANG_PUSH(Fortran)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="      program t\n      end\n"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  CC=${FC-"f95"}
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix4* | aix5*)
+       if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+         test "$enable_shared" = yes && enable_static=no
+       fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+    _LT_CMD_STRIPLIB
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
 # _LT_LANG_GCJ_CONFIG([TAG])
 # --------------------------
 # Ensure that the configuration variables for the GNU Java Compiler compiler
diff --git a/tests/fcdemo-conf.test b/tests/fcdemo-conf.test
new file mode 100755 (executable)
index 0000000..2b3e474
--- /dev/null
@@ -0,0 +1,32 @@
+#! /bin/sh
+# fcdemo-conf.test - try configuring the fcdemo subdirectory
+
+# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# 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 of the License, 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, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+. tests/defs || exit 1
+
+func_mkprefixdir
+func_cd "tests/fcdemo"
+func_make_distclean
+func_configure
+func_check_static_shared "yes" "yes"
+
+exit 0
diff --git a/tests/fcdemo-exec.test b/tests/fcdemo-exec.test
new file mode 100755 (executable)
index 0000000..7d8588d
--- /dev/null
@@ -0,0 +1,33 @@
+#! /bin/sh
+# fcdemo-exec.test - check that programs in the fcdemo subdirectory are viable
+
+# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# 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 of the License, 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, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+. tests/defs || exit 1
+
+func_require "fcdemo-make" "tests/fcdemo/fprogram$EXEEXT" "tests/fcdemo/cprogram$EXEEXT"
+
+func_rmprefixdir
+func_exec_init "uninstalled"
+func_exec "tests/fcdemo/fprogram"
+func_exec "tests/fcdemo/cprogram"
+
+exit $exec_status
diff --git a/tests/fcdemo-make.test b/tests/fcdemo-make.test
new file mode 100755 (executable)
index 0000000..9dab990
--- /dev/null
@@ -0,0 +1,34 @@
+#! /bin/sh
+# fcdemo-make.test - try building in the fcdemo subdirectory
+
+# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# 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 of the License, 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, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+. tests/defs || exit 1
+
+func_require "fcdemo-conf" "tests/fcdemo/Makefile"
+
+func_rmprefixdir
+func_cd "tests/fcdemo"
+# May fail make on some platforms, simply "skip" in that case
+#func_make
+eval $MAKE || func_skip "The improved fortran tests catch a known failure mode"
+
+exit 0
diff --git a/tests/fcdemo-shared.test b/tests/fcdemo-shared.test
new file mode 100755 (executable)
index 0000000..ce2b68e
--- /dev/null
@@ -0,0 +1,32 @@
+#! /bin/sh
+# fcdemo-shared.test - try configuring the fcdemo subdirectory for shared libs
+
+# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# 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 of the License, 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, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+. tests/defs || exit 1
+
+func_mkprefixdir
+func_cd "tests/fcdemo"
+func_make_distclean
+func_configure "--disable-static"
+func_check_static_shared "no" "yes"
+
+exit 0
diff --git a/tests/fcdemo-static.test b/tests/fcdemo-static.test
new file mode 100755 (executable)
index 0000000..2f960b8
--- /dev/null
@@ -0,0 +1,32 @@
+#! /bin/sh
+# fcdemo-static.test - try configuring the fcdemo subdirectory for static libs
+
+# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# 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 of the License, 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, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+. tests/defs || exit 1
+
+func_mkprefixdir
+func_cd "tests/fcdemo"
+func_make_distclean
+func_configure "--disable-shared"
+func_check_static_shared "yes" "no"
+
+exit 0
diff --git a/tests/fcdemo/.cvsignore b/tests/fcdemo/.cvsignore
new file mode 100644 (file)
index 0000000..30c8944
--- /dev/null
@@ -0,0 +1,17 @@
+.deps
+.libs
+Makefile
+Makefile.in
+acinclude.m4
+aclocal.m4
+autom4te.cache
+configure
+config.*
+config-h.in
+conftest*
+libtool
+*.lo
+*.la
+stamp-h*
+cprogram
+fprogram
diff --git a/tests/fcdemo/Makefile.am b/tests/fcdemo/Makefile.am
new file mode 100644 (file)
index 0000000..10b33fa
--- /dev/null
@@ -0,0 +1,51 @@
+## Makefile.am -- Process this file with automake to produce Makefile.in
+##
+## Copyright (C) 2003, 2004, 2005 Free Software Foundation
+##
+## 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 of the License, 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; see the file COPYING.  If not, write to
+## the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+## Boston, MA 02110-1301, USA.
+
+AUTOMAKE_OPTIONS = no-dependencies foreign
+ACLOCAL_AMFLAGS  = -I ../../m4
+AM_CPPFLAGS     = -I$(top_srcdir)/../..
+
+lib_LTLIBRARIES = libfoo.la libmix.la libfoo2.la libfoo3.la
+
+libfoo_la_SOURCES = foof.f90
+libfoo_la_LDFLAGS = -no-undefined
+libfoo_la_LIBADD = libfoo2.la
+
+libfoo2_la_SOURCES = foof2.f90
+libfoo2_la_LDFLAGS = -no-undefined
+
+libfoo3_la_SOURCES = foof3.f90
+libfoo3_la_LDFLAGS = -no-undefined
+
+libmix_la_SOURCES = foof.f90 foof2.f90 fooc.c
+libmix_la_LDFLAGS = -no-undefined
+
+noinst_HEADERS = foo.h
+
+bin_PROGRAMS = fprogram cprogram
+
+fprogram_SOURCES = fprogram.f90
+fprogram_LDADD = libfoo.la libfoo3.la
+
+cprogram_SOURCES = cprogram.c
+cprogram_LDADD = libmix.la $(FCLIBS)
+
+$(OBJECTS): libtool
+libtool: $(LIBTOOL_DEPS)
+       $(SHELL) ./config.status --recheck
diff --git a/tests/fcdemo/README b/tests/fcdemo/README
new file mode 100644 (file)
index 0000000..50cee2b
--- /dev/null
@@ -0,0 +1,16 @@
+This is a short demo of the fortran support in libtool.
+
+fprogram is a pure-fortran program which is linked 
+against the fortran-only library libfoo.la
+
+cprogram is a C program, which is linked against the
+mixed C and fortran library libmix.la. The program
+calls a C function, which in turn calls a fortran 
+function.
+
+This demo requires GNU autoconf, automake, 
+libtool with the FC tag and quite obvious Fortran.
+
+
+
+
diff --git a/tests/fcdemo/configure.ac b/tests/fcdemo/configure.ac
new file mode 100644 (file)
index 0000000..61ef86e
--- /dev/null
@@ -0,0 +1,79 @@
+## Process this file with autoconf to create configure. -*- autoconf -*-
+# Copyright (C) 2001, 2003, 2005 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 of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301  USA
+
+AC_PREREQ(2.54)
+
+## ------------------------ ##
+## Autoconf initialisation. ##
+## ------------------------ ##
+AC_INIT([fcdemo], [1.0], [bug-libtool@gnu.org])
+AC_CONFIG_HEADERS([config.h:config-h.in])
+AC_CONFIG_SRCDIR([foof.f90])
+AC_CONFIG_AUX_DIR([../../config])
+
+## ------------------------ ##
+## Automake Initialisation. ##
+## ------------------------ ##
+AM_INIT_AUTOMAKE
+
+
+## ------------------ ##
+## C compiler checks. ##
+## ------------------ ##
+AC_PROG_CC
+
+## ------------------------ ##
+## Fortran compiler checks. ##
+## ------------------------ ##
+AC_LANG_PUSH([Fortran])
+AC_PROG_FC
+dnl Check the flags needed to link fc programs with ld (i.e. cc)
+AC_FC_LIBRARY_LDFLAGS
+dnl Check for underscoring of external names
+AC_FC_WRAPPERS
+dnl We need to use .f90 and not .f to enable Automake FC support
+dnl Some Intel ifc/ifort do not understand .f95.  :-/
+AC_FC_SRCEXT([f90])
+dnl Yes, we want free form Fortran!
+AC_FC_FREEFORM
+AC_LANG_POP
+
+
+# As of the writing of this demo, GNU Autoconf's AC_OBJEXT and
+# AC_EXEEXT macros only works for C compilers!
+# Libtool's setup macro calls AC_OBJEXT and AC_EXEEXT without setting
+# the test language to C.  We do it before any libtool setup macros are
+# called so that the proper values are cached beforehand.  We also do
+# it before any linker flags (LDFLAGS) are set so that fortran specific
+# ones don't break the tests.
+AC_LANG_PUSH([C])
+AC_OBJEXT
+AC_EXEEXT
+AC_LANG_POP
+
+## ----------------------- ##
+## Libtool initialisation. ##
+## ----------------------- ##
+LT_INIT
+AC_SUBST([LIBTOOL_DEPS])
+
+## -------- ##
+## Outputs. ##
+## -------- ##
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/tests/fcdemo/cprogram.c b/tests/fcdemo/cprogram.c
new file mode 100644 (file)
index 0000000..65e60cc
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+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 of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+USA. */
+
+#include "foo.h"
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+  int arg,cres,fres;
+  
+  printf ("Welcome to GNU libtool mixed C/Fortran demo!\n");
+  
+  arg=2;
+  
+  cres=csub(arg);
+  
+  printf ("The C subroutine returned, claiming that 2*%d = %d\n",arg,cres);
+  
+  if(cres==2*arg)
+    printf ("The C subroutine is ok!\n");
+  
+  printf("\nCalling the C wrapper routine...\n");
+  fres=fwrapper(arg);
+  
+  printf ("The C wrapper to the fortran subroutine returned,\n"
+         "claiming that 2*%d = %d\n",arg,fres);
+  
+  if(fres==2*arg)
+    printf ("The Fortran subroutine is ok!\n");
+  
+  return 0;
+}
+
diff --git a/tests/fcdemo/foo.h b/tests/fcdemo/foo.h
new file mode 100644 (file)
index 0000000..e62e004
--- /dev/null
@@ -0,0 +1,47 @@
+/* foo.h -- interface to fortran and C libraries
+   Copyright (C) 1998-1999, 2005 Free Software Foundation, Inc.
+   This file is part of GNU Libtool.
+
+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 of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+USA. */
+
+#ifndef _FOO_H_
+#define _FOO_H_ 1
+
+/* config.h is necessary for the fortran name mangling */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* csub is an extremely useful subroutine that
+ * returns the argument multiplied by two :-)
+ */
+extern int csub(int);
+
+/* This routine performs the same action, but
+ * calls the fortran subroutine fsub to do the 
+ * real work.
+ */
+extern int fwrapper(int);
+
+/* fsub does the same thing as csub, i.e. res=arg*2.
+ * Use autoconf macro for fortran function names.
+ * Note that fortran passes args by reference, so
+ * you need to provide pointers to your ints.
+ */
+extern void FC_FUNC(fsub,FSUB)(int *arg, int *res);
+
+
+#endif
diff --git a/tests/fcdemo/fooc.c b/tests/fcdemo/fooc.c
new file mode 100644 (file)
index 0000000..8f11409
--- /dev/null
@@ -0,0 +1,17 @@
+#include "foo.h"
+#include <stdio.h>
+
+int csub(int arg)
+{
+  return (2*arg);
+}
+
+
+int fwrapper(int arg)
+{
+  int res;
+  printf("Calling the Fortran subroutine from the C wrapper...\n");
+  FC_FUNC(fsub,FSUB)(&arg,&res);
+  printf("Returned from the Fortran subroutine...\n");
+  return res;
+}
diff --git a/tests/fcdemo/foof.f90 b/tests/fcdemo/foof.f90
new file mode 100644 (file)
index 0000000..794dde9
--- /dev/null
@@ -0,0 +1,11 @@
+! 
+! 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
+! of the License, or (at your option) any later version.
+! 
+subroutine fsub(arg,res)
+  write(*,*) 'fsub called'
+  call fsubf(arg,res)
+  return
+end
diff --git a/tests/fcdemo/foof2.f90 b/tests/fcdemo/foof2.f90
new file mode 100644 (file)
index 0000000..913868b
--- /dev/null
@@ -0,0 +1,13 @@
+! 
+! 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
+! of the License, or (at your option) any later version.
+! 
+subroutine fsubf(arg,res)
+  implicit none
+  integer arg,res
+  write(*,*) 'fsubf called'
+  res=arg*2
+  return
+end
diff --git a/tests/fcdemo/foof3.f90 b/tests/fcdemo/foof3.f90
new file mode 100644 (file)
index 0000000..922751b
--- /dev/null
@@ -0,0 +1,13 @@
+! 
+! 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
+! of the License, or (at your option) any later version.
+! 
+subroutine fsub3(arg,res)
+  implicit none
+  integer arg,res
+  write(*,*) 'fsub3 called'
+  res=arg*4
+  return
+end
diff --git a/tests/fcdemo/fprogram.f90 b/tests/fcdemo/fprogram.f90
new file mode 100644 (file)
index 0000000..dca35b8
--- /dev/null
@@ -0,0 +1,32 @@
+! 
+! 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
+! of the License, or (at your option) any later version.
+! 
+program fprogram
+  implicit none
+  integer arg,res
+
+  write(*,*) 'Welcome to GNU libtool Fortran demo!'
+  write(*,*) 'Real programmers write in FORTRAN.'
+  arg=2
+
+  call fsub(arg,res)
+
+  write(*,*) 'fsub returned, saying that 2 *',arg,' =',res
+
+  if (res.eq.4) then
+     write(*,*) 'fsub is ok!'
+  endif
+
+  call fsub3(arg,res)
+
+  write(*,*) 'fsub3 returned, saying that 4 *',arg,' =',res
+
+  if (res.eq.8) then
+     write(*,*) 'fsub3 is ok!'
+  endif
+
+  stop
+end