blob: db4502c4b949c1636e7a765ce6e28afd540ab92c [file] [log] [blame]
Willy Tarreau69e7b7f2022-12-22 19:32:24 +01001# this contains various functions and macros used to manipulate USE_* options
2# and their flags
3
4# Depending on the target platform, some options are set, as well as some
5# CFLAGS and LDFLAGS. All variables pre-set here will not appear in the build
6# options string. They may be set to any value, but are historically set to
7# "implicit" which eases debugging. You should not have to change anything
8# there unless you're adding support for a new platform.
9default_opts = $(foreach name,$(1),$(eval $(name)=implicit))
10
11# Return USE_xxx=$(USE_xxx) if the variable was set from the environment or the
12# command line.
13ignore_implicit = $(if $(subst environment,,$(origin $(1))), \
14 $(if $(subst command line,,$(origin $(1))),, \
15 $(1)=$($(1))), \
16 $(1)=$($(1))) \
17
18# This macro collects all USE_* values except those set to "implicit". This
19# is used to report a list of all flags which were used to build this version.
20# Do not assign anything to it.
21build_options = $(foreach opt,$(use_opts),$(call ignore_implicit,$(opt)))
22
23# Make a list of all known features with +/- prepended depending on their
24# activation status. Must be a macro so that dynamically enabled ones are
25# evaluated with their current status.
Willy Tarreau848362f2022-12-22 19:51:30 +010026build_features = $(foreach opt,$(patsubst USE_%,%,$(sort $(use_opts))),$(if $(USE_$(opt)),+$(opt),-$(opt)))
Willy Tarreau69e7b7f2022-12-22 19:32:24 +010027
28# This returns a list of -DUSE_* for all known USE_* that are set
29opts_as_defines = $(foreach opt,$(use_opts),$(if $($(opt)),-D$(opt),))
30
31# Lists all enabled or disabled options without the "USE_" prefix
32enabled_opts = $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt)),$(opt),))
33disabled_opts = $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt)),,$(opt)))