build: Add support for compiler analyzer flags
[dpkg.git] / scripts / mk / buildtools.mk
blobdc28017bb2e9a3fdae6465feedb8167ef7116caf
1 # This Makefile fragment (since dpkg 1.19.0) defines the following variables
2 # for host tools:
4 # AS: assembler (since dpkg 1.19.1).
5 # CPP: C preprocessor.
6 # CC: C compiler.
7 # CXX: C++ compiler.
8 # OBJC: Objective C compiler.
9 # OBJCXX: Objective C++ compiler.
10 # GCJ: GNU Java compiler.
11 # F77: Fortran 77 compiler.
12 # FC: Fortran 9x compiler.
13 # LD: linker.
14 # STRIP: strip objects (since dpkg 1.19.1).
15 # OBJCOPY: copy objects (since dpkg 1.19.1).
16 # OBJDUMP: dump objects (since dpkg 1.19.1).
17 # NM: names lister (since dpkg 1.19.1).
18 # AR: archiver (since dpkg 1.19.1).
19 # RANLIB: archive index generator (since dpkg 1.19.1).
20 # PKG_CONFIG: pkg-config tool.
21 # QMAKE: Qt build system generator (since dpkg 1.20.0).
23 # All the above variables have a counterpart variable for the build tool,
24 # as in CC → CC_FOR_BUILD.
26 # The variables are not exported by default. This can be changed by
27 # defining DPKG_EXPORT_BUILDTOOLS.
29 dpkg_datadir = $(srcdir)/mk
30 include $(dpkg_datadir)/architecture.mk
32 # We set the TOOL_FOR_BUILD variables to the specified value, and the TOOL
33 # variables (for the host) to their triplet-prefixed form iff they are
34 # not defined or contain the make built-in defaults. On native builds if
35 # TOOL is defined and TOOL_FOR_BUILD is not, we fallback to use TOOL.
36 define dpkg_buildtool_setvar
37 ifeq (,$(findstring $(3),$(DEB_BUILD_OPTIONS)))
38 ifeq ($(origin $(1)),default)
39 $(1) = $(DEB_HOST_GNU_TYPE)-$(2)
40 else
41 $(1) ?= $(DEB_HOST_GNU_TYPE)-$(2)
42 endif
44 # On native build fallback to use TOOL if that's defined.
45 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
46 $(1)_FOR_BUILD ?= $$($(1))
47 else
48 $(1)_FOR_BUILD ?= $(DEB_BUILD_GNU_TYPE)-$(2)
49 endif
50 else
51 $(1) = :
52 $(1)_FOR_BUILD = :
53 endif
55 ifdef DPKG_EXPORT_BUILDTOOLS
56 export $(1)
57 export $(1)_FOR_BUILD
58 endif
59 endef
61 $(eval $(call dpkg_buildtool_setvar,AS,as))
62 $(eval $(call dpkg_buildtool_setvar,CPP,gcc -E))
63 $(eval $(call dpkg_buildtool_setvar,CC,gcc))
64 $(eval $(call dpkg_buildtool_setvar,CXX,g++))
65 $(eval $(call dpkg_buildtool_setvar,OBJC,gcc))
66 $(eval $(call dpkg_buildtool_setvar,OBJCXX,g++))
67 $(eval $(call dpkg_buildtool_setvar,GCJ,gcj))
68 $(eval $(call dpkg_buildtool_setvar,F77,gfortran))
69 $(eval $(call dpkg_buildtool_setvar,FC,gfortran))
70 $(eval $(call dpkg_buildtool_setvar,LD,ld))
71 $(eval $(call dpkg_buildtool_setvar,STRIP,strip,nostrip))
72 $(eval $(call dpkg_buildtool_setvar,OBJCOPY,objcopy))
73 $(eval $(call dpkg_buildtool_setvar,OBJDUMP,objdump))
74 $(eval $(call dpkg_buildtool_setvar,NM,nm))
75 $(eval $(call dpkg_buildtool_setvar,AR,ar))
76 $(eval $(call dpkg_buildtool_setvar,RANLIB,ranlib))
77 $(eval $(call dpkg_buildtool_setvar,PKG_CONFIG,pkg-config))
78 $(eval $(call dpkg_buildtool_setvar,QMAKE,qmake))