* 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.
* tests/convenience.at: Extended.
* Makefile.am, configure.ac: Adjusted.
* NEWS: Updated.
This commit is contained in:
Ralf Wildenhues 2005-08-08 09:23:57 +00:00
parent 6d1b0beae3
commit a1b595f6ab
22 changed files with 734 additions and 14 deletions

View File

@ -1,5 +1,19 @@
2005-08-08 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> 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.
* tests/convenience.at: Extended.
* Makefile.am, configure.ac: Adjusted.
* NEWS: Updated.
* AUTHORS, HACKING: Updated. * AUTHORS, HACKING: Updated.
2005-08-05 Albert Chin-A-Young <china@thewrittenword.com> 2005-08-05 Albert Chin-A-Young <china@thewrittenword.com>

View File

@ -312,6 +312,7 @@ TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" CONFIG_SHELL="$(SHELL)" \ OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" CONFIG_SHELL="$(SHELL)" \
CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" CXXCPP="$(CXXCPP)" \ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" CXXCPP="$(CXXCPP)" \
F77="$(F77)" FFLAGS="$(FFLAGS)" \ F77="$(F77)" FFLAGS="$(FFLAGS)" \
FC="$(FC)" FCFLAGS="$(FCFLAGS)" \
GCJ="$(GCJ)" GCJFLAGS="$(GCJFLAGS)" GCJ="$(GCJ)" GCJFLAGS="$(GCJFLAGS)"
check-recursive: $(srcdir)/$(TESTSUITE) check-recursive: $(srcdir)/$(TESTSUITE)
@ -379,6 +380,13 @@ F77_TESTS = \
tests/f77demo-shared.test tests/f77demo-make.test \ tests/f77demo-shared.test tests/f77demo-make.test \
tests/f77demo-exec.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 = \ COMMON_TESTS = \
tests/link.test tests/link-2.test tests/nomode.test \ tests/link.test tests/link-2.test tests/nomode.test \
tests/objectlist.test tests/quote.test tests/sh.test \ tests/objectlist.test tests/quote.test tests/sh.test \
@ -420,24 +428,21 @@ COMMON_TESTS = \
tests/mdemo-inst.test tests/mdemo-unst.test \ tests/mdemo-inst.test tests/mdemo-unst.test \
tests/cdemo-undef.test tests/cdemo-make.test tests/cdemo-exec.test tests/cdemo-undef.test tests/cdemo-make.test tests/cdemo-exec.test
if HAVE_CXX
if HAVE_F77
TESTS = $(COMMON_TESTS) $(CXX_TESTS) $(F77_TESTS)
else
TESTS = $(COMMON_TESTS) $(CXX_TESTS)
endif
else
if HAVE_F77
TESTS = $(COMMON_TESTS) $(F77_TESTS)
else
TESTS = $(COMMON_TESTS) TESTS = $(COMMON_TESTS)
if HAVE_CXX
TESTS += $(CXX_TESTS)
endif endif
if HAVE_F77
TESTS += $(F77_TESTS)
endif
if HAVE_FC
TESTS += $(FC_TESTS)
endif endif
tests/demo-conf.test: libtool tests/demo-conf.test: libtool
EXTRA_DIST += tests/defs.in tests/defs.m4sh \ 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) DIST_SUBDIRS += $(CONF_SUBDIRS)
# The defs script shouldn't be recreated whenever the Makefile is # The defs script shouldn't be recreated whenever the Makefile is
@ -459,7 +464,7 @@ $(srcdir)/tests/defs.in: config/general.m4sh tests/defs.m4sh Makefile.am
# We need to remove any files that the above tests created. # We need to remove any files that the above tests created.
clean-local-legacy: clean-local-legacy:
-cd tests; \ -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 \ do \
test -f $$dir/Makefile && ( cd $$dir && $(MAKE) distclean; ); \ test -f $$dir/Makefile && ( cd $$dir && $(MAKE) distclean; ); \
done done

1
NEWS
View File

@ -11,6 +11,7 @@ New in 2.1b: 2005-??-??; CVS version 2.1a, Libtool team:
* Allow shell special characters like `$' in source file names, but not * Allow shell special characters like `$' in source file names, but not
in object names, to enhance GCJ support. in object names, to enhance GCJ support.
* Detection of compiler wrappers like distcc/ccache and $host_alias prefix. * Detection of compiler wrappers like distcc/ccache and $host_alias prefix.
* Initial Support for FC (modern Fortran).
New in 1.9h: 2004-??-??; CVS version 1.9g, Libtool team: New in 1.9h: 2004-??-??; CVS version 1.9g, Libtool team:
* Bug fixes. * Bug fixes.

View File

@ -136,8 +136,8 @@ fi
# All subdirectories that are configured on demand, but that must be # All subdirectories that are configured on demand, but that must be
# included in the distribution. # included in the distribution.
CONF_SUBDIRS="tests/cdemo tests/demo tests/depdemo tests/f77demo tests/mdemo \ CONF_SUBDIRS="tests/cdemo tests/demo tests/depdemo tests/f77demo tests/fcdemo \
tests/mdemo2 tests/pdemo tests/tagdemo" tests/mdemo tests/mdemo2 tests/pdemo tests/tagdemo"
AC_SUBST([CONF_SUBDIRS]) AC_SUBST([CONF_SUBDIRS])
DIST_MAKEFILE_LIST= DIST_MAKEFILE_LIST=
@ -166,6 +166,7 @@ LTDL_INIT
# Enable all the language support we can # Enable all the language support we can
LT_LANG(C++) LT_LANG(C++)
LT_LANG(Fortran 77) LT_LANG(Fortran 77)
LT_LANG(Fortran)
LT_LANG(Java) LT_LANG(Java)
LT_LANG(Windows Resource) LT_LANG(Windows Resource)
@ -175,6 +176,7 @@ LT_LANG(Windows Resource)
## --------------------------- ## ## --------------------------- ##
AM_CONDITIONAL(HAVE_CXX,[test -n "[$]_LT_TAGVAR(compiler, CXX)"]) AM_CONDITIONAL(HAVE_CXX,[test -n "[$]_LT_TAGVAR(compiler, CXX)"])
AM_CONDITIONAL(HAVE_F77,[test -n "[$]_LT_TAGVAR(compiler, F77)"]) 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_GCJ, [test -n "[$]_LT_TAGVAR(compiler, GCJ)"])
AM_CONDITIONAL(HAVE_RC, [test -n "[$]_LT_TAGVAR(compiler, RC)"]) AM_CONDITIONAL(HAVE_RC, [test -n "[$]_LT_TAGVAR(compiler, RC)"])

150
m4/libtool.m4 vendored
View File

@ -629,6 +629,7 @@ AC_DEFUN([LT_LANG],
[C++], [_LT_LANG(CXX)], [C++], [_LT_LANG(CXX)],
[Java], [_LT_LANG(GCJ)], [Java], [_LT_LANG(GCJ)],
[Fortran 77], [_LT_LANG(F77)], [Fortran 77], [_LT_LANG(F77)],
[Fortran], [_LT_LANG(FC)],
[Windows Resource], [_LT_LANG(RC)], [Windows Resource], [_LT_LANG(RC)],
[m4_ifdef([_LT_LANG_]$1[_CONFIG], [m4_ifdef([_LT_LANG_]$1[_CONFIG],
[_LT_LANG($1)], [_LT_LANG($1)],
@ -656,6 +657,10 @@ AC_PROVIDE_IFELSE([AC_PROG_F77],
[LT_LANG(F77)], [LT_LANG(F77)],
[m4_define([AC_PROG_F77], defn([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 The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
dnl pulling things in needlessly. dnl pulling things in needlessly.
AC_PROVIDE_IFELSE([AC_PROG_GCJ], AC_PROVIDE_IFELSE([AC_PROG_GCJ],
@ -679,10 +684,12 @@ AC_PROVIDE_IFELSE([LT_PROG_RC],
# Obsolete macros: # Obsolete macros:
AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) 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)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
dnl aclocal-1.4 backwards compatibility: dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_F77], [])
dnl AC_DEFUN([AC_LIBTOOL_FC], [])
dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
@ -1703,6 +1710,7 @@ m4_case([$1],
[C], [withGCC=$GCC], [C], [withGCC=$GCC],
[CXX], [withGCC=$GXX], [CXX], [withGCC=$GXX],
[F77], [withGCC=$G77], [F77], [withGCC=$G77],
[FC], [withGCC=$ac_cv_fc_compiler_gnu],
[withGCC=$GCC]) [withGCC=$GCC])
library_names_spec= library_names_spec=
libname_spec='lib$name' libname_spec='lib$name'
@ -5720,6 +5728,14 @@ _LT_EOF
return return
end end
_LT_EOF _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 ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
public class foo { public class foo {
private int a; private int a;
@ -5965,6 +5981,140 @@ AC_LANG_POP
])# _LT_LANG_F77_CONFIG ])# _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]) # _LT_LANG_GCJ_CONFIG([TAG])
# -------------------------- # --------------------------
# Ensure that the configuration variables for the GNU Java Compiler compiler # Ensure that the configuration variables for the GNU Java Compiler compiler

View File

@ -113,6 +113,48 @@ LT_AT_EXEC_CHECK([./main])
AT_CLEANUP AT_CLEANUP
AT_SETUP([FC convenience archives])
LT_AT_TAG([FC])
AT_DATA([a.f],
[[ subroutine a
return
end
]])
AT_DATA([b.f],
[[ subroutine b
return
end
]])
AT_DATA([c.f],
[[ subroutine c
return
end
]])
AT_DATA(main.f,
[[ program main
call a
call b
call c
end
]])
$LIBTOOL --tag=FC --mode=compile $FC -c $FCFLAGS $FCFLAGS_f a.f
$LIBTOOL --tag=FC --mode=compile $FC -c $FCFLAGS $FCFLAGS_f b.f
$LIBTOOL --tag=FC --mode=compile $FC -c $FCFLAGS $FCFLAGS_f c.f
$LIBTOOL --tag=FC --mode=compile $FC -c $FCFLAGS $FCFLAGS_f main.f
$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -o liba.la a.lo
$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -o libb.la b.lo
$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -o libcee.la c.lo liba.la libb.la -rpath /notexist
AT_CHECK([$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -static -o main_static main.lo libcee.la],
[0],[ignore],[ignore])
AT_CHECK([$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -o main main.lo libcee.la],
[0],[ignore],[ignore])
LT_AT_EXEC_CHECK([./main_static])
LT_AT_EXEC_CHECK([./main])
AT_CLEANUP
AT_SETUP([Java convenience archives]) AT_SETUP([Java convenience archives])
LT_AT_TAG([GCJ]) LT_AT_TAG([GCJ])

32
tests/fcdemo-conf.test Executable file
View File

@ -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

33
tests/fcdemo-exec.test Executable file
View File

@ -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

34
tests/fcdemo-make.test Executable file
View File

@ -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

32
tests/fcdemo-shared.test Executable file
View File

@ -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

32
tests/fcdemo-static.test Executable file
View File

@ -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

17
tests/fcdemo/.cvsignore Normal file
View File

@ -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

51
tests/fcdemo/Makefile.am Normal file
View File

@ -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

16
tests/fcdemo/README Normal file
View File

@ -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.

79
tests/fcdemo/configure.ac Normal file
View File

@ -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

47
tests/fcdemo/cprogram.c Normal file
View File

@ -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;
}

47
tests/fcdemo/foo.h Normal file
View File

@ -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

17
tests/fcdemo/fooc.c Normal file
View File

@ -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;
}

11
tests/fcdemo/foof.f90 Normal file
View File

@ -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

13
tests/fcdemo/foof2.f90 Normal file
View File

@ -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

13
tests/fcdemo/foof3.f90 Normal file
View File

@ -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

32
tests/fcdemo/fprogram.f90 Normal file
View File

@ -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