summaryrefslogtreecommitdiff
path: root/t/backslash-tricks.sh
blob: d0057657976df69c8f8d86a12f90987e5a60e681 (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
#! /bin/sh
# Copyright (C) 2012 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/>.

#
# - Automake should handle trailing backslashes in comments the way GNU
#   make does, i.e., considering the next line as a continuation of the
#   comment.
#
# - Automake should allow backslash-escaped '#' characters at the end
#   of a line (in variable definitions as well as well as in recipes),
#   because GNU make allows that.
#
# - GNU make handles comments following trailing backslashes gracefully,
#   so Automake should do the same.
#
# - Automake should not complain if the Makefile ands with a backslash
#   and newline sequence, because GNU make handles that gracefully.
#

. ./defs || exit 1

echo AC_OUTPUT >> configure.ac

# Avoid possible interferences from the environment.
var1= var2=; unset var1 var2

cat > Makefile.am << 'END'
# a comment with backslash \
var1 = foo
var2 = bar

var3 = \#
var4 = $(var3)

var5 = ok \
# ko

var6 = \# \
\#\\\\\# seen # not seen

var6 += \# \# # again not seen

.PHONY: test
test:
	test -z '$(var1)'
	test '$(var2)' = bar
	test '$(var3)' = '#'
	test '$(var4)' = \#
	# Use '[', not 'test', here, so that spurious comments
	# are ensured to cause syntax errors.
	[ $(var5) = ok ]
	test '$(var6)' = '# #\\# seen # #'

# Yes, this file ends with a backslash-newline.  So what?
\
END

$ACLOCAL
$AUTOCONF
$AUTOMAKE

./configure
$MAKE test

: