From: Willy Tarreau Date: Thu, 22 Dec 2022 18:44:35 +0000 (+0100) Subject: BUILD: makefile: add a function to collect all options' CFLAGS/LDFLAGS X-Git-Tag: v2.8-dev1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fa2f49f244c37960f0ebd5fb0b9518e4dd91f0a;p=thirdparty%2Fhaproxy.git BUILD: makefile: add a function to collect all options' CFLAGS/LDFLAGS 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. --- diff --git a/include/make/options.mk b/include/make/options.mk index f439be345a..9e96f875ce 100644 --- a/include/make/options.mk +++ b/include/make/options.mk @@ -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))))