maint: adjust version for snapshot
[automake.git] / t / subobj.sh
blobb883deae249fb2dcba5fffc429926dba97652b03
1 #! /bin/sh
2 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Test of subdir objects with C and C++.
19 . test-init.sh
21 cat >> configure.ac <<'END'
22 AC_PROG_CC
23 AC_PROG_CXX
24 AC_PROG_YACC
25 AC_CONFIG_FILES([sub/Makefile])
26 AC_OUTPUT
27 END
29 $ACLOCAL
30 : > ylwrap
32 cat > Makefile.am << 'END'
33 SUBDIRS = sub
34 bin_PROGRAMS = wish
35 wish_SOURCES = generic/a.c
36 wish_SOURCES += another/z.cxx
37 END
39 mkdir sub
40 cat > sub/Makefile.am << 'END'
41 dream_SOURCES = generic/b.c more/r.y
42 bin_PROGRAMS = dream
43 END
45 AUTOMAKE_fails
46 grep "^Makefile\.am:3:.*'generic/a\.c'.* in a subdirectory" stderr
47 grep "^Makefile\.am:[34]:.*'another/z\.cxx'.* in a subdirectory" stderr
48 grep "^sub/Makefile\.am:1:.*'generic/b\.c'.* in a subdirectory" stderr
49 grep "option 'subdir-objects' is disabled" stderr
50 # Verbose tips should be given, but not too many times.
51 for msg in \
52 "possible forward-incompatibility" \
53 "For now,.* corresponding" \
54 "advi[sc]e.* 'subdir-objects' option throughout" \
55 ; do
56 test $(grep -c "$msg" stderr) -eq 1
57 done
59 # Guard against stupid typos.
60 grep 'subdir-object([^s]|$)' stderr && exit 1
62 $AUTOMAKE -Wno-unsupported
64 echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
65 AUTOMAKE_fails
66 grep "^Makefile\.am" stderr && exit 1
67 grep "^sub/Makefile\.am:.*'generic/b\.c'.* in a subdirectory" stderr
68 grep "option 'subdir-objects' is disabled" stderr
70 sed 's/^AM_INIT_AUTOMAKE/&([subdir-objects])/' configure.ac > configure.tmp
71 mv -f configure.tmp configure.ac
72 $ACLOCAL --force
73 $AUTOMAKE
75 rm -f compile
76 $AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; exit 1; }
77 cat stderr >&2
78 # Make sure compile is installed, and that Automake says so.
79 grep '^configure\.ac:[48]:.*install.*compile' stderr
80 test -f compile
82 grep '^generic/a\.\$(OBJEXT):' Makefile.in
83 grep '^generic/b\.\$(OBJEXT):' sub/Makefile.in
84 grep '^another/z\.\$(OBJEXT):' Makefile.in
85 $EGREP '(^|[^/])[abz]\.\$(OBJEXT)' Makefile.in sub/Makefile.in && exit 1
87 # Opportunistically test for a different bug.
88 grep '^another/z\.\$(OBJEXT):.*dirstamp' Makefile.in
89 grep '^generic/b\.\$(OBJEXT):.*dirstamp' sub/Makefile.in