Dpkg::Vendor: Make the add_build_flags() a non-private method
[dpkg.git] / scripts / mk / buildflags.mk
blob4b8a3d8c4a99fd61d4a0b22c45b4a92c1fe7d90e
1 # This Makefile fragment (since dpkg 1.16.1) defines the following host
2 # variables:
4 # ASFLAGS: flags for the host assembler (since 1.21.0).
5 # CFLAGS: flags for the host C compiler.
6 # CPPFLAGS: flags for the host C preprocessor.
7 # CXXFLAGS: flags for the host C++ compiler.
8 # OBJCFLAGS: flags for the host Objective C compiler.
9 # OBJCXXFLAGS: flags for the host Objective C++ compiler.
10 # DFLAGS: flags for the host D compiler.
11 # FFLAGS: flags for the host Fortran 77 compiler.
12 # FCFLAGS: flags for the host Fortran 9x compiler.
13 # LDFLAGS: flags for the host linker.
15 # And the following variables for the build tools (since dpkg 1.22.1):
17 # ASFLAGS_FOR_BUILD: flags for the build assembler.
18 # CFLAGS_FOR_BUILD: flags for the build C compiler.
19 # CPPFLAGS_FOR_BUILD: flags for the build C preprocessor.
20 # CXXFLAGS_FOR_BUILD: flags for the build C++ compiler.
21 # OBJCFLAGS_FOR_BUILD: flags for the build Objective C compiler.
22 # OBJCXXFLAGS_FOR_BUILD: flags for the build Objective C++ compiler.
23 # DFLAGS_FOR_BUILD: flags for the build D compiler.
24 # FFLAGS_FOR_BUILD: flags for the build Fortran 77 compiler.
25 # FCFLAGS_FOR_BUILD: flags for the build Fortran 9x compiler.
26 # LDFLAGS_FOR_BUILD: flags for the build linker.
28 # You can also export them in the environment by setting
29 # DPKG_EXPORT_BUILDFLAGS to a non-empty value.
31 # This list is kept in sync with the default set of flags returned
32 # by dpkg-buildflags.
34 dpkg_lazy_eval ?= $$(or $$(value DPKG_CACHE_$(1)),$$(eval DPKG_CACHE_$(1) := $$(shell $(2)))$$(value DPKG_CACHE_$(1)))
36 DPKG_BUILDFLAGS_LIST = \
37 ASFLAGS \
38 ASFLAGS_FOR_BUILD \
39 CFLAGS \
40 CFLAGS_FOR_BUILD \
41 CPPFLAGS \
42 CPPFLAGS_FOR_BUILD \
43 CXXFLAGS \
44 CXXFLAGS_FOR_BUILD \
45 OBJCFLAGS \
46 OBJCFLAGS_FOR_BUILD \
47 OBJCXXFLAGS \
48 OBJCXXFLAGS_FOR_BUILD \
49 DFLAGS \
50 DFLAGS_FOR_BUILD \
51 FFLAGS \
52 FFLAGS_FOR_BUILD \
53 FCFLAGS \
54 FCFLAGS_FOR_BUILD \
55 LDFLAGS \
56 LDFLAGS_FOR_BUILD \
57 # EOL
59 define dpkg_buildflags_export_envvar
60 ifdef $(1)
61 DPKG_BUILDFLAGS_EXPORT_ENVVAR += $(1)="$$(value $(1))"
62 endif
63 endef
65 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_OPTIONS))
66 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_MAINT_OPTIONS))
67 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_PATH))
68 $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
69 $(foreach operation,SET STRIP APPEND PREPEND,\
70 $(eval $(call dpkg_buildflags_export_envvar,DEB_$(flag)_MAINT_$(operation)))))
72 dpkg_buildflags_setvar = $(1) = $(call dpkg_lazy_eval,$(1),$(DPKG_BUILDFLAGS_EXPORT_ENVVAR) dpkg-buildflags --get $(1))
74 $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
75 $(eval $(call dpkg_buildflags_setvar,$(flag))))
77 ifdef DPKG_EXPORT_BUILDFLAGS
78 export $(DPKG_BUILDFLAGS_LIST)
79 endif