* lib/Makefile.am (dist_script_DATA): Move config-ml.in ...
[automake.git] / tests / subcond3.test
blobf030b4fd143c8f0bad0aa57b6c2416e87b26bfb0
1 #! /bin/sh
2 # Copyright (C) 2002, 2003 Free Software Foundation, Inc.
4 # This file is part of GNU Automake.
6 # GNU Automake is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # GNU Automake is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with autoconf; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
21 # The for conditional SUBDIRS.
22 # SUBDIRS + AC_SUBST setup from the manual.
23 # Lots of lines here are duplicated in subcond2.test.
25 . ./defs || exit 1
27 set -e
29 cat >>configure.in <<'END'
30 if test "$want_opt" = yes; then
31 MAYBE_OPT=opt
32 else
33 MAYBE_OPT=
35 AC_SUBST([MAYBE_OPT])
36 AC_CONFIG_FILES([src/Makefile opt/Makefile])
37 AC_OUTPUT
38 END
40 cat >Makefile.am << 'END'
41 SUBDIRS = src $(MAYBE_OPT)
42 DIST_SUBDIRS = src opt
44 # Testing targets.
46 # We want to ensure that
47 # - src/source and opt/source are always distributed.
48 # - src/result is always built
49 # - opt/result is built conditionally
51 # We rely on `distcheck' to run `check-local' and use
52 # `sanity1' and `sanity2' as evidences that test-build was run.
54 test-build: all
55 test -f src/result
56 if test -n "$(MAYBE_OPT)"; then \
57 test -f opt/result || exit 1; \
58 : > $(top_builddir)/../../sanity2 || exit 1; \
59 else \
60 test ! -f opt/result || exit 1; \
61 : > $(top_builddir)/../../sanity1 || exit 1; \
64 test-dist: distdir
65 test -f $(distdir)/src/source
66 test -f $(distdir)/opt/source
68 check-local: test-build test-dist
69 END
71 mkdir src opt
72 : > src/source
73 : > opt/source
75 cat >src/Makefile.am << 'END'
76 EXTRA_DIST = source
77 all-local: result
78 CLEANFILES = result
80 result: source
81 cp $(srcdir)/source result
82 END
84 # We want in opt/ the same Makefile as in src/. Let's exercise `include'.
85 cat >opt/Makefile.am << 'END'
86 include ../src/Makefile.am
87 END
89 $ACLOCAL
90 $AUTOCONF
91 $AUTOMAKE --add-missing
92 ./configure
93 $MAKE distcheck
94 test -f sanity1
95 DISTCHECK_CONFIGURE_FLAGS=want_opt=yes $MAKE distcheck
96 test -f sanity2