diff options
author | rillig <rillig@pkgsrc.org> | 2019-05-04 15:16:50 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2019-05-04 15:16:50 +0000 |
commit | 773adbae92949dd501df4fcb900f2b1804439587 (patch) | |
tree | c2cb8639749877bc8f226de1cc93d2d40e4ab082 /mk | |
parent | 4fd7954d250d619e698b70429552a63cdbd6fc65 (diff) | |
download | pkgsrc-773adbae92949dd501df4fcb900f2b1804439587.tar.gz |
mk/configure: assist in finding unrecognized configure options
Instead of giving instructions, just to the work automatically as far as
it can be automated.
Diffstat (limited to 'mk')
-rw-r--r-- | mk/configure/gnu-configure-unknown.awk | 83 | ||||
-rw-r--r-- | mk/configure/gnu-configure.mk | 46 |
2 files changed, 119 insertions, 10 deletions
diff --git a/mk/configure/gnu-configure-unknown.awk b/mk/configure/gnu-configure-unknown.awk new file mode 100644 index 00000000000..28fa3bbec76 --- /dev/null +++ b/mk/configure/gnu-configure-unknown.awk @@ -0,0 +1,83 @@ +#! awk +# $NetBSD: gnu-configure-unknown.awk,v 1.1 2019/05/04 15:16:50 rillig Exp $ +# +# Inspects all GNU configure scripts from a package, including nested +# ones, to see whether command line options that are reported as +# unrecognized by one of them are also unrecognized by the others. +# +# See GNU_CONFIGURE_STRICT. + +BEGIN { + # The set of all options from all configure scripts, + # kept in insertion order to guarantee reproducible output. + delete opts; opts_len = 0; delete opts_seen; + + # The list of subdirectories from which a configure script + # has been executed. + delete subdirs; subdirs_len = 0; + + # There's always at least one configure script. + # This script may execute others. + subdir = "."; + subdirs[subdirs_len++] = subdir; +} + +/^=== configuring in / { + subdir = $4; + subdirs[subdirs_len++] = subdir; +} + +/^configure: WARNING: unrecognized options: / { + for (i = 5; i <= NF; i++) { + opt = $i; + sub(",", "", opt); + if (!opts_seen[opt]++) { + opts[opts_len++] = opt; + } + unknown[subdir, opt] = 1; + } +} + +function count_unknown(opt, n, i) { + n = 0; + for (i in subdirs) { + if (unknown[subdirs[i], opt]) { + n++; + } + } + return n; +} + +function summary(opt, n) { + n = count_unknown(opt); + if (n == subdirs_len) { + print("option " opt " is unknown", + "in all " subdirs_len " configure scripts"); + return 1; + } + + if ("PKG_VERBOSE" in ENVIRON) { + print("good: option " opt " is known", + "in " (subdirs_len - n), + "of " subdirs_len " configure scripts"); + return 1; + } + + return 0; +} + +function finish(_, i, msgs) { + msgs = 0; + for (i = 0; i < opts_len; i++) { + msgs += summary(opts[i]); + } + + if (msgs == 0) { + print("good: all " opts_len " options are used somewhere"); + print("please set GNU_CONFIGURE_STRICT=no in the package"); + } +} + +END { + finish() +} diff --git a/mk/configure/gnu-configure.mk b/mk/configure/gnu-configure.mk index ebbbec4b78d..4823df36491 100644 --- a/mk/configure/gnu-configure.mk +++ b/mk/configure/gnu-configure.mk @@ -1,4 +1,4 @@ -# $NetBSD: gnu-configure.mk,v 1.20 2019/05/04 08:43:06 rillig Exp $ +# $NetBSD: gnu-configure.mk,v 1.21 2019/05/04 15:16:50 rillig Exp $ # # Package-settable variables: # @@ -13,15 +13,19 @@ # Whether unknown --enable/--disable/--with/--without options make # the package fail immediately. # -# When this check fails, inspect the configure script using "bmake -# configure-help" and adjust the CONFIGURE_ARGS accordingly. -# Inspect whether the configure script runs embedded configure -# scripts from subdirectories. In that case, some of the -# sub-configure scripts may need the options and some may not know -# them at all. +# Command line options that are unknown for all configure scripts +# of a package are effectively ignored and should be replaced with +# their current equivalent (in case they have been renamed), or +# otherwise be removed. # -# Possible: yes no +# This check may incorrectly report unknown options for packages +# that have multiple configure scripts, when one of these scripts +# recognizes the option and some other doesn't. To check this, run +# "bmake show-unknown-configure-options" after the package failed. +# +# Possible: yes no warn # Default: no +# See also: configure-help show-unknown-configure-options # # Keywords: configure configure_args gnu @@ -200,5 +204,27 @@ configure-scripts-osdep: done .endif -GNU_CONFIGURE_STRICT?= no -CONFIGURE_ARGS+= ${"${GNU_CONFIGURE_STRICT:M[yY][eE][sS]}":?--enable-option-checking=fatal:} +GNU_CONFIGURE_STRICT?= warn +.if ${GNU_CONFIGURE_STRICT:M[yY][eE][sS]} +CONFIGURE_ARGS+= --enable-option-checking=fatal +.elif ${GNU_CONFIGURE_STRICT} == warn +CONFIGURE_ARGS+= --enable-option-checking=yes +.endif + +# Inspects the configure scripts of a package to see whether there are +# multiple configure scripts, and one of them reports an option as +# unrecognized while some other still needs it. +# +# This target is expected to be called manually, after a package failed +# to configure because of the GNU_CONFIGURE_STRICT check. +# +# See also: GNU_CONFIGURE_STRICT configure-help +# +# Keywords: GNU_CONFIGURE_STRICT configure-help +show-unknown-configure-options: .PHONY + ${RUN} ${MAKE} patch + ${RUN} ${RM} -f ${_COOKIE.configure} + @${STEP_MSG} "Running configure scripts silently" + ${RUN} ${MAKE} configure GNU_CONFIGURE_STRICT=warn 2>&1 \ + | ${AWK} -f ${PKGSRCDIR}/mk/configure/gnu-configure-unknown.awk + ${RUN} ${RM} -f ${_COOKIE.configure} |