| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Copyright (C) 2004-2025 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 | # Make sure m4_included files are also scanned for definitions. |
| 18 | # Report from Phil Edwards. |
| 19 | |
| 20 | . test-init.shscip-shell source . . `test-init.sh`. |
| 21 | |
| 22 | catscip-shell system . . cat. >> configure.ac << 'END' |
| 23 | AC_CONFIG_MACRO_DIR([defs]) |
| 24 | AM_PROG_LIBTOOL |
| 25 | AC_OUTPUT |
| 26 | END |
| 27 | |
| 28 | echoscip-shell system . . echo. 'm4_include([a.m4])' > acinclude.m4 |
| 29 | echoscip-shell system . . echo. 'm4_include([b.m4])' > a.m4 |
| 30 | |
| 31 | catscip-shell system . . cat. >b.m4 <<EOF |
| 32 | m4_include([c.m4]) |
| 33 | AC_DEFUN([AM_PROG_LIBTOOL], |
| 34 | [AC_REQUIRE([SOMETHING])dnl |
| 35 | AC_REQUIRE([SOMETHING_ELSE])dnl |
| 36 | ]) |
| 37 | |
| 38 | AC_DEFUN([SOMETHING]) |
| 39 | EOF |
| 40 | |
| 41 | echoscip-shell system . . echo. 'm4_include([d.m4])' > c.m4 |
| 42 | echoscip-shell system . . echo. 'AC_DEFUN([SOMETHING_ELSE])' >d.m4 |
| 43 | |
| 44 | mkdirscip-shell system . . mkdir. defs |
| 45 | echoscip-shell system . . echo. 'AC_DEFUN([SOMETHING_ELSE])' >defs/e.m4 |
| 46 | echoscip-shell system . . echo. 'AC_DEFUN([ANOTHER_MACRO])' >defs/f.m4 |
| 47 | |
| 48 | catscip-shell system . . cat. >>Makefile.am<<\EOF |
| 49 | testdist1: distdir |
| 50 | test -f $(distdir)/acinclude.m4 |
| 51 | test -f $(distdir)/a.m4 |
| 52 | test -f $(distdir)/b.m4 |
| 53 | test -f $(distdir)/c.m4 |
| 54 | test -f $(distdir)/d.m4 |
| 55 | test ! -d $(distdir)/defs |
| 56 | testdist2: distdir |
| 57 | test -f $(distdir)/acinclude.m4 |
| 58 | test -f $(distdir)/a.m4 |
| 59 | test -f $(distdir)/b.m4 |
| 60 | test -f $(distdir)/c.m4 |
| 61 | test -f $(distdir)/d.m4 |
| 62 | test ! -f $(distdir)/defs/e.m4 |
| 63 | test -f $(distdir)/defs/f.m4 |
| 64 | EOF |
| 65 | |
| 66 | $ACLOCAL -I defs |
| 67 | |
| 68 | $FGREP acinclude.m4 aclocal.m4 |
| 69 | # None of the following macro should be included. acinclude.m4 |
| 70 | # includes the first four, and the last two are not needed at all. |
| 71 | $FGREP a.m4 aclocal.m4 && exit 1 |
| 72 | $FGREP b.m4 aclocal.m4 && exit 1 |
| 73 | $FGREP c.m4 aclocal.m4 && exit 1 |
| 74 | $FGREP d.m4 aclocal.m4 && exit 1 |
| 75 | $FGREP defs/e.m4 aclocal.m4 && exit 1 |
| 76 | $FGREP defs/f.m4 aclocal.m4 && exit 1 |
| 77 | |
| 78 | $AUTOCONF |
| 79 | $AUTOMAKE |
| 80 | |
| 81 | ./configure |
| 82 | $MAKE testdist1 |
| 83 | |
| 84 | cpscip-shell system . . cp. aclocal.m4 aclocal.old |
| 85 | $sleep |
| 86 | echoscip-shell system . . echo. 'AC_DEFUN([FOO], [ANOTHER_MACRO])' >> c.m4 |
| 87 | $MAKE |
| 88 | # Because c.m4 has changed, aclocal.m4 must have been rebuilt. |
| 89 | is_newest aclocal.m4 aclocal.old |
| 90 | # However, since FOO is not used, f.m4 should not be included |
| 91 | # and the contents of aclocal.m4 should remain the same |
| 92 | diffscip-shell system . . diff. aclocal.m4 aclocal.old |
| 93 | |
| 94 | # If FOO where to be used, that would be another story, of course: |
| 95 | # f.m4 should be included |
| 96 | $sleep |
| 97 | echoscip-shell system . . echo. FOO >> configure.ac |
| 98 | $MAKE |
| 99 | $FGREP defs/f.m4 aclocal.m4 |
| 100 | $MAKE testdist2 |
| 101 | |
| 102 | # Make sure aclocal diagnose missing included files with correct 'file:line:'. |
| 103 | rmscip-shell system . . rm. -f b.m4 |
| 104 | $ACLOCAL 2>stderr && { catscip-shell system . . cat. stderr >&2; exit 1; } |
| 105 | catscip-shell system . . cat. stderr >&2 |
| 106 | grepscip-shell system . . grep. 'a\.m4:1: .*b\.m4.*does not exist' stderr |
| 107 | |
| 108 | : |