packaging: Bump to 1.14.1
[platform/upstream/automake.git] / t / remake-gnulib-add-acsubst.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 <http://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 #  <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
22 # for more info).
23
24 required=cc
25 . test-init.sh
26
27 cat >> configure.ac <<'END'
28 AC_PROG_CC
29 MY_MACROS
30 AC_OUTPUT
31 END
32
33 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 mkdir m4
48
49 cat > m4/foo.m4 <<'END'
50 AC_DEFUN([MY_MACROS], [
51      FOO_MACRO
52 dnl: ZAP_MACRO
53 ])
54 END
55
56 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 cat > foo.in.h <<'END'
64 #define foo @foovar@
65 END
66
67 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 sed -e 's/^dnl:/   /' m4/bar.m4 > t
85 mv -f t m4/bar.m4
86 cat m4/bar.m4
87
88 cat >> foo.in.h <<'END'
89 #define bar @barvar@
90 END
91
92 cat >> foo.c <<'END'
93 typedef int checkbar[1 - 2 * (bar != 47)];
94 END
95
96 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 cat >> Makefile.am <<'END'
109 edit_h += -e 's|[@]zapvar@|$(zapvar)|g'
110 END
111
112 cat >> foo.c <<'END'
113 typedef int checkzap[1 - 2 * (zap != 163)];
114 END
115
116 sed -e 's/^dnl://' m4/foo.m4 > t
117 mv -f t m4/foo.m4
118 cat m4/foo.m4
119
120 cat >> foo.in.h <<'END'
121 #define zap @zapvar@
122 END
123
124 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 :