tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / subpkg-macrodir.sh
1 #! /bin/sh
2 # Copyright (C) 2002-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 # 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([WHOAMI], [SuperPkg])])
42 EOF
43
44 cat > Makefile.am << 'END'
45 test-whoami:
46         test '$(WHOAMI)' = SuperPkg
47 check-local: test-whoami
48 END
49
50 mkdir pkg
51
52 cat > pkg/configure.ac <<'END'
53 AC_INIT([super], [1.0])
54 AM_INIT_AUTOMAKE
55 AC_CONFIG_MACRO_DIRS([macros ../m4])
56 AX_BAR
57 AX_FOO
58 END
59
60 mkdir pkg/macros
61 cat > pkg/macros/zardoz.m4 << 'END'
62 AC_DEFUN([AX_BAR], [AC_SUBST([WHOAMI], [sub-pkg])])
63 END
64
65 cat > pkg/Makefile.am << 'END'
66 test-whoami:
67         test '$(WHOAMI)' = sub-pkg
68 check-local: test-whomai
69 END
70
71 AUTOMAKE=$AUTOMAKE ACLOCAL=$ACLOCAL AUTOCONF=$AUTOCONF $AUTORECONF -vi
72
73 $FGREP 'm4_include([m4/foo.m4])' aclocal.m4
74 $FGREP 'm4_include([m4/bar.m4])' aclocal.m4
75 $FGREP 'm4_include([../m4/foo.m4])' pkg/aclocal.m4
76 $FGREP 'm4_include([macros/zardoz.m4])' pkg/aclocal.m4
77
78 ./configure
79
80 $MAKE test-whoami
81 (cd pkg && $MAKE test-whoami) || exit 1
82
83 $MAKE distcheck
84
85 :