2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
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)
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.
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/>.
17 # Test remake rules when a C header "guarded" by AC_SUBST'd variables
18 # is not needed anymore, or when it's needed again.
19 # This test requires some user-level machinery, overlaps with other tests,
20 # and is not strictly necessary per se, but it exercises a real, important
21 # use case (from gnulib, see:
22 # <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
28 cat >> configure.ac <<'END'
29 AC_CONFIG_HEADERS([config.h])
35 cat > Makefile.am <<'END'
36 ACLOCAL_AMFLAGS = -I .
39 BUILT_SOURCES = $(STDIO_H)
41 stdio.h: stdio.in.h $(top_builddir)/config.status
42 cp $(srcdir)/stdio.in.h $@
44 stdio.h: $(top_builddir)/config.status
47 MOSTLYCLEANFILES = stdio.h
50 cat > macros.m4 <<'END'
51 AC_DEFUN([MY_MACROS], [
53 if $override_stdio; then
61 AC_DEFINE_UNQUOTED([USE_DUMMIES], [$use_dummies],
62 [Whether to use dummy types.])
63 AM_CONDITIONAL([REPLACE_STDIO_H], [test -n "$STDIO_H"])
67 cat > stdio.in.h <<'END'
68 typedef struct dummyfile { void *p; } DUMMYFILE;
79 int main () { return 0; }
87 for vpath in : false; do
97 # Do not reject slow dependency extractors: we need dependency tracking.
98 $srcdir/configure --enable-dependency-tracking
99 if $FGREP 'depmode=none' Makefile; then
100 skip_ "automatic dependency tracking couldn't be activated"
107 # Simulate that we don't need our custom stdio.h anymore.
110 sed -e 's/^\( *override_stdio\)=.*$/\1=false/' $srcdir/macros.m4 > t
111 diff $srcdir/macros.m4 t && fatal_ "failed to edit macros.m4"
112 mv -f t $srcdir/macros.m4
114 using_gmake || $MAKE Makefile
119 # And now simulate that we want our custom stdio.h back.
122 sed -e 's/^\( *override_stdio\)=.*$/\1=:/' $srcdir/macros.m4 > t
123 diff $srcdir/macros.m4 t && fatal_ "failed to edit macros.m4"
124 mv -f t $srcdir/macros.m4
126 using_gmake || $MAKE Makefile