man: Document purpose of origin files and how they tie to packages
[dpkg.git] / scripts / mk / buildflags.mk
blob8f25e2df77143c1135b034f5fdcf2ff143383868
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 # Note:
32 # - Only documented variables are considered public interfaces.
33 # - Expects to be included from the source tree root directory.
35 ifndef dpkg_buildflags_mk_included
36 dpkg_buildflags_mk_included = yes
38 # This list is kept in sync with the default set of flags returned
39 # by dpkg-buildflags.
41 dpkg_lazy_eval ?= $$(or $$(value DPKG_CACHE_$(1)),$$(eval DPKG_CACHE_$(1) := $$(shell $(2)))$$(value DPKG_CACHE_$(1)))
43 DPKG_BUILDFLAGS_LIST := $(foreach var,\
44 ASFLAGS \
45 CFLAGS \
46 CPPFLAGS \
47 CXXFLAGS \
48 OBJCFLAGS \
49 OBJCXXFLAGS \
50 DFLAGS \
51 FFLAGS \
52 FCFLAGS \
53 LDFLAGS \
54 ,$(var) $(var)_FOR_BUILD)
56 define dpkg_buildflags_export_envvar
57 ifdef $(1)
58 DPKG_BUILDFLAGS_EXPORT_ENVVAR += $(1)="$$(value $(1))"
59 endif
60 endef
62 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_OPTIONS))
63 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_MAINT_OPTIONS))
64 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_PATH))
65 $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
66 $(foreach operation,SET STRIP APPEND PREPEND,\
67 $(eval $(call dpkg_buildflags_export_envvar,DEB_$(flag)_MAINT_$(operation)))))
69 dpkg_buildflags_setvar = $(1) = $(call dpkg_lazy_eval,$(1),$(DPKG_BUILDFLAGS_EXPORT_ENVVAR) dpkg-buildflags --get $(1))
71 $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
72 $(eval $(call dpkg_buildflags_setvar,$(flag))))
74 ifdef DPKG_EXPORT_BUILDFLAGS
75 export $(DPKG_BUILDFLAGS_LIST)
76 endif
78 endif # dpkg_buildflags_mk_included