Merge branch 'yacc-quote-fix'
[automake.git] / tests / subcond2.test
blob304b2ed6e7404148b6e4e7383a4bd041d4bd1474
1 #! /bin/sh
2 # Copyright (C) 2002-2012 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 # The for conditional SUBDIRS.
18 # SUBDIRS + AM_CONDITIONAL setup from the manual.
19 # Lots of lines here are duplicated in subcond3.test.
21 . ./defs || Exit 1
23 cat >>configure.in <<'END'
24 AM_CONDITIONAL([COND_OPT], [test "$want_opt" = yes])
25 AC_CONFIG_FILES([src/Makefile opt/Makefile])
26 AC_OUTPUT
27 END
29 cat >Makefile.am << 'END'
30 if COND_OPT
31 MAYBE_OPT = opt
32 endif
33 SUBDIRS = src $(MAYBE_OPT)
35 # Testing targets.
37 # We want to ensure that
38 # - src/source and opt/source are always distributed.
39 # - src/result is always built
40 # - opt/result is built conditionally
42 # We rely on `distcheck' to run `check-local' and use
43 # `sanity1' and `sanity2' as evidences that test-build was run.
45 if COND_OPT
46 test-build: all
47 test -f src/result
48 test -f opt/result
49 : > $(top_builddir)/../../sanity2
50 else
51 test-build: all
52 test -f src/result
53 test ! -f opt/result
54 : > $(top_builddir)/../../sanity1
55 endif
57 test-dist: distdir
58 test -f $(distdir)/src/source
59 test -f $(distdir)/opt/source
61 check-local: test-build test-dist
62 END
64 mkdir src opt
65 : > src/source
66 : > opt/source
68 cat >src/Makefile.am << 'END'
69 EXTRA_DIST = source
70 all-local: result
71 CLEANFILES = result
73 result: source
74 cp $(srcdir)/source result
75 END
77 # We want in opt/ the same Makefile as in src/. Let's exercise `include'.
78 cat >opt/Makefile.am << 'END'
79 include ../src/Makefile.am
80 END
82 $ACLOCAL
83 $AUTOCONF
84 $AUTOMAKE --add-missing
85 ./configure
86 $MAKE distcheck
87 test -f sanity1
88 DISTCHECK_CONFIGURE_FLAGS=want_opt=yes $MAKE distcheck
89 test -f sanity2