Merge branch 'fix-pr14560' into micro
[platform/upstream/automake.git] / t / fort4.sh
1 #! /bin/sh
2 # Copyright (C) 2006-2013 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).
18
19 # For now, require the GNU compilers (to avoid some Libtool/Autoconf
20 # issues).
21 required='g77 gfortran'
22 . test-init.sh
23
24 mkdir sub
25
26 cat >hello.f <<'END'
27       program hello
28       call foo
29       call bar
30       stop
31       end
32 END
33
34 cat >bye.f90 <<'END'
35 program goodbye
36   call baz
37   stop
38 end
39 END
40
41 cat >foo.f90 <<'END'
42       subroutine foo
43       return
44       end
45 END
46
47 sed s,foo,bar, foo.f90 > sub/bar.f90
48 sed s,foo,baz, foo.f90 > sub/baz.f
49
50 cat >>configure.ac <<'END'
51 AC_PROG_F77
52 AC_PROG_FC
53 AC_FC_SRCEXT([f90], [],
54   [AC_MSG_FAILURE([$FC compiler cannot create executables], 77)])
55 AC_FC_LIBRARY_LDFLAGS
56 AC_OUTPUT
57 END
58
59 cat >Makefile.am <<'END'
60 bin_PROGRAMS = hello goodbye
61 hello_SOURCES = hello.f foo.f90 sub/bar.f90
62 goodbye_SOURCES = bye.f90 sub/baz.f
63 goodbye_FCFLAGS =
64 LDADD = $(FCLIBS)
65 END
66
67 $ACLOCAL
68 $AUTOMAKE -a
69 # The Fortran 77 linker should be preferred:
70 grep '.\$(FCLINK)' Makefile.in && exit 1
71
72 $AUTOCONF
73 # ./configure may exit with status 77 if no compiler is found,
74 # or if the compiler cannot compile Fortran 90 files).
75 ./configure
76 $MAKE
77 subobjs=$(echo sub/*.o sub/*.obj)
78 test "$subobjs" = 'sub/*.o sub/*.obj'
79 $MAKE distcheck
80
81 $MAKE distclean
82 echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
83 $AUTOMAKE
84 ./configure
85 $MAKE
86 test ! -e bar.o
87 test ! -e bar.obj
88 test ! -e baz.o
89 test ! -e baz.obj
90 test ! -e goodbye-baz.o
91 test ! -e goodbye-baz.obj
92 $MAKE distcheck
93
94 :