| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Copyright (C) 2011-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 | # Test remake rules when a new AC_SUBST'd variable is added, and C header |
| 18 | # files are involved. |
| 19 | # This test overlaps with others, and is not strictly necessary per se, |
| 20 | # but it exercises a real use case (from gnulib, see: |
| 21 | # <https://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html> |
| 22 | # for more info). |
| 23 | |
| 24 | required=cc |
| 25 | . test-init.shscip-shell source . . `test-init.sh`. |
| 26 | |
| 27 | catscip-shell system . . cat. >> configure.ac <<'END' |
| 28 | AC_PROG_CC |
| 29 | MY_MACROS |
| 30 | AC_OUTPUT |
| 31 | END |
| 32 | |
| 33 | catscip-shell system . . cat. > Makefile.am <<'END' |
| 34 | ACLOCAL_AMFLAGS = -I m4 |
| 35 | noinst_PROGRAMS = foo |
| 36 | foo_SOURCES = foo.c |
| 37 | BUILT_SOURCES = foo.h |
| 38 | edit_h = sed -e 's|[@]foovar@|@foovar@|g' |
| 39 | foo.h: foo.in.h |
| 40 | $(edit_h) < $(srcdir)/foo.in.h > $@-t |
| 41 | cat $@-t;: For debugging. |
| 42 | mv -f $@-t $@ |
| 43 | EXTRA_DIST = foo.in.h |
| 44 | MOSTLYCLEANFILES = foo.h foo.h-t |
| 45 | END |
| 46 | |
| 47 | mkdirscip-shell system . . mkdir. m4 |
| 48 | |
| 49 | catscip-shell system . . cat. > m4/foo.m4 <<'END' |
| 50 | AC_DEFUN([MY_MACROS], [ |
| 51 | FOO_MACRO |
| 52 | dnl: ZAP_MACRO |
| 53 | ]) |
| 54 | END |
| 55 | |
| 56 | catscip-shell system . . cat. > m4/bar.m4 <<'END' |
| 57 | AC_DEFUN([FOO_MACRO], [ |
| 58 | foovar=42; AC_SUBST([foovar]) |
| 59 | dnl: barvar=47; AC_SUBST([barvar]) |
| 60 | ]) |
| 61 | END |
| 62 | |
| 63 | catscip-shell system . . cat. > foo.in.h <<'END' |
| 64 | #define foo @foovar@ |
| 65 | END |
| 66 | |
| 67 | catscip-shell system . . cat. > foo.c <<'END' |
| 68 | #include "foo.h" |
| 69 | int main (void) { return 0; } |
| 70 | typedef int checkfoo[1 - 2 * (foo != 42)]; |
| 71 | END |
| 72 | |
| 73 | $ACLOCAL -I m4 |
| 74 | $AUTOCONF |
| 75 | $AUTOMAKE |
| 76 | |
| 77 | ./configure |
| 78 | $MAKE |
| 79 | |
| 80 | : AC_SUBST @barvar@ and add it to foo.h. |
| 81 | |
| 82 | $sleep |
| 83 | |
| 84 | sedscip-shell system . . sed. -e 's/^dnl:/ /' m4/bar.m4 > t |
| 85 | mvscip-shell system . . mv. -f t m4/bar.m4 |
| 86 | catscip-shell system . . cat. m4/bar.m4 |
| 87 | |
| 88 | catscip-shell system . . cat. >> foo.in.h <<'END' |
| 89 | #define bar @barvar@ |
| 90 | END |
| 91 | |
| 92 | catscip-shell system . . cat. >> foo.c <<'END' |
| 93 | typedef int checkbar[1 - 2 * (bar != 47)]; |
| 94 | END |
| 95 | |
| 96 | catscip-shell system . . cat. >> Makefile.am <<'END' |
| 97 | edit_h += -e 's|[@]barvar@|@barvar@|g' |
| 98 | END |
| 99 | |
| 100 | using_gmake || $MAKE Makefile |
| 101 | $MAKE |
| 102 | |
| 103 | : AC_SUBST @zapvar@ and add it to foo.h. |
| 104 | # Do it in a slightly different way from how it was done for @barvar@. |
| 105 | |
| 106 | $sleep |
| 107 | |
| 108 | catscip-shell system . . cat. >> Makefile.am <<'END' |
| 109 | edit_h += -e 's|[@]zapvar@|$(zapvar)|g' |
| 110 | END |
| 111 | |
| 112 | catscip-shell system . . cat. >> foo.c <<'END' |
| 113 | typedef int checkzap[1 - 2 * (zap != 163)]; |
| 114 | END |
| 115 | |
| 116 | sedscip-shell system . . sed. -e 's/^dnl://' m4/foo.m4 > t |
| 117 | mvscip-shell system . . mv. -f t m4/foo.m4 |
| 118 | catscip-shell system . . cat. m4/foo.m4 |
| 119 | |
| 120 | catscip-shell system . . cat. >> foo.in.h <<'END' |
| 121 | #define zap @zapvar@ |
| 122 | END |
| 123 | |
| 124 | catscip-shell system . . cat. >> m4/bar.m4 <<'END' |
| 125 | AC_DEFUN([ZAP_MACRO], [zapvar=163; AC_SUBST([zapvar])]) |
| 126 | END |
| 127 | |
| 128 | using_gmake || $MAKE Makefile |
| 129 | $MAKE |
| 130 | |
| 131 | $MAKE distcheck |
| 132 | |
| 133 | : |