1dpkg-architecture(1) dpkg utilities dpkg-architecture(1)
2
3
4
6 dpkg-architecture - set and determine the architecture for package
7 building
8
10 dpkg-architecture [options] [commands]
11
13 dpkg-architecture does provide a facility to determine and set the
14 build and host architecture for package building.
15
16 The build architecture is always determined by an external call to
17 dpkg(1), and can not be set at the command line.
18
19 You can specify the host architecture by providing one or both of the
20 options -a and -t. The default is determined by an external call to
21 gcc(1), or the same as the build architecture if CC or gcc are both not
22 available. One out of -a and -t is sufficient, the value of the other
23 will be set to a usable default. Indeed, it is often better to only
24 specify one, because dpkg-architecture will warn you if your choice
25 does not match the default.
26
28 -l Print the environment variables, one each line, in the format
29 VARIABLE=value. This is the default action.
30
31 -edebian-architecture
32 Check for equality of architecture. By default debian-architec‐
33 ture is compared against the current Debian architecture, being
34 the host. This action will not expand the architecture wild‐
35 cards. Command finishes with an exit status of 0 if matched, 1
36 if not matched.
37
38 -iarchitecture-wildcard
39 Check for identity of architecture by expanding architecture-
40 wildcard as an architecture wildcard and comparing against the
41 current Debian architecture. Command finishes with an exit sta‐
42 tus of 0 if matched, 1 if not matched.
43
44 -qvariable-name
45 Print the value of a single variable.
46
47 -s Print an export command. This can be used to set the environment
48 variables using eval.
49
50 -u Print a similar command to -s but to unset all variables.
51
52 -c command
53 Execute a command in an environment which has all variables set
54 to the determined value.
55
56 -L Print a list of valid architecture names.
57
58 --help Show the usage message and exit.
59
60 --version
61 Show the version and exit.
62
64 -adebian-architecture
65 Set the Debian architecture.
66
67 -tgnu-system-type
68 Set the GNU system type.
69
70 -f Values set by existing environment variables with the same name
71 as used by the scripts are honored (i.e. used by dpkg-architec‐
72 ture), except if this force flag is present. This allows the
73 user to override a value even when the call to dpkg-architecture
74 is buried in some other script (for example dpkg-buildpack‐
75 age(1)).
76
78 build machine
79 The machine the package is built on.
80
81 host machine
82 The machine the package is built for.
83
84 Debian architecture
85 The Debian architecture string, which specifies the binary tree in
86 the FTP archive. Examples: i386, sparc, hurd-i386.
87
88 architecture wildcard
89 An architecture wildcard is a special architecture string that will
90 match any real architecture being part of it. The general form is
91 <kernel>-<cpu>. Examples: linux-any, any-i386, hurd-any.
92
93 GNU system type
94 An architecture specification string consisting of two parts sepa‐
95 rated by a dash: cpu and system. Examples: i386-linux-gnu,
96 sparc-linux-gnu, i386-gnu, x86_64-netbsd.
97
99 The following variables are set by dpkg-architecture:
100
101 DEB_BUILD_ARCH
102 The Debian architecture of the build machine.
103
104 DEB_BUILD_ARCH_OS
105 The Debian system name of the build machine.
106
107 DEB_BUILD_ARCH_CPU
108 The Debian cpu name of the build machine.
109
110 DEB_BUILD_ARCH_BITS
111 The pointer size of the build machine (in bits).
112
113 DEB_BUILD_ARCH_ENDIAN
114 The endianness of the build machine (little / big).
115
116 DEB_BUILD_GNU_TYPE
117 The GNU system type of the build machine.
118
119 DEB_BUILD_GNU_CPU
120 The CPU part of DEB_BUILD_GNU_TYPE
121
122 DEB_BUILD_GNU_SYSTEM
123 The System part of DEB_BUILD_GNU_TYPE.
124
125 DEB_HOST_ARCH
126 The Debian architecture of the host machine.
127
128 DEB_HOST_ARCH_OS
129 The Debian system name of the host machine.
130
131 DEB_HOST_ARCH_CPU
132 The Debian cpu name of the host machine.
133
134 DEB_BUILD_ARCH_BITS
135 The pointer size of the host machine (in bits).
136
137 DEB_BUILD_ARCH_ENDIAN
138 The endianness of the host machine (little / big).
139
140 DEB_HOST_GNU_TYPE
141 The GNU system type of the host machine.
142
143 DEB_HOST_GNU_CPU
144 The CPU part of DEB_HOST_GNU_TYPE.
145
146 DEB_HOST_GNU_SYSTEM
147 The System part of DEB_HOST_GNU_TYPE.
148
150 The environment variables set by dpkg-architecture are passed to
151 debian/rules as make variables (see make documentation). However, you
152 should not rely on them, as this breaks manual invocation of the
153 script. Instead, you should always initialize them using dpkg-architec‐
154 ture with the -q option. Here are some examples, which also show how
155 you can improve the cross compilation support in your package:
156
157 Instead of:
158
159 ARCH=`dpkg --print-architecture`
160 configure $(ARCH)-linux
161
162 please use the following:
163
164 DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
165 DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
166
167 configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
168
169 Instead of:
170
171 ARCH=`dpkg --print-architecture`
172 ifeq ($(ARCH),alpha)
173 ...
174 endif
175
176 please use:
177
178 DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
179
180 ifeq ($(DEB_HOST_ARCH),alpha)
181 ...
182 endif
183
184 or if you only need to check the CPU or OS type, use the
185 DEB_HOST_ARCH_CPU or DEB_HOST_ARCH_OS variables.
186
187 In general, calling dpkg in the rules file to get architecture informa‐
188 tion is deprecated (unless you want to provide backward compatibility,
189 see below). Especially the --print-architecture option is unreliable
190 since we have Debian architectures which don't equal a processor name.
191
193 The DEB_*_ARCH_BITS and DEB_*_ARCH_ENDIAN variables were introduced in
194 dpkg-dev 1.15.4. Using them in debian/rules thus requires a build-
195 dependency on dpkg-dev (>= 1.15.4).
196
197 The DEB_HOST_ARCH_CPU and DEB_HOST_ARCH_OS variables were introduced in
198 dpkg-dev 1.13.2. Before this debian/rules files tended to check the
199 values of the DEB_HOST_GNU_CPU or DEB_HOST_GNU_TYPE variables which
200 have been subject to change.
201
202 Where debian/rules files check these variables to decide how or what to
203 compile, this should be updated to use the new variables and values.
204 You may wish to retain backwards compatibility with older version of
205 dpkg-dev by using the following code:
206
207 DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null)
208 DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
209
210 # Take account of old dpkg-architecture output.
211 ifeq ($(DEB_HOST_ARCH_CPU),)
212 DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
213 ifeq ($(DEB_HOST_ARCH_CPU),x86_64)
214 DEB_HOST_ARCH_CPU := amd64
215 endif
216 endif
217 ifeq ($(DEB_HOST_ARCH_OS),)
218 DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM))
219 ifeq ($(DEB_HOST_ARCH_OS),gnu)
220 DEB_HOST_ARCH_OS := hurd
221 endif
222 endif
223
224 And similarly for DEB_BUILD_ARCH_CPU and DEB_BUILD_ARCH_OS.
225
226 If you still wish to support versions of dpkg-dev that did not include
227 dpkg-architecture, the following does the job:
228
229 DEB_BUILD_ARCH := $(shell dpkg --print-architecture)
230 DEB_BUILD_GNU_CPU := $(patsubst hurd-%,%,$(DEB_BUILD_ARCH))
231 ifeq ($(filter-out hurd-%,$(DEB_BUILD_ARCH)),)
232 DEB_BUILD_GNU_SYSTEM := gnu
233 else
234 DEB_BUILD_GNU_SYSTEM := linux-gnu
235 endif
236 DEB_BUILD_GNU_TYPE=$(DEB_BUILD_GNU_CPU)-$(DEB_BUILD_GNU_SYSTEM)
237
238 DEB_HOST_ARCH := $(DEB_BUILD_ARCH)
239 DEB_HOST_GNU_CPU := $(DEB_BUILD_GNU_CPU)
240 DEB_HOST_GNU_SYSTEM := $(DEB_BUILD_GNU_SYSTEM)
241 DEB_HOST_GNU_TYPE := $(DEB_BUILD_GNU_TYPE)
242
243 Put a subset of these lines at the top of your debian/rules file; these
244 default values will be overwritten if dpkg-architecture is used.
245
246 You don't need the full set. Choose a consistent set which contains the
247 values you use in the rules file. For example, if you only need the
248 host Debian architecture, `DEB_HOST_ARCH=`dpkg --print-architecture`'
249 is sufficient (this is indeed the Debian architecture of the build
250 machine, but remember that we are only trying to be backward compatible
251 with native compilation).
252
253 The -e and -i options were only introduced in relatively recent ver‐
254 sions of dpkg-architecture (since dpkg 1.13.13).
255
257 dpkg-buildpackage accepts the -a option and passes it to dpkg-architec‐
258 ture. Other examples:
259
260 CC=i386-gnu-gcc dpkg-architecture -c debian/rules build
261
262 eval `dpkg-architecture -u`
263
264 Check if an architecture is equal to the current architecture or a
265 given one:
266
267 dpkg-architecture -elinux-alpha
268
269 dpkg-architecture -amips -elinux-mips
270
271 Check if the current architecture or an architecture provided with -a
272 are Linux systems:
273
274 dpkg-architecture -ilinux-any
275
276 dpkg-architecture -ai386 -ilinux-any
277
279 All these files have to be present for dpkg-architecture to work. Their
280 location can be overriden at runtime with the environment variable
281 DPKG_DATADIR.
282
283 /usr/share/dpkg/cputable
284 Table of known CPU names and mapping to their GNU name.
285
286 /usr/share/dpkg/ostable
287 Table of known operating system names and mapping to their GNU
288 name.
289
290 /usr/share/dpkg/triplettable
291 Mapping between Debian architecture triplets and Debian archi‐
292 tecture names.
293
295 dpkg-buildpackage(1), dpkg-cross(1).
296
298 dpkg-architecture and this man page were initially written by Marcus
299 Brinkmann <brinkmd@debian.org>.
300
301
302
303
304Debian Project 2009-08-15 dpkg-architecture(1)