Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / distcheck-configure-flags-am.test
1 #! /bin/sh
2 # Copyright (C) 2011 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 . ./defs || Exit 1
21
22 set -e
23
24 cat >> configure.in << 'END'
25 AC_ARG_ENABLE([success], [], [success=$enableval], [success=no])
26 AS_IF([test $success = yes && test "$sentence" = 'it works :-)'],
27       [:],
28       [AC_MSG_ERROR([success='$success', sentence='$sentence'])])
29 AC_OUTPUT
30 END
31
32 unset sentence || :
33
34 cat > Makefile.am << 'END'
35 AM_DISTCHECK_CONFIGURE_FLAGS = $(dc_flags1) $(dc_flags2)
36 dc_flags1 = --enable-success sentence='it works :-)'
37 dc_flags2 =
38 END
39
40 $ACLOCAL
41 $AUTOMAKE
42 $FGREP '$(DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
43 $FGREP '$(AM_DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
44 grep 'DISTCHECK_CONFIGURE_FLAGS.*AM_DISTCHECK_CONFIGURE_FLAGS' Makefile.in \
45   && Exit 1
46
47 $AUTOCONF
48 ./configure --enable-success sentence='it works :-)'
49
50 # The configure call in "make distcheck" should honour
51 # $(AM_DISTCHECK_CONFIGURE_FLAGS).
52
53 $MAKE distcheck
54
55 # $(DISTCHECK_CONFIGURE_FLAGS) takes precedence over
56 # $(AM_DISTCHECK_CONFIGURE_FLAGS)
57
58 cat >> Makefile.am << 'END'
59 dc_flags2 += --disable-success
60 END
61 $AUTOMAKE Makefile
62 ./config.status Makefile
63
64 $MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
65 cat output
66 grep "^configure:.* success='no', sentence='it works :-)'" output
67
68 $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-success=yes"
69
70 :