Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / fort5.test
1 #! /bin/sh
2 # Copyright (C) 2006, 2009  Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Test mixing Fortran 77 and Fortran (FC), libtool version.
18
19 # For now, require the GNU compilers (to avoid some Libtool/Autoconf
20 # issues).
21 required='libtoolize g77 gfortran'
22 . ./defs || Exit 1
23
24 set -e
25
26 mkdir sub
27
28 cat >hello.f <<'END'
29       program hello
30       call foo
31       call bar
32       call goodbye
33       stop
34       end
35 END
36
37 cat >bye.f90 <<'END'
38 subroutine goodbye
39   call baz
40   return
41 end
42 END
43
44 cat >foo.f90 <<'END'
45       subroutine foo
46       return
47       end
48 END
49
50 sed s,foo,bar, foo.f90 > sub/bar.f90
51 sed s,foo,baz, foo.f90 > sub/baz.f
52
53 cat >>configure.in <<'END'
54 AC_PROG_F77
55 AC_PROG_FC
56 AC_FC_SRCEXT([f90], [],
57   [AC_MSG_FAILURE([$FC compiler cannot create executables], 77)])
58 AC_FC_LIBRARY_LDFLAGS
59 AM_PROG_AR
60 LT_PREREQ([2.0])
61 AC_PROG_LIBTOOL
62 AC_OUTPUT
63 END
64
65 cat >Makefile.am <<'END'
66 bin_PROGRAMS = hello
67 lib_LTLIBRARIES = libhello.la
68 noinst_LTLIBRARIES = libgoodbye.la
69 hello_SOURCES = hello.f
70 hello_LDADD = libhello.la
71 libhello_la_SOURCES = foo.f90 sub/bar.f90
72 libhello_la_LIBADD = libgoodbye.la
73 libgoodbye_la_SOURCES = bye.f90 sub/baz.f
74 libgoodbye_la_FCFLAGS =
75 LDADD = $(FCLIBS)
76 END
77
78 libtoolize --force
79 $ACLOCAL
80 $AUTOMAKE -a
81 $AUTOCONF
82
83 # This test requires Libtool >= 2.0.  Earlier Libtool does not
84 # have the LT_PREREQ macro to cause autoconf failure, so let's
85 # skip in this case:
86 grep LT_PREREQ configure && Exit 77
87
88 # Ensure we use --tag for f90, too.
89 grep " --tag=FC" Makefile.in
90
91 # configure may Exit 77 if no compiler is found,
92 # or if the compiler cannot compile Fortran 90 files).
93 ./configure
94 $MAKE
95 subobjs=`echo sub/*.lo`
96 test "$subobjs" = 'sub/*.lo'
97 $MAKE distcheck
98
99 # The following will be fixed in a later patch:
100 $MAKE distclean
101 echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
102 $AUTOMAKE -a
103 ./configure
104 $MAKE
105 test ! -f bar.lo
106 test ! -f baz.lo
107 test ! -f libgoodbye_la-baz.lo
108 $MAKE distcheck