1#! /bin/sh 2# Copyright (C) 2003-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# Test to make sure that adding a new directory works, even from 18# subdirectories. The sister test 'subdir-add-pr46.sh' makes sure 19# it works when make is run from the top-level directory. 20# PR automake/46 21 22. test-init.sh 23 24cat >> configure.ac << 'END' 25AC_CONFIG_MACRO_DIR([m4]) 26m4_include([confiles.m4]) 27MORE_DEFS 28AC_OUTPUT 29END 30 31echo 'AC_CONFIG_FILES([sub/Makefile])' > confiles.m4 32 33cat > Makefile.am << 'END' 34SUBDIRS = sub 35END 36 37mkdir sub 38 39: > sub/Makefile.am 40 41mkdir m4 42echo 'AC_DEFUN([MORE_DEFS], [])' > m4/moredefs.m4 43 44$ACLOCAL 45$AUTOCONF 46$AUTOMAKE 47./configure 48$MAKE 49 50# Now add new directories. 51 52# The first step users typically do when adding a new subdir is editing 53# configure.ac. That is already tested by 'subdir-add-pr46.sh' though, 54# so here we try to just edit a file that is included by configure.ac, 55# without touching configure.ac itself. 56 57mkdir sub/maude 58cat > sub/maude/Makefile.am << 'END' 59include_HEADERS = foo.h 60END 61 62: > sub/maude/foo.h 63 64echo 'SUBDIRS = maude' >> sub/Makefile.am 65 66mkdir maude 67: > maude/Makefile.am 68 69# Update confiles.m4 *after* updating sub/Makefile.am; the sister test 70# 'subdir-add-pr46.sh' does it the in other way: it updates configure.ac 71# before Makefile.am. We sleep here because modified configure 72# dependencies must be newer than config.status. 73$sleep 74echo 'AC_CONFIG_FILES([maude/Makefile sub/maude/Makefile])' >> confiles.m4 75 76# We want a simple rebuild from sub/ to create sub/maude/Makefile 77# and maude/Makefile automatically. 78cd sub 79$MAKE 80cd .. 81grep '^SUBDIRS = *maude *$' sub/Makefile.in 82grep '^SUBDIRS = *maude *$' sub/Makefile 83test -f maude/Makefile 84test -f sub/maude/Makefile 85 86# Make sure the dependencies of aclocal.m4 or honored at least from 87# the top-level directory. 88echo 'AC_DEFUN([MORE_DEFS], [AC_SUBST([GREPME])])' > m4/moredefs.m4 89$MAKE 90 91for ext in '.in' ''; do 92 for d in . maude sub sub/maude; do 93 grep '^GREPME =' $d/Makefile$ext 94 done 95done 96 97: 98