]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
build: allow `./configure _foo=x` to work like FOO=x
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Mon, 2 Feb 2026 21:24:14 +0000 (10:24 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 18 Feb 2026 00:00:30 +0000 (00:00 +0000)
OpenWRT passes arguments like '_python_sysroot=x' after the './configure',
which it expects to work as if the occurred before the './configure'
-- that is, setting environment variables (let's assume its build
system is necessarily complex due to all the cross-compiles).

This used to work (or at least not cause a failure return code) until
the upgrade to waf 2.1.5 or 2.1.6 in mid-2025, when waf started using
the argparse parser.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15990

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Feb 18 00:00:30 UTC 2026 on atb-devel-224

buildtools/wafsamba/samba_utils.py
script/autobuild.py

index 548e21b4a26eddf59c378254f73d1474b478d1f6..1fd6c42776c229d0f63de6d9f1bf8accee073e7d 100644 (file)
@@ -435,7 +435,7 @@ def CHECK_MAKEFLAGS(options):
                 Logs.zones = ['runner']
             if Logs.verbose > 2:
                 Logs.zones = ['*']
-        elif opt[0].isupper() and opt.find('=') != -1:
+        elif (opt[0].isupper() or opt[0] == '_') and '=' in opt:
             # this allows us to set waf options on the make command line
             # for example, if you do "make FOO=blah", then we set the
             # option 'FOO' in Options.options, to blah. If you look in wafsamba/wscript
@@ -470,6 +470,16 @@ def wafsamba_options_parse_cmd_args(self, _args=None, cwd=None, allow_unknown=Fa
                                       _args=_args,
                                       cwd=cwd,
                                       allow_unknown=allow_unknown)
+    commands = []
+    for arg in leftover_args:
+        if '=' in arg and (arg.startswith('_') or arg[0].isupper()):
+            # We assume this is an environment setting argument, not a
+            # build target.
+            k, v = arg.split('=', 1)
+            setattr(options, k, v)
+        else:
+            commands.append(arg)
+
     CHECK_MAKEFLAGS(options)
     if options.jobs == 1:
         #
@@ -489,7 +499,7 @@ def wafsamba_options_parse_cmd_args(self, _args=None, cwd=None, allow_unknown=Fa
                 return
         from waflib import Runner
         Runner.Spawner = NoOpSpawner
-    return options, leftover_args
+    return options, commands
 Options.OptionsContext.parse_cmd_args = wafsamba_options_parse_cmd_args
 
 option_groups = {}
index 63b0cbb8c9c14dc687540a74b05fd2d68cb905b4..b2d3bd0bde4e2227a29bb2e79ea782c9aced5842 100755 (executable)
@@ -178,6 +178,15 @@ builddirs = {
 ctdb_configure_params = " --enable-developer ${PREFIX}"
 samba_configure_params = " ${ENABLE_COVERAGE} ${PREFIX} --with-profiling-data --with-prometheus-exporter"
 
+# To test that waf copes with unknown arguments that look like
+# environment variables, we add a couple of parameters that should be
+# treated environment variables that happen to have no effect.
+#
+# This is for https://bugzilla.samba.org/show_bug.cgi?id=15990: distro
+# build systems do this kind of thing, and older versions of waf
+# allowed it.
+useless_configure_params = " _foobliosity_over_mud=7 GRISHLIHOOD_77=0"
+
 rust_configure_param = ''
 glibc_vers = float('.'.join(get_libc_version().split('.')[:2]))
 cargo = shutil.which('cargo')
@@ -283,7 +292,7 @@ tasks = {
     "samba-def-build": {
         "git-clone-required": True,
         "sequence": [
-            ("configure", "./configure.developer" + samba_configure_params),
+            ("configure", "./configure.developer" + samba_configure_params + useless_configure_params),
             ("make", "make -j"),
             ("check-clean-tree", CLEAN_SOURCE_TREE_CMD),
             ("chmod-R-a-w", "chmod -R a-w ."),