diff options
-rw-r--r-- | mk/bsd.pkg.help.mk | 62 | ||||
-rw-r--r-- | mk/bsd.pkg.mk | 7 |
2 files changed, 67 insertions, 2 deletions
diff --git a/mk/bsd.pkg.help.mk b/mk/bsd.pkg.help.mk new file mode 100644 index 00000000000..bd186bf8d94 --- /dev/null +++ b/mk/bsd.pkg.help.mk @@ -0,0 +1,62 @@ +# $NetBSD: bsd.pkg.help.mk,v 1.1 2006/08/02 09:46:22 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/defaults/mk.conf +_HELP_FILES+= mk/bsd.prefs.mk +_HELP_FILES+= mk/bsd.pkg.mk +_HELP_FILES+= mk/*/*-vars.mk + +_HELP_AWK= \ + BEGIN { \ + hline = "==============="; \ + hline = hline hline hline hline hline; \ + found = 0; \ + var = 0; comment = 0; n = 0; lines[n++] = hline; \ + } \ + /./ { \ + lines[n++] = $$0; \ + } \ + ($$1 == VARNAME"?=") || ($$1 == "\#"VARNAME"=") { \ + var = 1; \ + } \ + /^\#/ { \ + comment = 1; \ + } \ + /^$$/ { \ + if (var == 1 && comment == 1) { \ + found = 1; \ + for (i = 0; i < n; i++) { print lines[i]; } \ + } \ + var = 0; comment = 0; n = 0; lines[n++] = hline; \ + } \ + END { \ + if (found) { \ + print hline; \ + } else { \ + print "No help found for " VARNAME "."; \ + } \ + } + +.if !defined(TOPIC) && defined(VARNAME) +TOPIC= ${VARNAME} +.endif + +help: +.if !defined(TOPIC) + @${ECHO} "usage: "${MAKE:Q}" help TOPIC=<VARNAME>" 1>&2 +.else + @set -e; cd ${PKGSRCDIR}; \ + { for i in ${_HELP_FILES}; do ${CAT} "$$i"; ${ECHO} ""; done; } \ + | ${AWK} -v VARNAME=${TOPIC} '${_HELP_AWK:M*}' +.endif + +.endif diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk index 96075aa8451..aa96c02345b 100644 --- a/mk/bsd.pkg.mk +++ b/mk/bsd.pkg.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkg.mk,v 1.1878 2006/07/27 21:46:45 jlam Exp $ +# $NetBSD: bsd.pkg.mk,v 1.1879 2006/08/02 09:46:22 rillig Exp $ # # This file is in the public domain. # @@ -1017,6 +1017,9 @@ changes-entry: ${ECHO} ${_CTYPE1}${_CTYPE2}${_CTYPE3} >> ${PKGSRC_CHANGES:Q} .include "${PKGSRCDIR}/mk/internal/build-defs-message.mk" -.if make(debug) +.if make(debug) || make(build-env) .include "${PKGSRCDIR}/mk/bsd.pkg.debug.mk" .endif +.if make(help) +.include "${PKGSRCDIR}/mk/bsd.pkg.help.mk" +.endif |