| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: show.mk,v 1.25 2020/09/12 21:00:10 rillig Exp $ | | 1 | # $NetBSD: show.mk,v 1.26 2020/09/12 21:27:15 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} |
| @@ -143,84 +143,84 @@ show-build-defs: .PHONY | | | @@ -143,84 +143,84 @@ show-build-defs: .PHONY |
143 | # lists, one word per line, in the given order. | | 143 | # lists, one word per line, in the given order. |
144 | # | | 144 | # |
145 | # Default: # none | | 145 | # Default: # none |
146 | # Example: *_ARGS *_CMD SUBST_SED.* | | 146 | # Example: *_ARGS *_CMD SUBST_SED.* |
147 | # | | 147 | # |
148 | _SHOW_ALL_CATEGORIES= _USER_VARS _PKG_VARS _SYS_VARS _USE_VARS _DEF_VARS | | 148 | _SHOW_ALL_CATEGORIES= _USER_VARS _PKG_VARS _SYS_VARS _USE_VARS _DEF_VARS |
149 | _LABEL._USER_VARS= usr | | 149 | _LABEL._USER_VARS= usr |
150 | _LABEL._PKG_VARS= pkg | | 150 | _LABEL._PKG_VARS= pkg |
151 | _LABEL._SYS_VARS= sys | | 151 | _LABEL._SYS_VARS= sys |
152 | _LABEL._USE_VARS= use | | 152 | _LABEL._USE_VARS= use |
153 | _LABEL._DEF_VARS= def | | 153 | _LABEL._DEF_VARS= def |
154 | | | 154 | |
155 | show-all: .PHONY | | 155 | show-all: .PHONY |
156 | .for g in ${"${.TARGETS:Mshow-all*}":?${_VARGROUPS:O:u}:} | | 156 | .for grp in ${"${.TARGETS:Mshow-all*}":?${_VARGROUPS:O:u}:} |
157 | . for w in ${_VARGROUP_WIDTH.${g}:U23} | | 157 | . for width in ${_VARGROUP_WIDTH.${grp}:U23} |
158 | | | 158 | |
159 | show-all: show-all-${g} | | 159 | show-all: show-all-${grp} |
160 | | | 160 | |
161 | # In the following code, the variables are evaluated as late as possible. | | 161 | # In the following code, the variables are evaluated as late as possible. |
162 | # This is especially important for variables that use the :sh modifier, | | 162 | # This is especially important for variables that use the :sh modifier, |
163 | # like SUBST_FILES.pkglocaledir from mk/configure/replace-localedir.mk. | | 163 | # like SUBST_FILES.pkglocaledir from mk/configure/replace-localedir.mk. |
164 | # | | 164 | # |
165 | # When finally showing the variables, it is unavoidable that variables | | 165 | # When finally showing the variables, it is unavoidable that variables |
166 | # using the :sh modifier may show warnings, for example because ${WRKDIR} | | 166 | # using the :sh modifier may show warnings, for example because ${WRKDIR} |
167 | # doesn't exist. | | 167 | # doesn't exist. |
168 | | | 168 | |
169 | show-all-${g}: .PHONY | | 169 | show-all-${grp}: .PHONY |
170 | @${RUN} printf '%s:\n' ${g:Q} | | 170 | @${RUN} printf '%s:\n' ${grp:Q} |
171 | | | 171 | |
172 | . for c in ${_SHOW_ALL_CATEGORIES} | | 172 | . for cat in ${_SHOW_ALL_CATEGORIES} |
173 | . for v in ${${c}.${g}} | | 173 | . for var in ${${cat}.${grp}} |
174 | | | 174 | |
175 | . if ${_SORTED_VARS.${g}:U:@pattern@ ${v:M${pattern}} @:M*} | | 175 | . if ${_SORTED_VARS.${grp}:U:@pattern@ ${var:M${pattern}} @:M*} |
176 | | | 176 | |
177 | # multi-valued variables, values are sorted | | 177 | # multi-valued variables, values are sorted |
178 | ${RUN} \ | | 178 | ${RUN} \ |
179 | if ${!defined(${v}) :? true : false}; then \ | | 179 | if ${!defined(${var}) :? true : false}; then \ |
180 | printf ' %-6s%-${w}s # undefined\n' ${_LABEL.${c}} ${v:Q}; \ | | 180 | printf ' %-6s%-${width}s # undefined\n' ${_LABEL.${cat}} ${var:Q}; \ |
181 | elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then \ | | 181 | elif value=${${var}:U:M*:Q} && test "x$$value" = "x"; then \ |
182 | printf ' %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=; \ | | 182 | printf ' %-6s%-${width}s # empty\n' ${_LABEL.${cat}} ${var:Q}=; \ |
183 | else \ | | 183 | else \ |
184 | printf ' %-6s%-${w}s \\''\n' ${_LABEL.${c}} ${v:Q}=; \ | | 184 | printf ' %-6s%-${width}s \\''\n' ${_LABEL.${cat}} ${var:Q}=; \ |
185 | printf ' %-${w}s %s \\''\n' ${${v}:O:C,\\\$,\$\$\$\$,g:@x@'' ${x:Q}@}; \ | | 185 | printf ' %-${width}s %s \\''\n' ${${var}:O:C,\\\$,\$\$\$\$,g:@word@'' ${word:Q}@}; \ |
186 | printf ' %-${w}s # end of %s (sorted)\n' '' ${v:Q}; \ | | 186 | printf ' %-${width}s # end of %s (sorted)\n' '' ${var:Q}; \ |
187 | fi | | 187 | fi |
188 | | | 188 | |
189 | . elif ${_LISTED_VARS.${g}:U:@pattern@ ${v:M${pattern}} @:M*} | | 189 | . elif ${_LISTED_VARS.${grp}:U:@pattern@ ${var:M${pattern}} @:M*} |
190 | | | 190 | |
191 | # multi-valued variables, preserving original order | | 191 | # multi-valued variables, preserving original order |
192 | ${RUN} \ | | 192 | ${RUN} \ |
193 | if ${!defined(${v}) :? true : false}; then \ | | 193 | if ${!defined(${var}) :? true : false}; then \ |
194 | printf ' %-6s%-${w}s # undefined\n' ${_LABEL.${c}} ${v:Q}; \ | | 194 | printf ' %-6s%-${width}s # undefined\n' ${_LABEL.${cat}} ${var:Q}; \ |
195 | elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then \ | | 195 | elif value=${${var}:U:M*:Q} && test "x$$value" = "x"; then \ |
196 | printf ' %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=; \ | | 196 | printf ' %-6s%-${width}s # empty\n' ${_LABEL.${cat}} ${var:Q}=; \ |
197 | else \ | | 197 | else \ |
198 | printf ' %-6s%-${w}s \\''\n' ${_LABEL.${c}} ${v:Q}=; \ | | 198 | printf ' %-6s%-${width}s \\''\n' ${_LABEL.${cat}} ${var:Q}=; \ |
199 | printf ' %-${w}s %s \\''\n' ${${v}:C,\\\$,\$\$\$\$,g:@x@'' ${x:Q}@}; \ | | 199 | printf ' %-${width}s %s \\''\n' ${${var}:C,\\\$,\$\$\$\$,g:@word@'' ${word:Q}@}; \ |
200 | printf ' %-${w}s # end of %s\n' '' ${v:Q}; \ | | 200 | printf ' %-${width}s # end of %s\n' '' ${var:Q}; \ |
201 | fi | | 201 | fi |
202 | | | 202 | |
203 | . else | | 203 | . else |
204 | | | 204 | |
205 | # single-valued variables | | 205 | # single-valued variables |
206 | ${RUN} \ | | 206 | ${RUN} \ |
207 | if ${!defined(${v}) :? true : false}; then \ | | 207 | if ${!defined(${var}) :? true : false}; then \ |
208 | printf ' %-6s%-${w}s # undefined\n' ${_LABEL.${c}} ${v:Q}; \ | | 208 | printf ' %-6s%-${width}s # undefined\n' ${_LABEL.${cat}} ${var:Q}; \ |
209 | elif value=${${v}:U:C,\\\$,\$\$,gW:Q} && test "x$$value" = "x"; then \ | | 209 | elif value=${${var}:U:C,\\\$,\$\$,gW:Q} && test "x$$value" = "x"; then \ |
210 | printf ' %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=; \ | | 210 | printf ' %-6s%-${width}s # empty\n' ${_LABEL.${cat}} ${var:Q}=; \ |
211 | else \ | | 211 | else \ |
212 | case "$$value" in (*[\ \ ]) eol="# ends with space";; (*) eol=""; esac; \ | | 212 | case "$$value" in (*[\ \ ]) eol="# ends with space";; (*) eol=""; esac; \ |
213 | printf ' %-6s%-${w}s %s\n' ${_LABEL.${c}} ${v:Q}= "$$value$$eol"; \ | | 213 | printf ' %-6s%-${width}s %s\n' ${_LABEL.${cat}} ${var:Q}= "$$value$$eol"; \ |
214 | fi | | 214 | fi |
215 | | | 215 | |
216 | . endif | | 216 | . endif |
217 | . endfor | | 217 | . endfor |
218 | . endfor | | 218 | . endfor |
219 | ${RUN} printf '\n' | | 219 | ${RUN} printf '\n' |
220 | . endfor | | 220 | . endfor |
221 | .endfor | | 221 | .endfor |
222 | | | 222 | |
223 | .PHONY: show-depends-options | | 223 | .PHONY: show-depends-options |
224 | show-depends-options: | | 224 | show-depends-options: |
225 | ${RUN} \ | | 225 | ${RUN} \ |
226 | ${_DEPENDS_WALK_CMD} ${PKGPATH} | \ | | 226 | ${_DEPENDS_WALK_CMD} ${PKGPATH} | \ |