Clarify overriding of `*_DEPENDENCIES' in LIBOBJS node.
[automake/ericb.git] / tests / subcond2.test
blobb2f58b748f4d6e821dfcaae9a04a9f7951bf9e44
1 #! /bin/sh
2 # Copyright (C) 2002, 2003 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 3, 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 set -e
25 cat >>configure.in <<'END'
26 AM_CONDITIONAL([COND_OPT], [test "$want_opt" = yes])
27 AC_CONFIG_FILES([src/Makefile opt/Makefile])
28 AC_OUTPUT
29 END
31 cat >Makefile.am << 'END'
32 if COND_OPT
33 MAYBE_OPT = opt
34 endif
35 SUBDIRS = src $(MAYBE_OPT)
37 # Testing targets.
39 # We want to ensure that
40 # - src/source and opt/source are always distributed.
41 # - src/result is always built
42 # - opt/result is built conditionally
44 # We rely on `distcheck' to run `check-local' and use
45 # `sanity1' and `sanity2' as evidences that test-build was run.
47 if COND_OPT
48 test-build: all
49 test -f src/result
50 test -f opt/result
51 : > $(top_builddir)/../../sanity2
52 else
53 test-build: all
54 test -f src/result
55 test ! -f opt/result
56 : > $(top_builddir)/../../sanity1
57 endif
59 test-dist: distdir
60 test -f $(distdir)/src/source
61 test -f $(distdir)/opt/source
63 check-local: test-build test-dist
64 END
66 mkdir src opt
67 : > src/source
68 : > opt/source
70 cat >src/Makefile.am << 'END'
71 EXTRA_DIST = source
72 all-local: result
73 CLEANFILES = result
75 result: source
76 cp $(srcdir)/source result
77 END
79 # We want in opt/ the same Makefile as in src/. Let's exercise `include'.
80 cat >opt/Makefile.am << 'END'
81 include ../src/Makefile.am
82 END
84 $ACLOCAL
85 $AUTOCONF
86 $AUTOMAKE --add-missing
87 ./configure
88 $MAKE distcheck
89 test -f sanity1
90 DISTCHECK_CONFIGURE_FLAGS=want_opt=yes $MAKE distcheck
91 test -f sanity2