test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / distcheck-configure-flags-am.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 support for AM_DISTCHECK_CONFIGURE_FLAGS at "make distcheck"
18 # time, and its interactions with DISTCHECK_CONFIGURE_FLAGS.
19
20 . test-init.sh
21
22 cat >> configure.ac << 'END'
23 AC_ARG_ENABLE([success], [], [success=$enableval], [success=no])
24 AS_IF([test $success = yes && test "$sentence" = 'it works :-)'],
25       [:],
26       [AC_MSG_ERROR([success='$success', sentence='$sentence'])])
27 AC_OUTPUT
28 END
29
30 unset sentence
31
32 cat > Makefile.am << 'END'
33 AM_DISTCHECK_CONFIGURE_FLAGS = $(dc_flags1) $(dc_flags2)
34 dc_flags1 = --enable-success sentence='it works :-)'
35 dc_flags2 =
36 END
37
38 $ACLOCAL
39 $AUTOMAKE
40 $FGREP '$(DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
41 $FGREP '$(AM_DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
42 grep 'DISTCHECK_CONFIGURE_FLAGS.*AM_DISTCHECK_CONFIGURE_FLAGS' Makefile.in \
43   && exit 1
44
45 $AUTOCONF
46 ./configure --enable-success sentence='it works :-)'
47
48 # The configure call in "make distcheck" should honour
49 # $(AM_DISTCHECK_CONFIGURE_FLAGS).
50
51 $MAKE distcheck
52
53 # $(DISTCHECK_CONFIGURE_FLAGS) takes precedence over
54 # $(AM_DISTCHECK_CONFIGURE_FLAGS)
55
56 cat >> Makefile.am << 'END'
57 dc_flags2 += --disable-success
58 END
59 $AUTOMAKE Makefile
60 ./config.status Makefile
61
62 run_make -e FAIL -M distcheck
63 grep "^configure:.* success='no', sentence='it works :-)'" output
64
65 $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-success=yes"
66
67 :