mk/misc: adjust layout of the show-all output to pkgsrc format In Makefiles, the variable values are aligned vertically. This format is now also used in the show-all target, which makes it easier readable. Some more variables have been marked as multi-value, and single-valued variables ending in space are clearly marked. Without the latter, the regression test would have a line with significant trailing whitespace.diff -r1.15 -r1.16 pkgsrc/mk/misc/show.mk
(rillig)
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: show.mk,v 1.15 2018/11/10 10:40:55 rillig Exp $ | 1 | # $NetBSD: show.mk,v 1.16 2018/11/11 19:07:12 rillig Exp $ | |
2 | # | 2 | # | |
3 | # This file contains some targets that print information gathered from | 3 | # This file contains some targets that print information gathered from | |
4 | # variables. They do not modify any variables. | 4 | # variables. They do not modify any variables. | |
5 | # | 5 | # | |
6 | 6 | |||
7 | # show-tools: | 7 | # show-tools: | |
8 | # Emits a /bin/sh shell script that defines all known tools | 8 | # Emits a /bin/sh shell script that defines all known tools | |
9 | # to the values they have in the pkgsrc infrastructure. | 9 | # to the values they have in the pkgsrc infrastructure. | |
10 | # | 10 | # | |
11 | show-tools: .PHONY | 11 | show-tools: .PHONY | |
12 | .for t in ${_USE_TOOLS} | 12 | .for t in ${_USE_TOOLS} | |
13 | . if defined(_TOOLS_VARNAME.${t}) | 13 | . if defined(_TOOLS_VARNAME.${t}) | |
14 | @${ECHO} ${_TOOLS_VARNAME.${t}:Q}=${${_TOOLS_VARNAME.${t}}:Q:Q} | 14 | @${ECHO} ${_TOOLS_VARNAME.${t}:Q}=${${_TOOLS_VARNAME.${t}}:Q:Q} | |
@@ -139,78 +139,81 @@ show-all: show-all-${g} | @@ -139,78 +139,81 @@ show-all: show-all-${g} | |||
139 | # In the following code, the variables are evaluated as late as possible. | 139 | # In the following code, the variables are evaluated as late as possible. | |
140 | # This is especially important for variables that use the :sh modifier, | 140 | # This is especially important for variables that use the :sh modifier, | |
141 | # like SUBST_FILES.pkglocaledir from mk/configure/replace-localedir.mk. | 141 | # like SUBST_FILES.pkglocaledir from mk/configure/replace-localedir.mk. | |
142 | # | 142 | # | |
143 | # When finally showing the variables, it is unavoidable that variables | 143 | # When finally showing the variables, it is unavoidable that variables | |
144 | # using the :sh modifier may show warnings, for example because ${WRKDIR} | 144 | # using the :sh modifier may show warnings, for example because ${WRKDIR} | |
145 | # doesn't exist. | 145 | # doesn't exist. | |
146 | 146 | |||
147 | show-all-${g}: .PHONY | 147 | show-all-${g}: .PHONY | |
148 | @echo "${g}:" | 148 | @echo "${g}:" | |
149 | . for c in ${_SHOW_ALL_CATEGORIES} | 149 | . for c in ${_SHOW_ALL_CATEGORIES} | |
150 | . for v in ${${c}.${g}} | 150 | . for v in ${${c}.${g}} | |
151 | . if (${v:M*_ENV} \ | 151 | . if (${v:M*_ENV} \ | |
152 | || ${v:M*_ENV.*}) | 152 | || ${v:M*_ENV.*} \ | |
153 | || ${v} == PLIST_SUBST \ | |||
154 | || ${v:MSUBST_VARS.*}) | |||
153 | 155 | |||
154 | # multi-valued variables, values are sorted | 156 | # multi-valued variables, values are sorted | |
155 | ${RUN} \ | 157 | ${RUN} \ | |
156 | if ${!defined(${v}) :? true : false}; then \ | 158 | if ${!defined(${v}) :? true : false}; then \ | |
157 | printf ' %s\t%s (undefined)\n' ${_LABEL.${c}} ${v:Q}; \ | 159 | printf ' %s\t%-23s # undefined\n' ${_LABEL.${c}} ${v:Q}; \ | |
158 | elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then \ | 160 | elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then \ | |
159 | printf ' %s\t%s = # empty\n' ${_LABEL.${c}} ${v:Q}; \ | 161 | printf ' %s\t%-23s # empty\n' ${_LABEL.${c}} ${v:Q}=; \ | |
160 | else \ | 162 | else \ | |
161 | printf ' %s\t%s (sorted) = \\\n' ${_LABEL.${c}} ${v:Q}; \ | 163 | printf ' %s\t%-23s \\\n' ${_LABEL.${c}} ${v:Q}=; \ | |
162 | printf ' \t\t%s \\\n' ${${v}:O:@x@${x:Q}@}; \ | 164 | printf '\t\t\t\t%s \\\n' ${${v}:O:@x@${x:Q}@}; \ | |
163 | printf ' \t\t# end of %s\n' ${v:Q}; \ | 165 | printf '\t\t\t\t# end of %s (sorted)\n' ${v:Q}; \ | |
164 | fi | 166 | fi | |
165 | 167 | |||
166 | . elif (${v:M*_ARGS} \ | 168 | . elif (${v:M*_ARGS} \ | |
167 | || ${v:M*_ARGS.*} \ | 169 | || ${v:M*_ARGS.*} \ | |
168 | || ${v:M*_CMD} \ | 170 | || ${v:M*_CMD} \ | |
169 | || ${v:M*_CMD_DEFAULT} \ | 171 | || ${v:M*_CMD_DEFAULT} \ | |
170 | || ${v:M*_SKIP} \ | 172 | || ${v:M*_SKIP} \ | |
173 | || ${v:M*INSTALL_SRC} \ | |||
171 | || ${v:MMASTER_SITE*} \ | 174 | || ${v:MMASTER_SITE*} \ | |
172 | || ${v:MSUBST_FILES.*} \ | 175 | || ${v:MSUBST_FILES.*} \ | |
173 | || ${v:MSUBST_SED.*} \ | 176 | || ${v:MSUBST_SED.*} \ | |
174 | || ${v:MSUBST_FILTER_CMD.*} \ | 177 | || ${v:MSUBST_FILTER_CMD.*} \ | |
175 | || ${v:M*_SUBST}) | 178 | || ${v:M*_SUBST}) | |
176 | 179 | |||
177 | # multi-valued variables, preserving original order | 180 | # multi-valued variables, preserving original order | |
178 | ${RUN} \ | 181 | ${RUN} \ | |
179 | if ${!defined(${v}) :? true : false}; then \ | 182 | if ${!defined(${v}) :? true : false}; then \ | |
180 | printf ' %s\t%s (undefined)\n' ${_LABEL.${c}} ${v:Q}; \ | 183 | printf ' %s\t%-23s # undefined\n' ${_LABEL.${c}} ${v:Q}; \ | |
181 | elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then \ | 184 | elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then \ | |
182 | printf ' %s\t%s = # empty\n' ${_LABEL.${c}} ${v:Q}; \ | 185 | printf ' %s\t%-23s # empty\n' ${_LABEL.${c}} ${v:Q}=; \ | |
183 | else \ | 186 | else \ | |
184 | printf ' %s\t%s = \\\n' ${_LABEL.${c}} ${v:Q}; \ | 187 | printf ' %s\t%-23s \\\n' ${_LABEL.${c}} ${v:Q}=; \ | |
185 | printf ' \t\t%s \\\n' ${${v}:@x@${x:Q}@}; \ | 188 | printf '\t\t\t\t%s \\\n' ${${v}:@x@${x:Q}@}; \ | |
186 | printf ' \t\t# end of %s\n' ${v:Q}; \ | 189 | printf '\t\t\t\t# end of %s\n' ${v:Q}; \ | |
187 | fi | 190 | fi | |
188 | 191 | |||
189 | . else | 192 | . else | |
190 | 193 | |||
191 | # single-valued variables | 194 | # single-valued variables | |
192 | ${RUN} \ | 195 | ${RUN} \ | |
193 | if ${!defined(${v}) :? true : false}; then \ | 196 | if ${!defined(${v}) :? true : false}; then \ | |
194 | printf ' %s\t%s (undefined)\n' ${_LABEL.${c}} ${v:Q}; \ | 197 | printf ' %s\t%-23s # undefined\n' ${_LABEL.${c}} ${v:Q}; \ | |
195 | elif value=${${v}:U:Q} && test "x$$value" = "x"; then \ | 198 | elif value=${${v}:U:Q} && test "x$$value" = "x"; then \ | |
196 | printf ' %s\t%s = # empty\n' ${_LABEL.${c}} ${v:Q}; \ | 199 | printf ' %s\t%-23s # empty\n' ${_LABEL.${c}} ${v:Q}=; \ | |
197 | else \ | 200 | else \ | |
198 | printf ' %s\t%s = %s\n' ${_LABEL.${c}} ${v:Q} "$$value"; \ | 201 | case "$$value" in (*[\ \ ]) eol="# ends with space";; (*) eol=""; esac; \ | |
202 | printf ' %s\t%-23s %s\n' ${_LABEL.${c}} ${v:Q}= "$$value$$eol"; \ | |||
199 | fi | 203 | fi | |
200 | 204 | |||
201 | . endif | 205 | . endif | |
202 | . endfor | 206 | . endfor | |
203 | . endfor | 207 | . endfor | |
204 | ${RUN} printf '\n' | 208 | ${RUN} printf '\n' | |
205 | .endfor | 209 | .endfor | |
206 | 210 | |||
207 | .PHONY: show-depends-options | 211 | .PHONY: show-depends-options | |
208 | show-depends-options: | 212 | show-depends-options: | |
209 | ${RUN} \ | 213 | ${RUN} \ | |
210 | ${_DEPENDS_WALK_CMD} ${PKGPATH} | \ | 214 | ${_DEPENDS_WALK_CMD} ${PKGPATH} | \ | |
211 | while read dir; do \ | 215 | while read dir; do \ | |
212 | ${ECHO} "===> Options for $${dir}" && \ | 216 | ${ECHO} "===> Options for $${dir}" && \ | |
213 | cd ${.CURDIR}/../../$$dir && \ | 217 | cd ${.CURDIR}/../../$$dir && \ | |
214 | ${RECURSIVE_MAKE} ${MAKEFLAGS} show-options; \ | 218 | ${RECURSIVE_MAKE} ${MAKEFLAGS} show-options; \ | |
215 | done | 219 | done | |
216 |
@@ -1,35 +1,34 @@ | @@ -1,35 +1,34 @@ | |||
1 | # $NetBSD: Makefile,v 1.1 2018/11/10 10:40:56 rillig Exp $ | 1 | # $NetBSD: Makefile,v 1.2 2018/11/11 19:07:12 rillig Exp $ | |
2 | 2 | |||
3 | DISTNAME= show-all-1.0 | 3 | DISTNAME= show-all-1.0 | |
4 | CATEGORIES= regress | 4 | CATEGORIES= regress | |
5 | MASTER_SITES= # none | 5 | MASTER_SITES= # none | |
6 | DISTFILES= # none | 6 | DISTFILES= # none | |
7 | 7 | |||
8 | MAINTAINER= pkgsrc-users@NetBSD.org | 8 | MAINTAINER= pkgsrc-users@NetBSD.org | |
9 | COMMENT= Demonstrates the show-all target | 9 | COMMENT= Demonstrates the show-all target | |
10 | LICENSE= 2-clause-bsd | 10 | LICENSE= 2-clause-bsd | |
11 | 11 | |||
12 | REGRESS.empty= # empty | 12 | REGRESS.empty= # empty | |
13 | REGRESS.space= ${:U } # a single space | |||
13 | REGRESS.value= All * kinds of `strange' \escape $$characters | 14 | REGRESS.value= All * kinds of `strange' \escape $$characters | |
14 | 15 | |||
15 | REGRESS_ENV.empty= # empty | 16 | REGRESS_ENV.empty= # empty | |
16 | REGRESS_ENV.space= # initially empty | 17 | REGRESS_ENV.space= ${:U } # a single space | |
17 | REGRESS_ENV.space+= # now it contains a single space | |||
18 | REGRESS_ENV.value= VAR1=value1 VAR2=`command execution via backticks` *=all | 18 | REGRESS_ENV.value= VAR1=value1 VAR2=`command execution via backticks` *=all | |
19 | 19 | |||
20 | REGRESS_ARGS.empty= # empty | 20 | REGRESS_ARGS.empty= # empty | |
21 | REGRESS_ARGS.space= # initially empty | 21 | REGRESS_ARGS.space= ${:U } # a single space | |
22 | REGRESS_ARGS.space+= # now it contains a single space | |||
23 | REGRESS_ARGS.value= VAR1=value1 VAR2=`command execution via backticks` *=all | 22 | REGRESS_ARGS.value= VAR1=value1 VAR2=`command execution via backticks` *=all | |
24 | 23 | |||
25 | # Variable names may also contain special characters that must be escaped. | 24 | # Variable names may also contain special characters that must be escaped. | |
26 | *= bmake built-in | 25 | *= bmake built-in | |
27 | **= asterisk | 26 | **= asterisk | |
28 | 27 | |||
29 | _VARGROUPS+= regress | 28 | _VARGROUPS+= regress | |
30 | _PKG_VARS.regress+= REGRESS.undefined REGRESS.empty REGRESS.value | |||
31 | _PKG_VARS.regress+= REGRESS_ENV.undefined REGRESS_ENV.empty REGRESS_ENV.space REGRESS_ENV.value | 29 | _PKG_VARS.regress+= REGRESS_ENV.undefined REGRESS_ENV.empty REGRESS_ENV.space REGRESS_ENV.value | |
32 | _PKG_VARS.regress+= REGRESS_ARGS.undefined REGRESS_ARGS.empty REGRESS_ARGS.space REGRESS_ARGS.value | 30 | _PKG_VARS.regress+= REGRESS_ARGS.undefined REGRESS_ARGS.empty REGRESS_ARGS.space REGRESS_ARGS.value | |
31 | _PKG_VARS.regress+= REGRESS.undefined REGRESS.empty REGRESS.space REGRESS.value | |||
33 | _PKG_VARS.regress+= * ** | 32 | _PKG_VARS.regress+= * ** | |
34 | 33 | |||
35 | .include "../../mk/bsd.pkg.mk" | 34 | .include "../../mk/bsd.pkg.mk" |
@@ -1,65 +1,66 @@ | @@ -1,65 +1,66 @@ | |||
1 | # $NetBSD: spec,v 1.1 2018/11/10 10:40:56 rillig Exp $ | 1 | # $NetBSD: spec,v 1.2 2018/11/11 19:07:12 rillig Exp $ | |
2 | 2 | |||
3 | tmpdir=${TMPDIR:-/tmp}/pkgsrc-show-all | 3 | tmpdir=${TMPDIR:-/tmp}/pkgsrc-show-all | |
4 | rm -rf "$tmpdir" | 4 | rm -rf "$tmpdir" | |
5 | mkdir -p "$tmpdir" | 5 | mkdir -p "$tmpdir" | |
6 | 6 | |||
7 | require_file() { | 7 | require_file() { | |
8 | if diff -u "$3" "$1" > /dev/null; then | 8 | if diff -u "$3" "$1" > /dev/null; then | |
9 | : | 9 | : | |
10 | else | 10 | else | |
11 | regress_fail "Expected files to be equal." | 11 | regress_fail "Expected files to be equal." | |
12 | diff -u "$3" "$1" || true | 12 | diff -u "$3" "$1" || true | |
13 | fi | 13 | fi | |
14 | } | 14 | } | |
15 | 15 | |||
16 | 16 | |||
17 | do_test() { | 17 | do_test() { | |
18 | $TEST_MAKE show-all-regress > "$tmpdir/show-all-regress.out" | 18 | $TEST_MAKE show-all-regress > "$tmpdir/show-all-regress.out" | |
19 | } | 19 | } | |
20 | 20 | |||
21 | check_result() { | 21 | check_result() { | |
22 | exit_status 0 | 22 | exit_status 0 | |
23 | 23 | |||
24 | cat <<'EOF' > "$tmpdir/expected" | 24 | cat <<'EOF' > "$tmpdir/expected" | |
25 | regress: | 25 | regress: | |
26 | pkg REGRESS.undefined (undefined) | 26 | pkg REGRESS_ENV.undefined # undefined | |
27 | pkg REGRESS.empty = # empty | 27 | pkg REGRESS_ENV.empty= # empty | |
28 | pkg REGRESS.value = All * kinds of `strange' \escape $characters | 28 | pkg REGRESS_ENV.space= # empty | |
29 | pkg REGRESS_ENV.undefined (undefined) | 29 | pkg REGRESS_ENV.value= \ | |
30 | pkg REGRESS_ENV.empty = # empty | 30 | *=all \ | |
31 | pkg REGRESS_ENV.space = # empty | 31 | VAR1=value1 \ | |
32 | pkg REGRESS_ENV.value (sorted) = \ | 32 | VAR2=`command \ | |
33 | *=all \ | 33 | backticks` \ | |
34 | VAR1=value1 \ | 34 | execution \ | |
35 | VAR2=`command \ | 35 | via \ | |
36 | backticks` \ | 36 | # end of REGRESS_ENV.value (sorted) | |
37 | execution \ | 37 | pkg REGRESS_ARGS.undefined # undefined | |
38 | via \ | 38 | pkg REGRESS_ARGS.empty= # empty | |
39 | # end of REGRESS_ENV.value | 39 | pkg REGRESS_ARGS.space= # empty | |
40 | pkg REGRESS_ARGS.undefined (undefined) | 40 | pkg REGRESS_ARGS.value= \ | |
41 | pkg REGRESS_ARGS.empty = # empty | 41 | VAR1=value1 \ | |
42 | pkg REGRESS_ARGS.space = # empty | 42 | VAR2=`command \ | |
43 | pkg REGRESS_ARGS.value = \ | 43 | execution \ | |
44 | VAR1=value1 \ | 44 | via \ | |
45 | VAR2=`command \ | 45 | backticks` \ | |
46 | execution \ | 46 | *=all \ | |
47 | via \ | 47 | # end of REGRESS_ARGS.value | |
48 | backticks` \ | 48 | pkg REGRESS.undefined # undefined | |
49 | *=all \ | 49 | pkg REGRESS.empty= # empty | |
50 | # end of REGRESS_ARGS.value | 50 | pkg REGRESS.space= # ends with space | |
51 | pkg * = show-all-regress | 51 | pkg REGRESS.value= All * kinds of `strange' \escape $characters | |
52 | pkg ** = asterisk | 52 | pkg *= show-all-regress | |
53 | pkg **= asterisk | |||
53 | 54 | |||
54 | EOF | 55 | EOF | |
55 | 56 | |||
56 | # The "*" variable is built-in into bmake and expands to the current | 57 | # The "*" variable is built-in into bmake and expands to the current | |
57 | # make target, which in this case is "show-all-regress". | 58 | # make target, which in this case is "show-all-regress". | |
58 | 59 | |||
59 | # The "**" variable ensures that show-all doesn't accidentally expand | 60 | # The "**" variable ensures that show-all doesn't accidentally expand | |
60 | # filenames. | 61 | # filenames. | |
61 | 62 | |||
62 | # It's a bit strange that bmake doesn't handle the backticks command | 63 | # It's a bit strange that bmake doesn't handle the backticks command | |
63 | # as a single word. Luckily, this is a rare case. | 64 | # as a single word. Luckily, this is a rare case. | |
64 | # | 65 | # | |
65 | # On the other hand, if it did, bmake would also have to handle | 66 | # On the other hand, if it did, bmake would also have to handle |