]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: warn about unknown USE_* variables
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2024 06:27:18 +0000 (08:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2024 09:06:19 +0000 (11:06 +0200)
William suggested that it would be nice to warn about unknown USE_*
variables to more easily catch misspelled ones. The valid ones are
present in use_opts, so by appending "=%" to each of them, we can
build a series of patterns to exclude from MAKEOVERRIDES and emit
a warning for the ones that stand out.

Example:

  $ make TARGET=linux-glibc  USE_QUIC_COMPAT_OPENSSL=1
  Makefile:338: Warning: ignoring unknown build option: USE_QUIC_COMPAT_OPENSSL=1
    CC      src/slz.o

Makefile
include/make/options.mk

index af40c7b79c2b55f7970560e025bc6073fce71f31..71a8c2179e49e937fed3dfe89a23538cfcd47ca5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -322,6 +322,9 @@ use_opts = USE_EPOLL USE_KQUEUE USE_NETFILTER USE_POLL                        \
 # preset all variables for all supported build options among use_opts
 $(reset_opts_vars)
 
+# Check that any USE_* variable that was forced actually exist.
+$(warn_unknown_options)
+
 #### Target system options
 
 # poll() is always supported, unless explicitly disabled by passing USE_POLL=""
index 022981cb809bb3d819f506ce520e60e1708905d6..d1ea90e5d0d1c247e11283815a49a8d9a65190a5 100644 (file)
@@ -50,3 +50,15 @@ endef
 
 # collect all enabled USE_foo's foo_{C,LD}FLAGS into OPTIONS_{C,LD}FLAGS
 collect_opts_flags = $(foreach opt,$(enabled_opts),$(eval $(call collect_opt_flags,$(opt))))
+
+# Check that any USE_* variable that was forced actually exist. For this we'll
+# build a list of the MAKEOVERRIDES variables that start with USE_*, and keep
+# the ones that do not match any of the patterns built by appending '=%' to all
+# use_opts. The outstanding ones are thus unknown and each of them produces a
+# warning.
+warn_unknown_options =                                                       \
+    $(foreach unknown,                                                       \
+              $(filter-out $(foreach opt,$(use_opts),$(opt:==%)),            \
+                           $(foreach opt,$(MAKEOVERRIDES),                   \
+                                     $(strip $(filter USE_%,$(opt))))),      \
+              $(warning Warning: ignoring unknown build option: $(unknown)))