Merge branch 'maint'
[platform/upstream/automake.git] / t / subpkg-macrodir.sh
1 #! /bin/sh
2 # Copyright (C) 2002-2012 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 # Subpackages that want to use m4 macros from their superpackages,
18 # with AC_CONFIG_MACRO_DIRS.
19
20 . test-init.sh
21
22 cat > configure.ac <<'END'
23 AC_INIT([super], [1.0])
24 AM_INIT_AUTOMAKE
25 AC_CONFIG_MACRO_DIR([m4])
26 AC_CONFIG_SUBDIRS([pkg])
27 AX_BAR
28 AX_FOO
29 END
30
31 mkdir m4
32
33 cat > m4/foo.m4 <<'EOF'
34 AC_DEFUN([AX_FOO], [
35   AC_CONFIG_FILES([Makefile])
36   AC_OUTPUT
37 ])
38 EOF
39
40 cat > m4/bar.m4 <<'EOF'
41 AC_DEFUN([AX_BAR], [AC_SUBST([WHOMAI], [SuperPkg])])
42 EOF
43
44 cat > Makefile.am << 'END'
45 test-whomai:
46         test '$(WHOAMI)' = SuperPkg
47 check-local: test
48 .PHONY: test
49 END
50
51 mkdir pkg
52
53 cat > pkg/configure.ac <<'END'
54 AC_INIT([super], [1.0])
55 AM_INIT_AUTOMAKE
56 AC_CONFIG_MACRO_DIRS([macros ../m4])
57 AX_BAR
58 AX_FOO
59 END
60
61 mkdir pkg/macros
62 cat > pkg/macros/zardoz.m4 << 'END'
63 AC_DEFUN([AX_BAR], [AC_SUBST([WHOMAI], [sub-pkg])])
64 END
65
66 cat > pkg/Makefile.am << 'END'
67 test-whomai:
68         test '$(WHOAMI)' = sub-pkg
69 check-local: test
70 .PHONY: test
71 END
72
73 AUTOMAKE=$AUTOMAKE ACLOCAL=$ACLOCAL AUTOCONF=$AUTOCONF $AUTORECONF -vi
74
75 $FGREP 'm4_include([m4/foo.m4])' aclocal.m4
76 $FGREP 'm4_include([m4/bar.m4])' aclocal.m4
77 $FGREP 'm4_include([../m4/foo.m4])' pkg/aclocal.m4
78 $FGREP 'm4_include([macros/zardoz.m4])' pkg/aclocal.m4
79
80 ./configure
81
82 $MAKE test
83 (cd pkg && $MAKE test) || exit 1
84
85 $MAKE distcheck
86
87 :