1#! /bin/sh
2# Copyright (C) 2011-2021 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 <https://www.gnu.org/licenses/>.
16
17# Files specified by AC_REQUIRE_AUX_FILE must exist, and they get
18# automatically distributed by the top-level Makefile.am.
19# Automake bug#9651 reported that this didn't happen when the build-aux
20# directory was set to '.' by AC_CONFIG_AUX_DIR.
21
22am_create_testdir=empty
23. test-init.sh
24
25i=0
26for auxdir in build-aux ''; do
27
28  echo "*** Testing with auxdir '$auxdir' ***"
29
30  i=$(($i + 1))
31  mkdir T$i.d
32  cd T$i.d
33
34  unindent > configure.ac <<END
35    AC_INIT([$me], [1.0])
36    AC_CONFIG_AUX_DIR([${auxdir:-.}])
37    AM_INIT_AUTOMAKE
38    AC_REQUIRE_AUX_FILE([foo.txt])
39    AC_REQUIRE_AUX_FILE([bar.sh])
40    AC_REQUIRE_AUX_FILE([zardoz])
41    AC_CONFIG_FILES([Makefile subdir/Makefile])
42    AC_OUTPUT
43END
44
45  echo auxdir = ${auxdir:+"$auxdir/"} > Makefile.am
46  unindent >> Makefile.am <<'END'
47    SUBDIRS = subdir
48    test: distdir
49	ls -l $(distdir) $(distdir)/*      ;: For debugging.
50	@echo DIST_COMMON = $(DIST_COMMON) ;: Likewise.
51	echo ' ' $(DIST_COMMON) ' ' | grep '[ /]$(auxdir)foo.txt '
52	echo ' ' $(DIST_COMMON) ' ' | grep '[ /]$(auxdir)bar.sh '
53	echo ' ' $(DIST_COMMON) ' ' | grep '[ /]$(auxdir)zardoz '
54	test -f $(distdir)/$(auxdir)foo.txt
55	test -f $(distdir)/$(auxdir)bar.sh
56	test -f $(distdir)/$(auxdir)zardoz
57    .PHONY: test
58    check-local: test
59END
60
61  mkdir subdir
62  : > subdir/Makefile.am
63
64  test -z "$auxdir" || mkdir "$auxdir" || exit 99
65
66  if test -z "$auxdir"; then
67    auxdir=.
68    auxdir_rx='\.'
69  else
70    auxdir_rx=$auxdir
71  fi
72
73  $ACLOCAL
74  $AUTOCONF
75
76  AUTOMAKE_fails
77  grep "^configure\\.ac:4:.* required file.*$auxdir_rx/foo\\.txt" stderr
78  grep "^configure\\.ac:5:.* required file.*$auxdir_rx/bar\\.sh"  stderr
79  grep "^configure\\.ac:6:.* required file.*$auxdir_rx/zardoz"    stderr
80
81  touch $auxdir/foo.txt $auxdir/bar.sh $auxdir/zardoz
82  cp "$am_scriptdir"/missing "$am_scriptdir"/install-sh $auxdir \
83    || fatal_ "fetching auxiliary scripts 'missing' and 'install-sh'"
84  $AUTOMAKE
85  ./configure
86  $MAKE test
87  $EGREP '(foo\.txt|bar\.sh|zardoz)' subdir/Makefile.in && exit 1
88
89  $MAKE distcheck
90
91  cd ..
92
93done
94
95:
96