man: Add dpkg-build-api behavior for Rules-Requires-Root field defaults
[dpkg.git] / scripts / mk / buildtools.mk
blob933fdcfaa4be3f77d5394572a7b7554f5ed566de
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 # F77: Fortran 77 compiler.
11 # FC: Fortran 9x compiler.
12 # LD: linker.
13 # STRIP: strip objects (since dpkg 1.19.1).
14 # OBJCOPY: copy objects (since dpkg 1.19.1).
15 # OBJDUMP: dump objects (since dpkg 1.19.1).
16 # NM: names lister (since dpkg 1.19.1).
17 # AR: archiver (since dpkg 1.19.1).
18 # RANLIB: archive index generator (since dpkg 1.19.1).
19 # PKG_CONFIG: pkg-config tool.
20 # QMAKE: Qt build system generator (since dpkg 1.20.0).
22 # All the above variables have a counterpart variable for the build tool,
23 # as in CC → CC_FOR_BUILD.
25 # The variables are not exported by default. This can be changed by
26 # defining DPKG_EXPORT_BUILDTOOLS.
28 dpkg_datadir = $(srcdir)/mk
29 include $(dpkg_datadir)/architecture.mk
31 # We set the TOOL_FOR_BUILD variables to the specified value, and the TOOL
32 # variables (for the host) to their triplet-prefixed form iff they are
33 # not defined or contain the make built-in defaults. On native builds if
34 # TOOL is defined and TOOL_FOR_BUILD is not, we fallback to use TOOL.
35 define dpkg_buildtool_setvar
36 ifeq (,$(findstring $(3),$(DEB_BUILD_OPTIONS)))
37 ifeq ($(origin $(1)),default)
38 $(1) = $(DEB_HOST_GNU_TYPE)-$(2)
39 else
40 $(1) ?= $(DEB_HOST_GNU_TYPE)-$(2)
41 endif
43 # On native build fallback to use TOOL if that's defined.
44 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
45 $(1)_FOR_BUILD ?= $$($(1))
46 else
47 $(1)_FOR_BUILD ?= $(DEB_BUILD_GNU_TYPE)-$(2)
48 endif
49 else
50 $(1) = :
51 $(1)_FOR_BUILD = :
52 endif
54 ifdef DPKG_EXPORT_BUILDTOOLS
55 export $(1)
56 export $(1)_FOR_BUILD
57 endif
58 endef
60 $(eval $(call dpkg_buildtool_setvar,AS,as))
61 $(eval $(call dpkg_buildtool_setvar,CPP,gcc -E))
62 $(eval $(call dpkg_buildtool_setvar,CC,gcc))
63 $(eval $(call dpkg_buildtool_setvar,CXX,g++))
64 $(eval $(call dpkg_buildtool_setvar,OBJC,gcc))
65 $(eval $(call dpkg_buildtool_setvar,OBJCXX,g++))
66 $(eval $(call dpkg_buildtool_setvar,F77,gfortran))
67 $(eval $(call dpkg_buildtool_setvar,FC,gfortran))
68 $(eval $(call dpkg_buildtool_setvar,LD,ld))
69 $(eval $(call dpkg_buildtool_setvar,STRIP,strip,nostrip))
70 $(eval $(call dpkg_buildtool_setvar,OBJCOPY,objcopy))
71 $(eval $(call dpkg_buildtool_setvar,OBJDUMP,objdump))
72 $(eval $(call dpkg_buildtool_setvar,NM,nm))
73 $(eval $(call dpkg_buildtool_setvar,AR,ar))
74 $(eval $(call dpkg_buildtool_setvar,RANLIB,ranlib))
75 $(eval $(call dpkg_buildtool_setvar,PKG_CONFIG,pkgconf))
76 $(eval $(call dpkg_buildtool_setvar,QMAKE,qmake))