blob: fb5122d92cf82eafa5a6003ee1c230a795230ce4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#! /bin/sh
# Copyright (C) 2013-2015 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Basic tests for '%...%' preprocessing in included Makefile fragments:
# %reldir% a.k.a. %D%
# %canon_reldir% a.k.a. %C%
. test-init.sh
cat >> configure.ac << 'END'
AC_CONFIG_FILES([zot/Makefile])
AC_OUTPUT
END
mkdir foo foo/bar foo/foobar zot
cat > Makefile.am << 'END'
include $(top_srcdir)/foo/local.mk
include $(srcdir)/foo/foobar/local.mk
include local.mk
END
cat > zot/Makefile.am << 'END'
include $(top_srcdir)/zot/local.mk
## Check that '%canon_reldir%' doesn't remain overridden
## by the previous include.
%canon_reldir%_zot_whoami:
echo "I am %reldir%/Makefile.am" >$@
include $(top_srcdir)/top.mk
include ../reltop.mk
END
cat > local.mk << 'END'
%canon_reldir%_whoami:
echo "I am %reldir%/local.mk" >$@
END
cat > top.mk << 'END'
%canon_reldir%_top_whoami:
echo "I am %reldir%/top.mk" >$@
END
cat > reltop.mk << 'END'
%C%_reltop_whoami:
echo "I am %D%/reltop.mk" >$@
END
cp local.mk foo
cp local.mk foo/bar
cp local.mk foo/foobar
cp local.mk zot
cat >> foo/local.mk << 'END'
include %reldir%/bar/local.mk
## Check that '%canon_reldir%' doesn't remain overridden by the
## previous include. The duplicated checks are done to ensure that
## Automake substitutes all pre-processing occurrences on a line,
## not just the first one.
test-%reldir%:
test '%reldir%' = foo && test '%reldir%' = foo
test '%D%' = foo && test '%D%' = foo
test '%canon_reldir%' = foo && test '%C%' = foo
END
$ACLOCAL
$AUTOCONF
$AUTOMAKE
./configure
check ()
{
test $# -eq 2 || fatal_ "made_into(): bad usage"
target=$1 contents=$2
rm -f "$target" \
&& $MAKE "$target" \
&& test x"$(cat "$target")" = x"$contents"
}
check whoami "I am local.mk"
check foo_whoami "I am foo/local.mk"
check foo_bar_whoami "I am foo/bar/local.mk"
check foo_foobar_whoami "I am foo/foobar/local.mk"
$MAKE test-foo
cd zot
check whoami "I am local.mk"
check ___top_whoami "I am ../top.mk"
check ___reltop_whoami "I am ../reltop.mk"
check zot_whoami "I am Makefile.am"
:
|