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.
This commit is contained in:
Willy Tarreau 2022-12-22 19:44:35 +01:00
parent b14e89e322
commit 8fa2f49f24

View 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))))