Merge branch 'micro' into maint
[platform/upstream/automake.git] / t / remake-renamed-m4-macro-and-file.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 an m4 file gets renamed and *simultaneously*
18 # an m4 macro in it gets renamed.  Kudos to Bruno Haible for thinking
19 # about this situation.  See also related test 'aclocal-deleted-header.sh'.
20
21 . test-init.sh
22
23 cat >> configure.ac <<'END'
24 MY_MACRO
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am <<'END'
29 ACLOCAL_AMFLAGS = -I m4
30 .PHONY: test
31 test:
32         test '$(the_answer)' -eq 42
33 END
34
35 mkdir m4
36
37 cat > m4/macros.m4 <<'END'
38 AC_DEFUN([MY_MACRO], [FOO_MACRO])
39 END
40
41 cat > m4/foo.m4 <<'END'
42 AC_DEFUN([FOO_MACRO], [the_answer=42; AC_SUBST([the_answer])])
43 END
44
45 $ACLOCAL -I m4
46 $AUTOCONF
47 $AUTOMAKE
48
49 ./configure
50 $MAKE test
51
52 # Rename only one file and one macro.
53
54 $sleep
55 sed -e 's/FOO_MACRO/BAR_MACRO/' m4/foo.m4 > m4/bar.m4
56 rm -f m4/foo.m4
57 sed -e 's/FOO_MACRO/BAR_MACRO/' m4/macros.m4 > t
58 mv -f t m4/macros.m4
59 using_gmake || $MAKE Makefile
60 $MAKE test
61 $MAKE distdir
62 ls -l $distdir $distdir/*
63 test -f $distdir/m4/bar.m4
64 test -f $distdir/m4/macros.m4
65 test ! -e $distdir/m4/foo.m4
66
67 # Rename both at once.
68
69 $sleep
70 sed -e 's/BAR_MACRO/QUUX_MACRO/' \
71   m4/bar.m4 > m4/quux.m4
72 sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' \
73   m4/macros.m4 > m4/defs.m4
74 rm -f m4/macros.m4 m4/bar.m4
75 sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' configure.ac > t
76 mv -f t configure.ac
77 using_gmake || $MAKE Makefile
78 $MAKE test
79 $MAKE distdir
80 ls -l $distdir $distdir/*
81 test -f $distdir/m4/quux.m4
82 test -f $distdir/m4/defs.m4
83 test ! -e $distdir/m4/bar.m4
84 test ! -e $distdir/m4/macros.m4
85
86 :