c474a413b218f71d1c9e218e111160603feec57c
[platform/upstream/automake.git] / tests / subobjname.test
1 #! /bin/sh
2 # Copyright (C) 2002  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 3, 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 # Make sure we reuse variables whenever possible, to limit
18 # combinational explosion.  (This test is named after the &subobjname
19 # sub in Automake).
20
21 . ./defs || Exit 1
22
23 set -e
24
25 cat >> configure.in << 'END'
26 AC_PROG_CC
27 AM_CONDITIONAL([FOO1], [some test])
28 AM_CONDITIONAL([FOO2], [some test])
29 AM_CONDITIONAL([FOO3], [some test])
30 AC_OUTPUT
31 END
32
33 cat > Makefile.am << 'END'
34 noinst_PROGRAMS = c d
35
36 if FOO1
37 A1=a1.c
38 endif
39
40 if FOO2
41 A2=a2.c
42 endif
43
44 if FOO3
45 A3=a3.c
46 endif
47
48 B=$(A1) $(A2) $(A3)
49
50 c_SOURCES=$(B)
51 d_SOURCES=$(B)
52 END
53
54 $ACLOCAL
55 $AUTOMAKE -a
56
57 # Sanity check: make sure am_c_OBJECTS and am_d_OBJECTS are used
58 # in the Makefile.  (This is an internal detail, so better make
59 # sure we update this test if the naming changes in the future.)
60 grep '^am_c_OBJECTS = ' Makefile.in
61 grep '^am_d_OBJECTS = ' Makefile.in
62
63 # Now the actual test.  Are both values equal?
64 cobj=`sed -n '/^am_c_OBJECTS = / {
65                 s/.* = \(.*\)$/\1/
66                 p
67               }' Makefile.in`
68 dobj=`sed -n '/^am_d_OBJECTS = / {
69                 s/^.* = \(.*\)$/\1/
70                 p
71               }' Makefile.in`
72 test "$cobj" = "$dobj"