1#!/bin/sh
2# Copyright (C) 2010-2021 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 <https://www.gnu.org/licenses/>.
16
17# Check silent-rules mode for Fortran 77.
18# Keep this ins sync with the sister test 'silent-f90.sh'.
19
20required=fortran77
21. test-init.sh
22
23mkdir sub
24
25cat >>configure.ac <<'EOF'
26AC_PROG_F77
27AC_CONFIG_FILES([sub/Makefile])
28AC_OUTPUT
29EOF
30
31cat > Makefile.am <<'EOF'
32# Need generic and non-generic rules.
33bin_PROGRAMS = foo1 foo2
34foo1_SOURCES = foo.f
35foo2_SOURCES = $(foo1_SOURCES)
36foo2_FFLAGS = $(AM_FFLAGS)
37SUBDIRS = sub
38EOF
39
40cat > sub/Makefile.am <<'EOF'
41AUTOMAKE_OPTIONS = subdir-objects
42# Need generic and non-generic rules.
43bin_PROGRAMS = bar1 bar2
44bar1_SOURCES = bar.f
45bar2_SOURCES = $(bar1_SOURCES)
46bar2_FFLAGS = $(AM_FFLAGS)
47EOF
48
49cat > foo.f <<'EOF'
50      program foo
51      stop
52      end
53EOF
54cp foo.f sub/bar.f
55
56$ACLOCAL
57$AUTOMAKE --add-missing
58$AUTOCONF
59
60./configure --enable-silent-rules
61run_make -O
62# Avoid spurious failures with SunStudio Fortran compilers.
63sed '/^NOTICE:/d' stdout > t
64mv -f t stdout
65cat stdout
66
67$EGREP ' (-c|-o)' stdout && exit 1
68grep 'mv ' stdout && exit 1
69
70grep 'F77 .*foo\.'  stdout
71grep 'F77 .*bar\.'  stdout
72grep 'F77LD .*foo1' stdout
73grep 'F77LD .*bar1' stdout
74grep 'F77LD .*foo2' stdout
75grep 'F77LD .*bar2' stdout
76
77$EGREP '(FC|FCLD) ' stdout && exit 1
78
79# Ensure a clean rebuild.
80$MAKE clean
81
82run_make -O V=1
83
84grep ' -c ' stdout
85grep ' -o ' stdout
86
87$EGREP '(F77|FC|LD) ' stdout && exit 1
88
89:
90