tests: expose bug#14991 (relates to 'distcheck')
[platform/upstream/automake.git] / t / distcheck-no-prefix-or-srcdir-override.sh
1 #! /bin/sh
2 # Copyright (C) 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 that "make distcheck" overrides any --srcdir or --prefix flag
18 # (mistakenly) defined in $(AM_DISTCHECK_CONFIGURE_FLAGS) or
19 # $(DISTCHECK_CONFIGURE_FLAGS).  See automake bug#14991.
20
21 . test-init.sh
22
23 echo AC_OUTPUT >> configure.ac
24
25 orig_cwd=$(pwd); export orig_cwd
26
27 cat > Makefile.am << 'END'
28 # configure should choke on non-absolute prefix or non-existent
29 # srcdir.  We'll sanity-check that later.
30 AM_DISTCHECK_CONFIGURE_FLAGS = --srcdir am-src --prefix am-pfx
31 END
32
33 # Same comments as above applies.
34 DISTCHECK_CONFIGURE_FLAGS='--srcdir user-src --prefix user-pfx'
35 export DISTCHECK_CONFIGURE_FLAGS
36
37 $ACLOCAL
38 $AUTOMAKE
39 $AUTOCONF
40
41 # Sanity check: configure should choke on non-absolute prefix
42 # or non-existent srcdir.
43 ./configure --prefix foobar 2>stderr && { cat stderr >&2; exit 99; }
44 cat stderr >&2
45 grep "expected an absolute directory name for --prefix" stderr || exit 99
46 ./configure --srcdir foobar 2>stderr && { cat stderr >&2; exit 99; }
47 cat stderr >&2
48 grep "cannot find sources.* in foobar" stderr || exit 99
49
50 ./configure
51 run_make -E -O distcheck
52 test ! -s stderr
53 # Sanity check: the flags have been actually seen.
54 $PERL -e 'undef $/; $_ = <>; s/ \\\n/ /g; print;' <stdout >t
55 grep '/configure .* --srcdir am-src'   t || exit 99
56 grep '/configure .* --prefix am-pfx'   t || exit 99
57 grep '/configure .* --srcdir user-src' t || exit 99
58 grep '/configure .* --prefix user-pfx' t || exit 99
59
60 :