1 # This Makefile snippet defines the following variables:
2 #
3 # CFLAGS: flags for the C compiler
4 # CPPFLAGS: flags for the C preprocessor
5 # CXXFLAGS: flags for the C++ compiler
6 # FFLAGS: flags for the Fortran compiler
7 # LDFLAGS: flags for the linker
8 #
9 # You can also export them in the environment by setting
10 # DPKG_EXPORT_BUILDFLAGS to a non-empty value.
11 #
12 # This list is kept in sync with the default set of flags returned
13 # by dpkg-buildflags.
15 dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
17 DPKG_BUILDFLAGS_LIST = CFLAGS CPPFLAGS CXXFLAGS FFLAGS LDFLAGS
19 define dpkg_buildflags_export_envvar
20 ifdef $(1)
21 DPKG_BUILDFLAGS_EXPORT_ENVVAR += $(1)="$(value $(1))"
22 endif
23 endef
25 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_MAINT_OPTIONS))
26 $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
27 $(foreach operation,SET STRIP APPEND PREPEND,\
28 $(eval $(call dpkg_buildflags_export_envvar,DEB_$(flag)_MAINT_$(operation)))))
30 dpkg_buildflags_setvar = $(1) = $(call dpkg_late_eval,$(1),$(DPKG_BUILDFLAGS_EXPORT_ENVVAR) dpkg-buildflags --get $(1))
32 $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
33 $(eval $(call dpkg_buildflags_setvar,$(flag))))
35 ifdef DPKG_EXPORT_BUILDFLAGS
36 export $(DPKG_BUILDFLAGS_LIST)
37 endif
