automake: do not emit rule with two dependents
[automake.git] / t / preproc-c-compile.sh
blobc71322dbba5bda7755bb497bf5e919afa9cbf1ae
1 #! /bin/sh
2 # Copyright (C) 2013-2015 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 <http://www.gnu.org/licenses/>.
17 # Test pre-processing substitutions '%reldir%' and '%canon_reldir%'
18 # with C compilation and subdir objects.
20 require=cc
21 . test-init.sh
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AM_PROG_CC_C_O
26 AC_CONFIG_FILES([zot/Makefile])
27 AC_OUTPUT
28 END
30 mkdir foo
31 mkdir foo/bar
32 mkdir foo/foobar
33 mkdir zot
35 cat > Makefile.am << 'END'
36 AUTOMAKE_OPTIONS = subdir-objects
37 SUBDIRS = zot
38 bin_PROGRAMS =
40 include $(top_srcdir)/foo/local.mk
41 include $(srcdir)/foo/foobar/local.mk
42 include local.mk
44 check-local:
45 is $(bin_PROGRAMS) == \
46 foo/mumble2$(EXEEXT) \
47 foo/bar/mumble$(EXEEXT) \
48 foo/foobar/mumble$(EXEEXT) \
49 mumble$(EXEEXT)
50 test '$(mumble_SOURCES)' = one.c
51 test '$(foo_mumble2_SOURCES)' = foo/one.c
52 test '$(foo_bar_mumble_SOURCES)' = foo/bar/one.c
53 test '$(foo_foobar_mumble_SOURCES)' = foo/foobar/one.c
54 test -f mumble$(EXEEXT)
55 test -f foo/mumble2$(EXEEXT)
56 test -f foo/bar/mumble$(EXEEXT)
57 test -f foo/foobar/mumble$(EXEEXT)
58 test -f zot/mumble$(EXEEXT)
59 : Test some of the object files too.
60 test -f one.$(OBJEXT)
61 test -f foo/foobar/one.$(OBJEXT)
62 test -f zot/one.$(OBJEXT)
63 END
65 cat > zot/Makefile.am << 'END'
66 AUTOMAKE_OPTIONS = subdir-objects
67 bin_PROGRAMS =
68 include $(top_srcdir)/zot/local.mk
70 test:
71 test '$(bin_PROGRAMS)' = mumble$(EXEEXT)
72 test '$(mumble_SOURCES)' = one.c
73 check-local: test
74 END
76 cat > local.mk << 'END'
77 bin_PROGRAMS += %reldir%/mumble
78 %canon_reldir%_mumble_SOURCES = %reldir%/one.c
79 END
81 echo 'int main (void) { return 0; }' > one.c
83 sed 's/mumble/mumble2/' local.mk > foo/local.mk
84 cp local.mk foo/bar
85 cp local.mk foo/foobar
86 cp local.mk zot
87 echo "include %reldir%/bar/local.mk" >> foo/local.mk
89 cp one.c foo
90 cp one.c foo/bar
91 cp one.c foo/foobar
92 cp one.c zot
94 $ACLOCAL
95 $AUTOCONF
96 $AUTOMAKE
97 ./configure
99 $MAKE
100 $MAKE check-local
101 if ! cross_compiling; then
102 ./mumble
103 ./foo/mumble2
104 ./foo/bar/mumble
105 ./foo/foobar/mumble
106 ./zot/mumble
109 (cd zot && $MAKE test)
111 # GNU install refuses to override a just-installed file; since we
112 # have plenty of 'mumble' dummy programs to install in the same
113 # location, such "overridden installations" are not a problem for
114 # us; so just force the use the 'install-sh' script.
115 ac_cv_path_install=$(pwd)/install-sh; export ac_cv_path_install
116 $MAKE distcheck