cf9c76081bff4619f699825891eaef85a2179f36
[platform/upstream/automake.git] / t / perf / cond.sh
1 #!/bin/sh
2 # Copyright (C) 2003-2012 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 that many conditions do not lead to combinatorial explosion.
18 # (This is related to PR/352.)
19
20 . ./defs || exit 1
21
22 echo AC_PROG_CC >>configure.ac
23
24 cat >Makefile.am <<EOF
25 bin_PROGRAMS = a
26 a02_LDADD =
27 a03_SOURCES =
28 EOF
29
30 # On this test, Automake 1.7.x would compute all 2**24 = 16777216
31 # possible combinations of conditionals (it would do this five times,
32 # to define a01_DEPENDENCIES, a02_DEPENDENCIES, a03_OBJECTS,
33 # a04_OBJECTS, and to rewrite bin_PROGRAM), eating all memory, swap,
34 # or cpu time it can found.
35
36 for i in \
37   01 02 03 04 05 06 07 08 09 10 \
38   11 12 13 14 15 16 17 18 19 20 \
39   21 22 23 24
40 do
41   unindent >>Makefile.am <<EOF
42     if C$i
43     bin_PROGRAMS += a$i
44     a01_LDADD = foo${i}.o
45     a02_LDADD += bar${i}.o
46     a03_SOURCES += baz${i}.c
47     a04_SOURCES = quux${i}.c
48     endif C$i
49 EOF
50   echo "AM_CONDITIONAL([C$i], [:])" >>configure.ac
51 done
52
53 $ACLOCAL
54 $AUTOMAKE
55
56 :