blob: 5f51305a23fba5ad0c5be88f57f2565bd1bd17c8 (
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
79
80
81
82
83
84
85
86
87
88
89
90
|
# $NetBSD: bsd.pkg.help.mk,v 1.5 2006/10/01 14:52:32 rillig Exp $
#
# This is the integrated pkgsrc online help system. To query for the
# meaning of a variable, run "make help TOPIC=VARNAME". All variables from
# certain pkgsrc Makefile fragments that have inline comments are eligible
# for querying.
.if !defined(_PKGSRC_HELP_MK)
_PKGSRC_HELP_MK= # defined
_HELP_FILES= # empty
_HELP_FILES+= mk/*.mk
_HELP_FILES+= mk/*/*.mk
_HELP_AWK= \
BEGIN { \
no = 0; yes = 1; \
hline = "==============="; \
hline = hline hline hline hline hline; \
found = no; var = no; comment = no; n = 0; \
rcsid = ""; \
last_line_was_rcsid = no; \
last_line_was_empty = yes; \
} \
/./ { \
if ($$0 ~ /^\\#.*\$$.*\$$$$/) { \
rcsid = $$0; \
last_line_was_rcsid = yes; \
} else { \
if (!(last_line_was_rcsid && $$0 == "\#")) { \
lines[n++] = $$0; \
} \
last_line_was_rcsid = no; \
} \
} \
($$1 == VARNAME"?=") || ($$1 == "\#"VARNAME"=") \
|| ($$1 == "\#" && last_line_was_empty && \
($$2 == VARNAME || $$2 == VARNAME":")) { \
var = 1; \
} \
/^\#/ { \
comment = 1; \
} \
/^$$/ { \
if (var && comment) { \
found = yes; \
print hline; \
if (rcsid != "") { print rcsid; print "\#"; } \
for (i = 0; i < n; i++) { print lines[i]; } \
} \
var = no; comment = no; n = 0; \
} \
/./ { \
last_line_was_empty = no; \
} \
/^\\#$$/ || /^$$/ { \
last_line_was_empty = yes; \
} \
END { \
if (found) { \
print hline; \
} else { \
print "No help found for " VARNAME "."; \
} \
}
.if !defined(TOPIC) && defined(VARNAME)
TOPIC= ${VARNAME}
.endif
.if !defined(TOPIC) && defined(topic)
TOPIC= ${topic}
.endif
.PHONY: help
help:
.if !defined(TOPIC)
@${PRINTF} "usage: %s help topic=<topic>\\n" ${MAKE:Q}
@${PRINTF} "\\n"
@${PRINTF} "\\t<topic> may be a variable name or a make target,\\n"
@${PRINTF} "\\tfor example CONFIGURE_DIRS or patch.\\n"
@${PRINTF} "\\n"
.else
${_PKG_SILENT}${_PKG_DEBUG} set -e; \
cd ${PKGSRCDIR}; \
{ for i in ${_HELP_FILES}; do ${CAT} "$$i"; ${ECHO} ""; done; } \
| ${AWK} -v VARNAME=${TOPIC} '${_HELP_AWK}'
.endif
.endif
|