From 8fa2f49f244c37960f0ebd5fb0b9518e4dd91f0a Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 22 Dec 2022 19:44:35 +0100 Subject: [PATCH] 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. --- include/make/options.mk | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/make/options.mk b/include/make/options.mk index f439be345..9e96f875c 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))))