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