summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-05-21 13:42:10 +0000
committerrillig <rillig@pkgsrc.org>2020-05-21 13:42:10 +0000
commit40e0a199cd77330a5d7edc0ef61d38b50887d0e2 (patch)
treef46a8390e10ad3f1b0cb56eec9d5e90a9b4588c8 /mk
parent92418464350826d33bffeb80a53ba30fbd83b4b7 (diff)
downloadpkgsrc-40e0a199cd77330a5d7edc0ef61d38b50887d0e2.tar.gz
mk/configure: completely rewrite check for unknown configure options
The previous implementation could not reliably detect outdated configure options. This was apparent in devel/gettext-tools, where the option --with-included-libcroco had become unknown between May 2019 and May 2020, but the check was not run. The behavior is the same in the pkgsrc default configuration. Only if GNU_CONFIGURE_STRICT=yes, the new check is activated and will make packages fail that previously succeeded to build. Since that variable is not widely known, there won't be much sudden breakage, if any.
Diffstat (limited to 'mk')
-rw-r--r--mk/configure/gnu-configure-unknown.awk83
-rw-r--r--mk/configure/gnu-configure.mk54
2 files changed, 42 insertions, 95 deletions
diff --git a/mk/configure/gnu-configure-unknown.awk b/mk/configure/gnu-configure-unknown.awk
deleted file mode 100644
index 28fa3bbec76..00000000000
--- a/mk/configure/gnu-configure-unknown.awk
+++ /dev/null
@@ -1,83 +0,0 @@
-#! 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 37510038433..fd6e2438f95 100644
--- a/mk/configure/gnu-configure.mk
+++ b/mk/configure/gnu-configure.mk
@@ -1,4 +1,4 @@
-# $NetBSD: gnu-configure.mk,v 1.22 2019/10/06 09:44:41 rillig Exp $
+# $NetBSD: gnu-configure.mk,v 1.23 2020/05/21 13:42:10 rillig Exp $
#
# Package-settable variables:
#
@@ -211,20 +211,50 @@ CONFIGURE_ARGS+= --enable-option-checking=fatal
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.
+_SHOW_UNKNOWN_CONFIGURE_OPTIONS_CMD= \
+ cd ${WRKSRC}; \
+ configures=$$( \
+ ${FIND} ${CONFIGURE_DIRS} -name configure \
+ | ${SED} -e 's,^${WRKSRC}/,,' \
+ | LC_ALL=C ${SORT} -u \
+ | ${TR} '\n' ' ' \
+ | ${SED} 's, $$,,'); \
+ exitcode=0; \
+ for opt in "" \
+ ${CONFIGURE_ARGS:M--enable-*} \
+ ${CONFIGURE_ARGS:M--disable-*} \
+ ${CONFIGURE_ARGS:M--with-*} \
+ ${CONFIGURE_ARGS:M--without-*}; do \
+ [ "$$opt" ] || continue; \
+ optvar=$${opt%%=*}; \
+ optvar=$${optvar\#--}; \
+ optvar=$$(${ECHO} "$$optvar" \
+ | ${SED} -e 's/[-+.]/_/g' \
+ -e 's,^disable_,enable_,' \
+ -e 's,^without_,with_,'); \
+ [ "$$optvar" = 'enable_option_checking' ] && continue; \
+ ${GREP} "^$$optvar$$" $$configures 1>/dev/null || { \
+ ${ERROR_MSG} "[gnu-configure.mk] option $$opt not found in $$configures"; \
+ exitcode=1; \
+ }; \
+ done
+
+# Inspects the configure scripts of a package to see whether each option
+# of the form --enable-* or --disable-* or --with-* or --without-* is
+# known to at least one of the configure scripts. If that is not the
+# case, the option is outdated in most cases, or it has a typo.
#
# 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}
+ ${RUN} ${_SHOW_UNKNOWN_CONFIGURE_OPTIONS_CMD}
+
+.if ${GNU_CONFIGURE_STRICT:tl} == yes
+USE_TOOLS+= find grep sed sort tr
+
+pre-configure-checks-hook: _check-unknown-configure-options
+_check-unknown-configure-options: .PHONY
+ ${RUN} ${_SHOW_UNKNOWN_CONFIGURE_OPTIONS_CMD}; exit $$exitcode
+.endif