doc: update Vala documentation
[automake.git] / t / subst-no-trailing-empty-line.sh
blobda0e9545f9c08f8e64185bdc6927a240f5d3b039
1 #! /bin/sh
2 # Copyright (C) 2003-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)
7 # any later version.
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 # If the last line of a automake-rewritten definition is made only of
18 # @substitutions@, automake should take care of appending an empty
19 # variable to make sure that line cannot end up substituted as a blank
20 # line (that would confuse HP-UX Make).
21 # These checks have been introduced in commit 'Release-1-9-254-g9d0eaef'
22 # into the former test 'subst2.test'.
24 . test-init.sh
26 # These are deliberately quite long, so that the xxx_PROGRAMS definition
27 # in Makefile.am below will be split on multiple lines, with the last
28 # line containing only @substituted@ stuff that expands to empty (this is
29 # required to expose the bug we are testing).
30 v1=ABCDEFGHIJKLMNOPQRSTUVWX
31 v2=ABCDEFGHIJKLMNOPQRSTUVWXY
32 v3=ABCDEFGHIJKLMNOPQRSTUVWXYZ
34 # Literal backslash for use by grep.
35 bs='\\'
37 cat >> configure.ac <<END
38 AC_SUBST([A], [''])
39 AC_SUBST([$v1], [''])
40 AC_SUBST([$v2], [''])
41 AC_SUBST([$v3], [''])
42 AC_OUTPUT
43 END
45 cat >Makefile.am <<END
46 AUTOMAKE_OPTIONS = no-dependencies
47 CC = false
48 EXEEXT =
50 ## The "x" and "zardoz" strings and the use of '+=' are there to ensure
51 ## that these variables get rewritten by Automake.
52 noinst_PROGRAMS = x @$v1@ @$v2@ @$v3@
53 bin_PROGRAMS = @A@
54 bin_PROGRAMS += @$v1@ @$v2@ @$v3@
55 check_PROGRAMS = zardoz \$(noinst_PROGRAMS)
57 ## Required whenever there are @substituted@ values in the
58 ## PROGRAMS primary, otherwise automake will complain.
59 EXTRA_PROGRAMS =
61 test-real-empty:
62 is \$(noinst_PROGRAMS) == x
63 is \$(bin_PROGRAMS) ==
64 is \$(check_PROGRAMS) == zardoz x
66 test-fake-empty:
67 is \$(noinst_PROGRAMS) == x X
68 is \$(bin_PROGRAMS) == X
69 is \$(check_PROGRAMS) == zardoz x X
70 END
72 $ACLOCAL
73 $AUTOCONF
74 $AUTOMAKE
75 # For debugging.
76 $EGREP -n 'ABCD|am__empty' Makefile.in
77 # Sanity check.
78 test $($EGREP -c "^[ $tab]*@$v2@ @$v3@[ $tab]*$bs?$" Makefile.in) -eq 3
80 ./configure
82 sed -n '/^noinst_PROGRAMS *=/,/[^\\]$/p' Makefile
83 sed -n '/^bin_PROGRAMS *=/,/[^\\]$/p' Makefile
84 sed -n '/^check_PROGRAMS *=/,/[^\\]$/p' Makefile
85 sed -n '/^am__EXEEXT.*=/,/[^\\]$/p' Makefile
86 } >t-programs
87 cat t-programs
88 grep '^ *$' t-programs && exit 1
90 run_make test-real-empty
91 run_make test-fake-empty am__empty=X