]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: add a function to collect all options' CFLAGS/LDFLAGS
authorWilly Tarreau <w@1wt.eu>
Thu, 22 Dec 2022 18:44:35 +0000 (19:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Dec 2022 15:53:35 +0000 (16:53 +0100)
The new function collect_opts_flags now scans all USE_* options defined
in use_opts and appends the corresponding *_CFLAGS and *_LDFLAGS to
OPTIONS_{C,LD}FLAGS respectively. This will be useful to get rid of all
the individual concatenations to these variables.

include/make/options.mk

index f439be345a91c34a70d3a2cb3b97707e72389ca1..9e96f875cea68587046a66124ad1ea0e33e43a5f 100644 (file)
@@ -37,3 +37,16 @@ reset_opt_vars = $(foreach name,INC LIB CFLAGS LDFLAGS SRC,$(eval $(1)_$(name)=)
 
 # preset all variables for all supported build options among use_opts
 reset_opts_vars = $(foreach opt,$(patsubst USE_%,%,$(use_opts)) SSL WOLFSSL,$(call reset_opt_vars,$(opt)))
+
+# append $(1)_{C,LD}FLAGS into OPTIONS_{C,LD}FLAGS if not empty
+define collect_opt_flags =
+  ifneq ($$($(1)_CFLAGS),)
+    OPTIONS_CFLAGS += $$($(1)_CFLAGS)
+  endif
+  ifneq ($$($(1)_LDFLAGS),)
+    OPTIONS_LDFLAGS += $$($(1)_LDFLAGS)
+  endif
+endef
+
+# collect all known USE_foo's foo_{C,LD}FLAGS into OPTIONS_{C,LD}FLAGS
+collect_opts_flags = $(foreach opt,$(patsubst USE_%,%,$(use_opts)) SSL,$(eval $(call collect_opt_flags,$(opt))))