2 # Copyright (C) 2013-2024 Free Software Foundation, Inc.
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)
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Basic tests for '%...%' preprocessing in included Makefile fragments:
19 # %canon_reldir% a.k.a. %C%
23 cat >> configure.ac
<< 'END'
24 AC_CONFIG_FILES
([zot
/Makefile
])
28 mkdir foo foo
/bar foo
/foobar zot
30 cat > Makefile.am
<< 'END'
31 include $
(top_srcdir
)/foo
/local.mk
32 include $
(srcdir
)/foo
/foobar
/local.mk
36 cat > zot
/Makefile.am
<< 'END'
37 include $
(top_srcdir
)/zot
/local.mk
39 ## Check that '%canon_reldir%' doesn't remain overridden
40 ## by the previous include.
41 %canon_reldir
%_zot_whoami
:
42 echo "I am %reldir%/Makefile.am" >$@
44 include $
(top_srcdir
)/top.mk
48 cat > local.mk
<< 'END'
49 %canon_reldir
%_whoami
:
50 echo "I am %reldir%/local.mk" >$@
54 %canon_reldir
%_top_whoami
:
55 echo "I am %reldir%/top.mk" >$@
58 cat > reltop.mk
<< 'END'
60 echo "I am %D%/reltop.mk" >$@
65 cp local.mk foo
/foobar
68 cat >> foo
/local.mk
<< 'END'
69 include
%reldir
%/bar
/local.mk
70 ## Check that '%canon_reldir%' doesn't remain overridden by the
71 ## previous include. The duplicated checks are done to ensure that
72 ## Automake substitutes all pre-processing occurrences on a line,
73 ## not just the first one.
75 test '%reldir%' = foo
&& test '%reldir%' = foo
76 test '%D%' = foo
&& test '%D%' = foo
77 test '%canon_reldir%' = foo
&& test '%C%' = foo
87 test $# -eq 2 || fatal_
"made_into(): bad usage"
91 && test x
"$(cat "$target")" = x
"$contents"
94 check whoami
"I am local.mk"
95 check foo_whoami
"I am foo/local.mk"
96 check foo_bar_whoami
"I am foo/bar/local.mk"
97 check foo_foobar_whoami
"I am foo/foobar/local.mk"
101 check whoami
"I am local.mk"
102 check ___top_whoami
"I am ../top.mk"
103 check ___reltop_whoami
"I am ../reltop.mk"
104 check zot_whoami
"I am Makefile.am"