maint: Update HACKING
[automake.git] / t / cond32.sh
blob879dda9dd584cc5cf686f5b96f90ea73d3b14cb7
1 #!/bin/sh
2 # Copyright (C) 2003-2017 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 # Make sure the user can override a conditional _DEPENDENCIES.
19 . test-init.sh
21 cat >>configure.ac <<'EOF'
22 AM_CONDITIONAL([C1], [test -z "$two"])
23 AM_CONDITIONAL([C2], [test -n "$two"])
24 AM_CONDITIONAL([C3], [test -z "$three"])
25 # We define CC in Makefile.am, but OBJEXT here.
26 OBJEXT=o; AC_SUBST([OBJEXT])
27 AC_SUBST([MYSUB], ["foo.$OBJEXT"])
28 AC_OUTPUT
29 EOF
31 cat >>Makefile.am <<'EOF'
32 AUTOMAKE_OPTIONS = no-dependencies
33 CC = :
35 bin_PROGRAMS = a
37 if C1
38 a_LDADD = $(MYSUB)
39 a_DEPENDENCIES = $(MYSUB) nonsense.a
40 # Note that 'nonsense.a' is there just to make sure Automake insn't
41 # using some self computed a_DEPENDENCIES variable.
42 endif
44 if C2
45 if C3
46 BAR = bar.o
47 else
48 BAR = baz.o
49 endif
50 a_LDADD = $(BAR)
51 endif
53 test:
54 is $(exp) == $(a_DEPENDENCIES)
55 .PHONY: test
56 EOF
58 $ACLOCAL
59 $AUTOCONF
60 $AUTOMAKE
62 ./configure
63 $MAKE test exp='foo.o nonsense.a'
65 ./configure two=yes three=
66 $MAKE test exp='bar.o'
68 ./configure two=yes three=yes
69 $MAKE test exp='baz.o'