pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc



Module Name:    pkgsrc
Committed By:   rillig
Date:           Thu May 21 13:42:10 UTC 2020

Modified Files:
        pkgsrc/mk/configure: gnu-configure.mk
Added Files:
        pkgsrc/regress/infra-unittests: gnu-configure-strict.sh
Removed Files:
        pkgsrc/mk/configure: gnu-configure-unknown.awk
        pkgsrc/regress/gnu-configure-strict: spec t-gettext-tools.test
            t-simple-unrecognized.test t-subdirs-ok.test
            t-subdirs-only-in-main.test t-subdirs-unrecognized.test
            t-verbose.test

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r0 pkgsrc/mk/configure/gnu-configure-unknown.awk
cvs rdiff -u -r1.22 -r1.23 pkgsrc/mk/configure/gnu-configure.mk
cvs rdiff -u -r1.1 -r0 pkgsrc/regress/gnu-configure-strict/spec \
    pkgsrc/regress/gnu-configure-strict/t-gettext-tools.test \
    pkgsrc/regress/gnu-configure-strict/t-simple-unrecognized.test \
    pkgsrc/regress/gnu-configure-strict/t-subdirs-ok.test \
    pkgsrc/regress/gnu-configure-strict/t-subdirs-only-in-main.test \
    pkgsrc/regress/gnu-configure-strict/t-subdirs-unrecognized.test \
    pkgsrc/regress/gnu-configure-strict/t-verbose.test
cvs rdiff -u -r0 -r1.1 pkgsrc/regress/infra-unittests/gnu-configure-strict.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/mk/configure/gnu-configure.mk
diff -u pkgsrc/mk/configure/gnu-configure.mk:1.22 pkgsrc/mk/configure/gnu-configure.mk:1.23
--- pkgsrc/mk/configure/gnu-configure.mk:1.22   Sun Oct  6 09:44:41 2019
+++ pkgsrc/mk/configure/gnu-configure.mk        Thu May 21 13:42:10 2020
@@ -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-checkin
 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

Added files:

Index: pkgsrc/regress/infra-unittests/gnu-configure-strict.sh
diff -u /dev/null pkgsrc/regress/infra-unittests/gnu-configure-strict.sh:1.1
--- /dev/null   Thu May 21 13:42:10 2020
+++ pkgsrc/regress/infra-unittests/gnu-configure-strict.sh      Thu May 21 13:42:10 2020
@@ -0,0 +1,399 @@
+#! /bin/sh
+# $NetBSD: gnu-configure-strict.sh,v 1.1 2020/05/21 13:42:10 rillig Exp $
+#
+# Tests for GNU_CONFIGURE_STRICT handling in mk/configure/gnu-configure.mk.
+#
+
+set -eu
+
+. './test.subr'
+
+test_case_set_up() {
+       create_file 'setup.mk' <<-EOF
+               ECHO=           echo
+               FIND=           find
+               GREP=           grep
+               SED=            sed
+               SORT=           sort
+               TR=             tr
+
+               RUN=            @set -eu; # be extra strict
+               ERROR_MSG=      echo 'error:'
+
+               GNU_CONFIGURE_PREFIX= unused-GNU_CONFIGURE_PREFIX
+               PREFIX=         unused-PREFIX
+               OPSYS=          NetBSD
+               WRKDIR=         $PWD
+               WRKSRC=         $PWD
+       EOF
+}
+
+
+if test_case_begin 'single configure'; then
+
+       create_file 'testcase.mk' <<-EOF
+               GNU_CONFIGURE_STRICT=   yes
+               CONFIGURE_DIRS=         .
+               CONFIGURE_ARGS=         --enable-known
+               CONFIGURE_ARGS+=        --disable-known
+               CONFIGURE_ARGS+=        --with-known
+               CONFIGURE_ARGS+=        --without-known
+
+               .include "setup.mk"
+               .include "mk/configure/gnu-configure.mk"
+       EOF
+       create_file 'configure' <<-EOF
+               enable_known
+               with_known
+       EOF
+
+       run_bmake 'testcase.mk' '_check-unknown-configure-options' \
+               1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "$tmpdir/output" --file-is-empty
+
+       test_case_end
+fi
+
+
+if test_case_begin 'neither --enable nor --with given'; then
+
+       # Make sure that there is no shell syntax error in the for loop.
+       #
+       # This test also covers the case where the configure script has
+       # some options that are not mentioned in CONFIGURE_ARGS.
+
+       create_file 'testcase.mk' <<-EOF
+               GNU_CONFIGURE_STRICT=   yes
+               CONFIGURE_DIRS=         .
+
+               .include "setup.mk"
+               .include "mk/configure/gnu-configure.mk"
+       EOF
+       create_file 'configure' <<-EOF
+               enable_known
+               with_known
+       EOF
+
+       run_bmake 'testcase.mk' '_check-unknown-configure-options' \
+               1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "$tmpdir/output" --file-is-empty
+
+       test_case_end
+fi
+
+
+if test_case_begin 'some unknown options'; then
+
+       create_file 'testcase.mk' <<-EOF
+               GNU_CONFIGURE_STRICT=   yes
+               CONFIGURE_DIRS=         .
+
+               CONFIGURE_ARGS=         --enable-unknown-1
+               CONFIGURE_ARGS+=        --disable-unknown-2
+               CONFIGURE_ARGS+=        --with-unknown-3
+               CONFIGURE_ARGS+=        --without-unknown-4
+
+               .include "setup.mk"
+               .include "mk/configure/gnu-configure.mk"
+       EOF
+       create_file 'configure' <<-EOF
+               enable_known
+               with_known
+       EOF
+
+       run_bmake 'testcase.mk' '_check-unknown-configure-options' \
+               1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "$exitcode" --equals '1'
+       assert_that "$tmpdir/output" --file-is-lines \
+               'error: [gnu-configure.mk] option --enable-unknown-1 not found in ./configure' \
+               'error: [gnu-configure.mk] option --disable-unknown-2 not found in ./configure' \
+               'error: [gnu-configure.mk] option --with-unknown-3 not found in ./configure' \
+               'error: [gnu-configure.mk] option --without-unknown-4 not found in ./configure' \
+               '*** Error code 1' \
+               '' \
+               'Stop.' \
+               "$make: stopped in $PWD"
+
+       test_case_end
+fi
+
+
+if test_case_begin 'unknown options in multiple configures'; then
+
+       create_file 'testcase.mk' <<-EOF
+               GNU_CONFIGURE_STRICT=   yes
+               CONFIGURE_DIRS=         .
+
+               CONFIGURE_ARGS=         --enable-main
+               CONFIGURE_ARGS+=        --with-main
+               CONFIGURE_ARGS+=        --enable-sub1
+               CONFIGURE_ARGS+=        --with-sub1
+               CONFIGURE_ARGS+=        --enable-sub2
+               CONFIGURE_ARGS+=        --with-sub2
+
+               .include "setup.mk"
+               .include "mk/configure/gnu-configure.mk"
+       EOF
+       create_file 'configure' <<-EOF
+               enable_main
+               with_main
+       EOF
+       create_file 'subdir1/configure' <<-EOF
+               enable_sub1
+       EOF
+       create_file 'subdir2/configure' <<-EOF
+               with_sub2
+       EOF
+
+       run_bmake 'testcase.mk' '_check-unknown-configure-options' \
+               1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "$exitcode" --equals '1'
+       assert_that "$tmpdir/output" --file-is-lines \
+               'error: [gnu-configure.mk] option --enable-sub2 not found in ./configure ./subdir1/configure ./subdir2/configure' \
+               'error: [gnu-configure.mk] option --with-sub1 not found in ./configure ./subdir1/configure ./subdir2/configure' \
+               '*** Error code 1' \
+               '' \
+               'Stop.' \
+               "$make: stopped in $PWD"
+
+       test_case_end
+fi
+
+
+if test_case_begin 'realistic example from gettext-tools-0.20.2 as of 2020-05-21'; then
+
+       # Each of the subdirectories flags several options as unrecognized,
+       # but in summary, each of the given options is used in at least one
+       # subdirectory, which in this case is gettext-tools.
+
+       create_file './configure' <<-EOF
+               enable_option_checking
+               enable_silent_rules
+               enable_dependency_tracking
+               enable_java
+               enable_csharp
+               enable_largefile
+               enable_threads
+               enable_shared
+               enable_static
+               with_pic
+               enable_fast_install
+               with_aix_soname
+               with_gnu_ld
+               with_sysroot
+               enable_libtool_lock
+               enable_nls
+               enable_rpath
+               with_libiconv_prefix
+               enable_c__
+               with_included_gettext
+               with_libintl_prefix
+               enable_cross_guesses
+               enable_relocatable
+               enable_libasprintf
+               enable_curses
+               with_libncurses_prefix
+               with_libtermcap_prefix
+               with_libxcurses_prefix
+               with_libcurses_prefix
+               enable_namespacing
+               with_libtextstyle_prefix
+               enable_openmp
+               enable_acl
+               with_included_libunistring
+               with_libunistring_prefix
+               with_included_libxml
+               with_libxml2_prefix
+               with_included_regex
+               with_emacs
+               with_lispdir
+               with_git
+               with_cvs
+               with_bzip2
+               with_xz
+       EOF
+       create_file './gettext-runtime/configure' <<-EOF
+               enable_option_checking
+               enable_silent_rules
+               enable_dependency_tracking
+               enable_java
+               enable_csharp
+               enable_largefile
+               enable_threads
+               enable_shared
+               enable_static
+               with_pic
+               enable_fast_install
+               with_aix_soname
+               with_gnu_ld
+               with_sysroot
+               enable_libtool_lock
+               enable_nls
+               enable_rpath
+               with_libiconv_prefix
+               enable_c__
+               with_included_gettext
+               with_libintl_prefix
+               enable_cross_guesses
+               enable_relocatable
+               enable_libasprintf
+       EOF
+       create_file './gettext-runtime/libasprintf/configure' <<-EOF
+               enable_option_checking
+               enable_silent_rules
+               enable_dependency_tracking
+               enable_shared
+               enable_static
+               with_pic
+               enable_fast_install
+               with_aix_soname
+               with_gnu_ld
+               with_sysroot
+               enable_libtool_lock
+               enable_cross_guesses
+       EOF
+       create_file './gettext-tools/configure' <<-EOF
+               enable_option_checking
+               enable_silent_rules
+               enable_dependency_tracking
+               enable_java
+               enable_csharp
+               enable_largefile
+               enable_threads
+               enable_shared
+               enable_static
+               with_pic
+               enable_fast_install
+               with_aix_soname
+               with_gnu_ld
+               with_sysroot
+               enable_libtool_lock
+               enable_nls
+               enable_rpath
+               with_libiconv_prefix
+               enable_c__
+               with_included_gettext
+               with_libintl_prefix
+               with_installed_libtextstyle
+               with_libtextstyle_prefix
+               with_installed_csharp_dll
+               enable_openmp
+               enable_cross_guesses
+               enable_acl
+               with_included_libunistring
+               with_libunistring_prefix
+               with_included_libxml
+               with_libxml2_prefix
+               enable_relocatable
+               with_included_regex
+               with_emacs
+               with_lispdir
+               with_git
+               with_cvs
+               with_bzip2
+               with_xz
+       EOF
+       create_file './gettext-tools/examples/configure' <<-EOF
+               enable_option_checking
+               enable_silent_rules
+               enable_nls
+       EOF
+       create_file './libtextstyle/configure' <<-EOF
+               enable_option_checking
+               enable_silent_rules
+               enable_dependency_tracking
+               enable_largefile
+               enable_shared
+               enable_static
+               with_pic
+               enable_fast_install
+               with_aix_soname
+               with_gnu_ld
+               with_sysroot
+               enable_libtool_lock
+               enable_cross_guesses
+               enable_rpath
+               with_libiconv_prefix
+               enable_curses
+               with_libncurses_prefix
+               with_libtermcap_prefix
+               with_libxcurses_prefix
+               with_libcurses_prefix
+               enable_namespacing
+       EOF
+
+       create_file 'testcase.mk' <<-EOF
+               GNU_CONFIGURE_STRICT=   yes
+               CONFIGURE_DIRS=         .
+               CONFIGURE_ARGS+=        --disable-csharp
+               CONFIGURE_ARGS+=        --disable-java
+               CONFIGURE_ARGS+=        --with-included-libcroco
+               CONFIGURE_ARGS+=        --without-git
+               CONFIGURE_ARGS+=        --with-xz
+               CONFIGURE_ARGS+=        --without-included-gettext
+               CONFIGURE_ARGS+=        --without-emacs
+               CONFIGURE_ARGS+=        --disable-openmp
+               CONFIGURE_ARGS+=        --prefix=/home/pbulk/pkg
+               CONFIGURE_ARGS+=        --build=x86_64--netbsd
+               CONFIGURE_ARGS+=        --host=x86_64--netbsd
+               CONFIGURE_ARGS+=        --infodir=/home/pbulk/pkg/info
+               CONFIGURE_ARGS+=        --mandir=/home/pbulk/pkg/man
+
+               .include "setup.mk"
+               #RUN=set -eux;
+               .include "mk/configure/gnu-configure.mk"
+       EOF
+
+       run_bmake 'testcase.mk' '_check-unknown-configure-options' \
+               1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       # There is one option that is unknown in all configure scripts.
+       #
+       # This was already reported by the implementation before May
+       # 2020.  That check was expensive to run though, therefore it
+       # had to be run manually.
+       #
+       # In May 2019, when GNU_CONFIGURE_STRICT=no was added to the
+       # package, the check reported: "good: all 8 options are used
+       # somewhere".  With the update to 0.20.2, the option had been
+       # removed but the check was never run again.  This made the
+       # check pretty useless since detecting outdated definitions was
+       # its primary purpose.
+       #
+       # In May 2020, if the old check had been run, it reported:
+       # "option --with-included-libcroco is unknown in all 6 configure
+       # scripts".
+       #
+       # The May 2020 implementation of this check does not require
+       # packages with multiple configure scripts to set this variable,
+       # which immediately flags these outdated definitions instead of
+       # hiding them just because it had worked some day in the past.
+       # Furthermore, it is very cheap to run since it statically
+       # analyzes the configure scripts instead of running them.
+       #
+       # This approach also has its drawbacks though.  It does not
+       # detect cases in which only some of the configure scripts are
+       # actually used for a build but the unknown option is defined in
+       # one of the unused configure scripts.  This case happens less
+       # often than a regular package update, therefore it is
+       # acceptable.
+
+       assert_that "$exitcode" --equals '1'
+       assert_that "$tmpdir/output" --file-is-lines \
+               'error: [gnu-configure.mk] option --with-included-libcroco not found in ./configure ./gettext-runtime/configure ./gettext-runtime/libasprintf/configure ./gettext-tools/configure 
./gettext-tools/examples/configure ./libtextstyle/configure' \
+               '*** Error code 1' \
+               '' \
+               'Stop.' \
+               "$make: stopped in $PWD"
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index