1dpkg-architecture(1) dpkg suite dpkg-architecture(1)
2
3
4
6 dpkg-architecture - set and determine the architecture for package
7 building
8
10 dpkg-architecture [option...] [command]
11
13 dpkg-architecture provides a facility to determine and set the build
14 and host architecture for package building.
15
16 The build architecture is always determined by an external call to
17 dpkg(1), and cannot be set at the command line.
18
19 You can specify the host architecture by providing one or both of the
20 options --host-arch and --host-type. The default is determined by an
21 external call to gcc(1), or the same as the build architecture if CC or
22 gcc are both not available. One out of --host-arch and --host-type is
23 sufficient, the value of the other will be set to a usable default.
24 Indeed, it is often better to only specify one, because
25 dpkg-architecture will warn you if your choice does not match the
26 default.
27
29 -l, --list
30 Print the environment variables, one each line, in the format
31 VARIABLE=value. This is the default action.
32
33 -e, --equal architecture
34 Check for equality of architecture (since dpkg 1.13.13). It
35 compares the current or specified Debian host architecture
36 against architecture, to check if they are equal. This action
37 will not expand the architecture wildcards. Command finishes
38 with an exit status of 0 if matched, 1 if not matched.
39
40
41 -i, --is architecture-wildcard
42 Check for identity of architecture (since dpkg 1.13.13). It
43 compares the current or specified Debian host architecture
44 against architecture-wildcard after having expanded it as an
45 architecture wildcard, to check if they match. Command finishes
46 with an exit status of 0 if matched, 1 if not matched.
47
48 -q, --query variable-name
49 Print the value of a single variable.
50
51 -s, --print-set
52 Print an export command. This can be used to set the environment
53 variables using eval.
54
55 -u, --print-unset
56 Print a similar command to --print-unset but to unset all
57 variables.
58
59 -c, --command command
60 Execute a command in an environment which has all variables set
61 to the determined value.
62
63 -L, --list-known
64 Print a list of valid architecture names. Possibly restricted
65 by one or more of the matching options --match-wildcard,
66 --match-bits or --match-endian (since dpkg 1.17.14).
67
68 -?, --help
69 Show the usage message and exit.
70
71 --version
72 Show the version and exit.
73
75 -a, --host-arch architecture
76 Set the host Debian architecture.
77
78 -t, --host-type gnu-system-type
79 Set the host GNU system type.
80
81 -A, --target-arch architecture
82 Set the target Debian architecture (since dpkg 1.17.14).
83
84 -T, --target-type gnu-system-type
85 Set the target GNU system type (since dpkg 1.17.14).
86
87 -W, --match-wildcard architecture-wildcard
88 Restrict the architectures listed by --list-known to ones
89 matching the specified architecture wildcard (since dpkg
90 1.17.14).
91
92 -B, --match-bits architecture-bits
93 Restrict the architectures listed by --list-known to ones with
94 the specified CPU bits (since dpkg 1.17.14). Either 32 or 64.
95
96 -E, --match-endian architecture-endianness
97 Restrict the architectures listed by --list-known to ones with
98 the specified endianness (since dpkg 1.17.14). Either little or
99 big.
100
101 -f, --force
102 Values set by existing environment variables with the same name
103 as used by the scripts are honored (i.e. used by
104 dpkg-architecture), except if this force flag is present. This
105 allows the user to override a value even when the call to
106 dpkg-architecture is buried in some other script (for example
107 dpkg-buildpackage(1)).
108
110 build machine
111 The machine the package is built on.
112
113 host machine
114 The machine the package is built for.
115
116 target machine
117 The machine the compiler is building for. This is only needed when
118 building a cross-toolchain, one that will be built on the build
119 architecture, to be run on the host architecture, and to build code
120 for the target architecture.
121
122 Debian architecture
123 The Debian architecture string, which specifies the binary tree in
124 the FTP archive. Examples: i386, sparc, hurd-i386.
125
126 Debian architecture tuple
127 A Debian architecture tuple is the fully qualified architecture
128 with all its components spelled out. This differs with Debian
129 architectures in that at least the cpu component does not embed the
130 abi. The current tuple has the form abi-libc-os-cpu. Examples:
131 base-gnu-linux-amd64, eabihf-musl-linux-arm.
132
133 Debian architecture wildcard
134 A Debian architecture wildcard is a special architecture string
135 that will match any real architecture being part of it. The
136 general form is a Debian architecture tuple with four or less
137 elements, and with at least one of them being any. Missing
138 elements of the tuple are prefixed implicitly as any, and thus the
139 following pairs are equivalent:
140 any-any-any-any = any
141 any-any-os-any = os-any
142 any-libc-any-any = libc-any-any
143 Examples: linux-any, any-i386, hurd-any, eabi-any-any-arm,
144 musl-any-any.
145
146 GNU system type
147 An architecture specification string consisting of two parts
148 separated by a hyphen: cpu and system. Examples: i586-linux-gnu,
149 sparc-linux-gnu, i686-gnu, x86_64-netbsd.
150
151 multiarch triplet
152 The clarified GNU system type, used for filesystem paths. This
153 triplet does not change even when the baseline ISA gets bumped, so
154 that the resulting paths are stable over time. The only current
155 difference with the GNU system type is that the CPU part for i386
156 based systems is always i386. Examples: i386-linux-gnu,
157 x86_64-linux-gnu. Example paths: /lib/powerpc64le-linux-gnu/,
158 /usr/lib/i386-kfreebsd-gnu/.
159
161 The following variables are set by dpkg-architecture:
162
163 DEB_BUILD_ARCH
164 The Debian architecture of the build machine.
165
166 DEB_BUILD_ARCH_ABI
167 The Debian abi name of the build machine (since dpkg 1.18.11).
168
169 DEB_BUILD_ARCH_LIBC
170 The Debian libc name of the build machine (since dpkg 1.18.11).
171
172 DEB_BUILD_ARCH_OS
173 The Debian system name of the build machine (since dpkg 1.13.2).
174
175 DEB_BUILD_ARCH_CPU
176 The Debian cpu name of the build machine (since dpkg 1.13.2).
177
178 DEB_BUILD_ARCH_BITS
179 The pointer size of the build machine (in bits; since dpkg 1.15.4).
180
181 DEB_BUILD_ARCH_ENDIAN
182 The endianness of the build machine (little / big; since dpkg
183 1.15.4).
184
185 DEB_BUILD_GNU_CPU
186 The CPU part of DEB_BUILD_GNU_TYPE.
187
188 DEB_BUILD_GNU_SYSTEM
189 The System part of DEB_BUILD_GNU_TYPE.
190
191 DEB_BUILD_GNU_TYPE
192 The GNU system type of the build machine.
193
194 DEB_BUILD_MULTIARCH
195 The clarified GNU system type of the build machine, used for
196 filesystem paths (since dpkg 1.16.0).
197
198 DEB_HOST_ARCH
199 The Debian architecture of the host machine.
200
201 DEB_HOST_ARCH_ABI
202 The Debian abi name of the host machine (since dpkg 1.18.11).
203
204 DEB_HOST_ARCH_LIBC
205 The Debian libc name of the host machine (since dpkg 1.18.11).
206
207 DEB_HOST_ARCH_OS
208 The Debian system name of the host machine (since dpkg 1.13.2).
209
210 DEB_HOST_ARCH_CPU
211 The Debian cpu name of the host machine (since dpkg 1.13.2).
212
213 DEB_HOST_ARCH_BITS
214 The pointer size of the host machine (in bits; since dpkg 1.15.4).
215
216 DEB_HOST_ARCH_ENDIAN
217 The endianness of the host machine (little / big; since dpkg
218 1.15.4).
219
220 DEB_HOST_GNU_CPU
221 The CPU part of DEB_HOST_GNU_TYPE.
222
223 DEB_HOST_GNU_SYSTEM
224 The System part of DEB_HOST_GNU_TYPE.
225
226 DEB_HOST_GNU_TYPE
227 The GNU system type of the host machine.
228
229 DEB_HOST_MULTIARCH
230 The clarified GNU system type of the host machine, used for
231 filesystem paths (since dpkg 1.16.0).
232
233 DEB_TARGET_ARCH
234 The Debian architecture of the target machine (since dpkg 1.17.14).
235
236 DEB_TARGET_ARCH_ABI
237 The Debian abi name of the target machine (since dpkg 1.18.11).
238
239 DEB_TARGET_ARCH_LIBC
240 The Debian libc name of the target machine (since dpkg 1.18.11).
241
242 DEB_TARGET_ARCH_OS
243 The Debian system name of the target machine (since dpkg 1.17.14).
244
245 DEB_TARGET_ARCH_CPU
246 The Debian cpu name of the target machine (since dpkg 1.17.14).
247
248 DEB_TARGET_ARCH_BITS
249 The pointer size of the target machine (in bits; since dpkg
250 1.17.14).
251
252 DEB_TARGET_ARCH_ENDIAN
253 The endianness of the target machine (little / big; since dpkg
254 1.17.14).
255
256 DEB_TARGET_GNU_CPU
257 The CPU part of DEB_TARGET_GNU_TYPE (since dpkg 1.17.14).
258
259 DEB_TARGET_GNU_SYSTEM
260 The System part of DEB_TARGET_GNU_TYPE (since dpkg 1.17.14).
261
262 DEB_TARGET_GNU_TYPE
263 The GNU system type of the target machine (since dpkg 1.17.14).
264
265 DEB_TARGET_MULTIARCH
266 The clarified GNU system type of the target machine, used for
267 filesystem paths (since dpkg 1.17.14).
268
270 Architecture tables
271 All these files have to be present for dpkg-architecture to work. Their
272 location can be overridden at runtime with the environment variable
273 DPKG_DATADIR. These tables contain a format Version pseudo-field on
274 their first line to mark their format, so that parsers can check if
275 they understand it, such as "# Version=1.0".
276
277 /usr/share/dpkg/cputable
278 Table of known CPU names and mapping to their GNU name. Format
279 version 1.0 (since dpkg 1.13.2).
280
281 /usr/share/dpkg/ostable
282 Table of known operating system names and mapping to their GNU
283 name. Format version 2.0 (since dpkg 1.18.11).
284
285 /usr/share/dpkg/tupletable
286 Mapping between Debian architecture tuples and Debian
287 architecture names. Format version 1.0 (since dpkg 1.18.11).
288
289 /usr/share/dpkg/abitable
290 Table of Debian architecture ABI attribute overrides. Format
291 version 2.0 (since dpkg 1.18.11).
292
293 Packaging support
294 /usr/share/dpkg/architecture.mk
295 Makefile snippet that properly sets and exports all the
296 variables that dpkg-architecture outputs (since dpkg 1.16.1).
297
299 dpkg-buildpackage accepts the -a option and passes it to
300 dpkg-architecture. Other examples:
301
302 CC=i386-gnu-gcc dpkg-architecture -c debian/rules build
303
304 eval `dpkg-architecture -u`
305
306 Check if the current or specified host architecture is equal to an
307 architecture:
308
309 dpkg-architecture -elinux-alpha
310
311 dpkg-architecture -amips -elinux-mips
312
313 Check if the current or specified host architecture is a Linux system:
314
315 dpkg-architecture -ilinux-any
316
317 dpkg-architecture -ai386 -ilinux-any
318
319 Usage in debian/rules
320 The environment variables set by dpkg-architecture are passed to
321 debian/rules as make variables (see make documentation). However, you
322 should not rely on them, as this breaks manual invocation of the
323 script. Instead, you should always initialize them using
324 dpkg-architecture with the -q option. Here are some examples, which
325 also show how you can improve the cross compilation support in your
326 package:
327
328 Retrieving the GNU system type and forwarding it to ./configure:
329
330 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
331 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
332 [...]
333 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
334 confflags += --build=$(DEB_HOST_GNU_TYPE)
335 else
336 confflags += --build=$(DEB_BUILD_GNU_TYPE) \
337 --host=$(DEB_HOST_GNU_TYPE)
338 endif
339 [...]
340 ./configure $(confflags)
341
342 Doing something only for a specific architecture:
343
344 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
345
346 ifeq ($(DEB_HOST_ARCH),alpha)
347 [...]
348 endif
349
350 or if you only need to check the CPU or OS type, use the
351 DEB_HOST_ARCH_CPU or DEB_HOST_ARCH_OS variables.
352
353 Note that you can also rely on an external Makefile snippet to properly
354 set all the variables that dpkg-architecture can provide:
355
356 include /usr/share/dpkg/architecture.mk
357
358 ifeq ($(DEB_HOST_ARCH),alpha)
359 [...]
360 endif
361
362 In any case, you should never use dpkg --print-architecture to get
363 architecture information during a package build.
364
366 DPKG_DATADIR
367 If set, it will be used as the dpkg data directory, where the
368 architecture tables are located (since dpkg 1.14.17). Defaults
369 to «/usr/share/dpkg».
370
372 All long command and option names available only since dpkg 1.17.17.
373
375 dpkg-buildpackage(1), dpkg-cross(1).
376
377
378
3791.18.25 2018-06-26 dpkg-architecture(1)