am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / cond34.sh
1 #!/bin/sh
2 # Copyright (C) 2004-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 # Check for _DEPENDENCIES definition with conditional _LDADD.
18 # Report from Elena A. Vengerova.
19
20 . test-init.sh
21
22 cat >>configure.ac <<'EOF'
23 AM_CONDITIONAL([TWO], [test -n "$two"])
24 AC_OUTPUT
25 EOF
26
27 cat > Makefile.am <<'EOF'
28 OBJEXT=z
29 CC=false
30 AUTOMAKE_OPTIONS=no-dependencies
31
32 bin_PROGRAMS = test1 test2
33
34 if TWO
35   test1_LDADD = two.$(OBJEXT)
36   test2_LDADD = two.$(OBJEXT)
37   test2_DEPENDENCIES = $(test2_LDADD) somethingelse.a
38 else !TWO
39   test1_LDADD = one.$(OBJEXT)
40   test2_LDADD = three.$(OBJEXT)
41 endif !TWO
42
43 test1_DEPENDENCIES = $(test1_LDADD) somethingelse.a
44
45 .PHONY: dep-test1 dep-test2
46 dep-test1:
47         echo BEG: $(test1_DEPENDENCIES) :END
48 dep-test2:
49         echo BEG: $(test2_DEPENDENCIES) :END
50 EOF
51
52 $ACLOCAL
53 $AUTOCONF
54 $AUTOMAKE
55 ./configure
56
57 run_make -O dep-test1
58 $FGREP 'BEG: one.z somethingelse.a :END' stdout
59
60 run_make -O dep-test2
61 $FGREP 'BEG: three.z :END' stdout
62
63 ./configure two=2
64
65 run_make -O dep-test1
66 $FGREP 'BEG: two.z somethingelse.a :END' stdout
67
68 run_make -O dep-test2
69 $FGREP 'BEG: two.z somethingelse.a :END' stdout
70
71 :