tests: prune some weed in a non-POSIX test
[platform/upstream/automake.git] / t / distcheck-configure-flags-subpkg.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 AM_DISTCHECK_CONFIGURE_FLAGS and DISTCHECK_CONFIGURE_FLAGS
18 # are not honored in a subpackage Makefile.am, but the flags from
19 # AM_DISTCHECK_CONFIGURE_FLAGS and DISTCHECK_CONFIGURE_FLAGS are
20 # passed down to the configure script of the subpackage.  This is
21 # explicitly documented in the manual.
22
23 . test-init.sh
24
25 cat >> configure.ac << 'END'
26 AC_CONFIG_SUBDIRS([subpkg])
27 if test $dc != ok || test $am_dc != ok; then
28   AC_MSG_ERROR([dc=$dc am_dc=$dc])
29 fi
30 AC_OUTPUT
31 END
32
33 mkdir subpkg
34
35 sed <configure.ac >subpkg/configure.ac \
36     -e 's/^AC_INIT.*/AC_INIT([subpkg], [2.0])/' \
37     -e '/^AC_CONFIG_SUBDIRS/d' \
38
39 cat configure.ac
40 cat subpkg/configure.ac
41
42 dc=KO am_dc=KO; export dc am_dc
43
44 cat > Makefile.am << 'END'
45 AM_DISTCHECK_CONFIGURE_FLAGS = am_dc=ok
46 DISTCHECK_CONFIGURE_FLAGS = dc=ok
47 END
48
49 : > subpkg/Makefile.am
50
51 $ACLOCAL
52 $AUTOMAKE
53 $AUTOCONF
54
55 cd subpkg
56 $ACLOCAL
57 $AUTOMAKE
58 $AUTOCONF
59 cd ..
60
61 # For debugging.
62 $FGREP 'DISTCHECK_CONFIGURE_FLAGS' Makefile.in subpkg/Makefile.in
63
64 grep '^AM_DISTCHECK_CONFIGURE_FLAGS =' Makefile.in
65 grep '^DISTCHECK_CONFIGURE_FLAGS =' Makefile.in
66 $EGREP '^(AM_)?DISTCHECK_CONFIGURE_FLAGS' subpkg/Makefile.in && exit 1
67
68 ./configure dc=ok am_dc=ok
69
70 # Flags in $(DISTCHECK_CONFIGURE_FLAGS) and $(AM_DISTCHECK_CONFIGURE_FLAGS)
71 # should be passed down to the subpackage configure when "make distcheck"
72 # is run from the top-level package ...
73 $MAKE distcheck
74
75 # ... but not when "make distcheck" is run from the subpackage.
76 cd subpkg
77 run_make -e FAIL -M distcheck
78 grep '^configure:.* dc=KO am_dc=KO' output
79
80 :