dpkg (1.18.25) stretch; urgency=medium
[dpkg] / man / dpkg-architecture.man
CommitLineData
1479465f
GJ
1.\" dpkg manual page - dpkg-architecture(1)
2.\"
3.\" Copyright © 2005 Marcus Brinkmann <brinkmd@debian.org>
4.\" Copyright © 2005 Scott James Remnant <scott@netsplit.com>
5.\" Copyright © 2006-2015 Guillem Jover <guillem@debian.org>
6.\" Copyright © 2009-2012 Raphaël Hertzog <hertzog@debian.org>
7.\"
8.\" This is free software; you can redistribute it and/or modify
9.\" it under the terms of the GNU General Public License as published by
10.\" the Free Software Foundation; either version 2 of the License, or
11.\" (at your option) any later version.
12.\"
13.\" This is distributed in the hope that it will be useful,
14.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.\" GNU General Public License for more details.
17.\"
18.\" You should have received a copy of the GNU General Public License
19.\" along with this program. If not, see <https://www.gnu.org/licenses/>.
20.
21.TH dpkg\-architecture 1 "%RELEASE_DATE%" "%VERSION%" "dpkg suite"
22.nh
23.SH NAME
24dpkg\-architecture \- set and determine the architecture for package building
25.
26.SH SYNOPSIS
27.B dpkg\-architecture
28.RI [ option "...] [" command ]
29.PP
30.
31.SH DESCRIPTION
32.B dpkg\-architecture
33provides a facility to determine and set the build and
34host architecture for package building.
35.PP
36The build architecture is always determined by an external call to
37\fBdpkg\fP(1), and cannot be set at the command line.
38.PP
39You can specify the host architecture by providing one or both of the options
40\fB\-\-host\-arch\fR and \fB\-\-host\-type\fR. The default is determined by
41an external call to
42.BR gcc (1),
43or the same as the build architecture if \fBCC\fP or gcc are both not
44available. One out of \fB\-\-host\-arch\fR and \fB\-\-host\-type\fR is
45sufficient, the value of the
46other will be set to a usable default. Indeed, it is often better to only
47specify one, because \fBdpkg\-architecture\fP will warn you if your choice
48does not match the default.
49.
50.SH COMMANDS
51.TP
52.BR \-l ", " \-\-list
53Print the environment variables, one each line, in the format
54\fIVARIABLE=value\fP. This is the default action.
55.TP
56.BR \-e ", " \-\-equal " \fIarchitecture\fP"
57Check for equality of architecture (since dpkg 1.13.13).
58It compares the current or specified Debian host architecture against
59\fIarchitecture\fP, to check if they are equal.
60This action will not expand the architecture wildcards.
61Command finishes with an exit status of 0 if matched, 1 if not matched.
62
63.TP
64.BR \-i ", " \-\-is " \fIarchitecture-wildcard\fP"
65Check for identity of architecture (since dpkg 1.13.13).
66It compares the current or specified Debian host architecture against
67\fIarchitecture-wildcard\fP after having expanded it as an architecture
68wildcard, to check if they match.
69Command finishes with an exit status of 0 if matched, 1 if not matched.
70.TP
71.BR \-q ", " \-\-query " \fIvariable-name\fP"
72Print the value of a single variable.
73.TP
74.BR \-s ", " \-\-print\-set
75Print an export command. This can be used to set the environment variables
76using eval.
77.TP
78.BR \-u ", " \-\-print\-unset
79Print a similar command to \fB\-\-print\-unset\fP but to unset all variables.
80.TP
81.BR \-c ", " \-\-command " \fIcommand\fP"
82Execute a \fIcommand\fP in an environment which has all variables set to
83the determined value.
84.TP
85.BR \-L ", " \-\-list\-known
86Print a list of valid architecture names.
87Possibly restricted by one or more of the matching options
88\fB\-\-match\-wildcard\fP, \fB\-\-match\-bits\fP or \fB\-\-match\-endian\fP
89(since dpkg 1.17.14).
90.TP
91.BR \-? ", " \-\-help
92Show the usage message and exit.
93.TP
94.B \-\-version
95Show the version and exit.
96.
97.SH OPTIONS
98.TP
99.BR \-a ", " \-\-host\-arch " \fIarchitecture\fP"
100Set the host Debian architecture.
101.TP
102.BR \-t ", " \-\-host\-type " \fIgnu-system-type\fP"
103Set the host GNU system type.
104.TP
105.BR \-A ", " \-\-target\-arch " \fIarchitecture\fP"
106Set the target Debian architecture (since dpkg 1.17.14).
107.TP
108.BR \-T ", " \-\-target\-type " \fIgnu-system-type\fP"
109Set the target GNU system type (since dpkg 1.17.14).
110.TP
111.BR \-W ", " \-\-match\-wildcard " \fIarchitecture-wildcard\fP"
112Restrict the architectures listed by \fB\-\-list\-known\fP to ones matching
113the specified architecture wildcard (since dpkg 1.17.14).
114.TP
115.BR \-B ", " \-\-match\-bits " \fIarchitecture-bits\fP"
116Restrict the architectures listed by \fB\-\-list\-known\fP to ones with the
117specified CPU bits (since dpkg 1.17.14). Either \fB32\fP or \fB64\fP.
118.TP
119.BR \-E ", " \-\-match\-endian " \fIarchitecture-endianness\fP"
120Restrict the architectures listed by \fB\-\-list\-known\fP to ones with the
121specified endianness (since dpkg 1.17.14). Either \fBlittle\fP or \fBbig\fP.
122.TP
123.BR \-f ", " \-\-force
124Values set by existing environment variables with the same name as used by
125the scripts are honored (i.e. used by \fBdpkg\-architecture\fP), except if
126this force flag is present. This allows the user
127to override a value even when the call to \fBdpkg\-architecture\fP is buried
128in some other script (for example \fBdpkg\-buildpackage\fP(1)).
129.
130.SH TERMS
131.IP "build machine" 4
132The machine the package is built on.
133.IP "host machine" 4
134The machine the package is built for.
135.IP "target machine" 4
136The machine the compiler is building for.
137This is only needed when building a cross-toolchain, one that will be built
138on the build architecture, to be run on the host architecture, and to build
139code for the target architecture.
140.IP "Debian architecture" 4
141The Debian architecture string, which specifies the binary tree in the
142FTP archive. Examples: i386, sparc, hurd\-i386.
143.IP "Debian architecture tuple" 4
144A Debian architecture tuple is the fully qualified architecture with all its
145components spelled out.
146This differs with Debian architectures in that at least the \fIcpu\fP
147component does not embed the \fIabi\fP.
148The current tuple has the form \fIabi\fP\-\fIlibc\fP\-\fIos\fP\-\fIcpu\fP.
149Examples: base\-gnu\-linux\-amd64, eabihf\-musl\-linux\-arm.
150.IP "Debian architecture wildcard" 4
151A Debian architecture wildcard is a special architecture string that will
152match any real architecture being part of it.
153The general form is a Debian architecture tuple with four or less elements,
154and with at least one of them being \fBany\fP.
155Missing elements of the tuple are prefixed implicitly as \fBany\fP, and thus
156the following pairs are equivalent:
157.nf
158 \fBany\fP\-\fBany\fP\-\fBany\fP\-\fBany\fP = \fBany\fP
159 \fBany\fP\-\fBany\fP\-\fIos\fP\-\fBany\fP = \fIos\fP\-\fBany\fP
160 \fBany\fP\-\fIlibc\fP\-\fBany\fP\-\fBany\fP = \fIlibc\fP\-\fBany\fP\-\fBany\fP
161.fi
162Examples: linux\-any, any\-i386, hurd\-any, eabi\-any\-any\-arm,
163musl\-any\-any.
164.IP "GNU system type" 4
165An architecture specification string consisting of two parts separated by
166a hyphen: cpu and system.
167Examples: i586\-linux\-gnu, sparc\-linux\-gnu, i686\-gnu, x86_64\-netbsd.
168.IP "multiarch triplet" 4
169The clarified GNU system type, used for filesystem paths.
170This triplet does not change even when the baseline ISA gets bumped,
171so that the resulting paths are stable over time.
172The only current difference with the GNU system type is that the CPU part
173for i386 based systems is always i386.
174Examples: i386\-linux\-gnu, x86_64\-linux\-gnu.
175Example paths: /lib/powerpc64le-linux-gnu/, /usr/lib/i386-kfreebsd-gnu/.
176.
177.SH VARIABLES
178The following variables are set by \fBdpkg\-architecture\fP:
179.IP "\fBDEB_BUILD_ARCH\fP" 4
180The Debian architecture of the build machine.
181.IP "\fBDEB_BUILD_ARCH_ABI\fP" 4
182The Debian abi name of the build machine (since dpkg 1.18.11).
183.IP "\fBDEB_BUILD_ARCH_LIBC\fP" 4
184The Debian libc name of the build machine (since dpkg 1.18.11).
185.IP "\fBDEB_BUILD_ARCH_OS\fP" 4
186The Debian system name of the build machine (since dpkg 1.13.2).
187.IP "\fBDEB_BUILD_ARCH_CPU\fP" 4
188The Debian cpu name of the build machine (since dpkg 1.13.2).
189.IP "\fBDEB_BUILD_ARCH_BITS\fP" 4
190The pointer size of the build machine (in bits; since dpkg 1.15.4).
191.IP "\fBDEB_BUILD_ARCH_ENDIAN\fP" 4
192The endianness of the build machine (little / big; since dpkg 1.15.4).
193.IP "\fBDEB_BUILD_GNU_CPU\fP" 4
194The CPU part of \fBDEB_BUILD_GNU_TYPE\fP.
195.IP "\fBDEB_BUILD_GNU_SYSTEM\fP" 4
196The System part of \fBDEB_BUILD_GNU_TYPE\fP.
197.IP "\fBDEB_BUILD_GNU_TYPE\fP" 4
198The GNU system type of the build machine.
199.IP "\fBDEB_BUILD_MULTIARCH\fP" 4
200The clarified GNU system type of the build machine, used for filesystem
201paths (since dpkg 1.16.0).
202.IP "\fBDEB_HOST_ARCH\fP" 4
203The Debian architecture of the host machine.
204.IP "\fBDEB_HOST_ARCH_ABI\fP" 4
205The Debian abi name of the host machine (since dpkg 1.18.11).
206.IP "\fBDEB_HOST_ARCH_LIBC\fP" 4
207The Debian libc name of the host machine (since dpkg 1.18.11).
208.IP "\fBDEB_HOST_ARCH_OS\fP" 4
209The Debian system name of the host machine (since dpkg 1.13.2).
210.IP "\fBDEB_HOST_ARCH_CPU\fP" 4
211The Debian cpu name of the host machine (since dpkg 1.13.2).
212.IP "\fBDEB_HOST_ARCH_BITS\fP" 4
213The pointer size of the host machine (in bits; since dpkg 1.15.4).
214.IP "\fBDEB_HOST_ARCH_ENDIAN\fP" 4
215The endianness of the host machine (little / big; since dpkg 1.15.4).
216.IP "\fBDEB_HOST_GNU_CPU\fP" 4
217The CPU part of \fBDEB_HOST_GNU_TYPE\fP.
218.IP "\fBDEB_HOST_GNU_SYSTEM\fP" 4
219The System part of \fBDEB_HOST_GNU_TYPE\fP.
220.IP "\fBDEB_HOST_GNU_TYPE\fP" 4
221The GNU system type of the host machine.
222.IP "\fBDEB_HOST_MULTIARCH\fP" 4
223The clarified GNU system type of the host machine, used for filesystem
224paths (since dpkg 1.16.0).
225.IP "\fBDEB_TARGET_ARCH\fP" 4
226The Debian architecture of the target machine (since dpkg 1.17.14).
227.IP "\fBDEB_TARGET_ARCH_ABI\fP" 4
228The Debian abi name of the target machine (since dpkg 1.18.11).
229.IP "\fBDEB_TARGET_ARCH_LIBC\fP" 4
230The Debian libc name of the target machine (since dpkg 1.18.11).
231.IP "\fBDEB_TARGET_ARCH_OS\fP" 4
232The Debian system name of the target machine (since dpkg 1.17.14).
233.IP "\fBDEB_TARGET_ARCH_CPU\fP" 4
234The Debian cpu name of the target machine (since dpkg 1.17.14).
235.IP "\fBDEB_TARGET_ARCH_BITS\fP" 4
236The pointer size of the target machine (in bits; since dpkg 1.17.14).
237.IP "\fBDEB_TARGET_ARCH_ENDIAN\fP" 4
238The endianness of the target machine (little / big; since dpkg 1.17.14).
239.IP "\fBDEB_TARGET_GNU_CPU\fP" 4
240The CPU part of \fBDEB_TARGET_GNU_TYPE\fP (since dpkg 1.17.14).
241.IP "\fBDEB_TARGET_GNU_SYSTEM\fP" 4
242The System part of \fBDEB_TARGET_GNU_TYPE\fP (since dpkg 1.17.14).
243.IP "\fBDEB_TARGET_GNU_TYPE\fP" 4
244The GNU system type of the target machine (since dpkg 1.17.14).
245.IP "\fBDEB_TARGET_MULTIARCH\fP" 4
246The clarified GNU system type of the target machine, used for filesystem
247paths (since dpkg 1.17.14).
248.
249.SH FILES
250.SS Architecture tables
251All these files have to be present for \fBdpkg\-architecture\fP to
252work. Their location can be overridden at runtime with the environment
253variable \fBDPKG_DATADIR\fP.
254These tables contain a format \fBVersion\fP pseudo-field on their first
255line to mark their format, so that parsers can check if they understand
256it, such as "# Version=1.0".
257.TP
258.I %PKGDATADIR%/cputable
259Table of known CPU names and mapping to their GNU name.
260Format version 1.0 (since dpkg 1.13.2).
261.TP
262.I %PKGDATADIR%/ostable
263Table of known operating system names and mapping to their GNU name.
264Format version 2.0 (since dpkg 1.18.11).
265.TP
266.I %PKGDATADIR%/tupletable
267Mapping between Debian architecture tuples and Debian architecture
268names.
269Format version 1.0 (since dpkg 1.18.11).
270.TP
271.I %PKGDATADIR%/abitable
272Table of Debian architecture ABI attribute overrides.
273Format version 2.0 (since dpkg 1.18.11).
274.SS Packaging support
275.TP
276.I %PKGDATADIR%/architecture.mk
277Makefile snippet that properly sets and exports all the variables that
278\fBdpkg\-architecture\fP outputs (since dpkg 1.16.1).
279.
280.SH EXAMPLES
281\fBdpkg\-buildpackage\fP accepts the \fB\-a\fR option and passes it to
282\fBdpkg\-architecture\fP. Other examples:
283.IP
284CC=i386\-gnu\-gcc dpkg\-architecture \-c debian/rules build
285.IP
286eval \`dpkg\-architecture \-u\`
287.PP
288Check if the current or specified host architecture is equal to an
289architecture:
290.IP
291dpkg\-architecture \-elinux\-alpha
292.IP
293dpkg\-architecture \-amips \-elinux\-mips
294.PP
295Check if the current or specified host architecture is a Linux system:
296.IP
297dpkg\-architecture \-ilinux\-any
298.IP
299dpkg\-architecture \-ai386 \-ilinux\-any
300.
301.SS Usage in debian/rules
302The environment variables set by \fBdpkg\-architecture\fP are passed to
303\fIdebian/rules\fP as make variables (see make documentation). However,
304you should not rely on them, as this breaks manual invocation of the
305script. Instead, you should always initialize them using
306\fBdpkg\-architecture\fP with the \fB\-q\fP option. Here are some examples,
307which also show how you can improve the cross compilation support in your
308package:
309.PP
310Retrieving the GNU system type and forwarding it to ./configure:
311.PP
312.RS 4
313.nf
314DEB_BUILD_GNU_TYPE ?= $(shell dpkg\-architecture \-qDEB_BUILD_GNU_TYPE)
315DEB_HOST_GNU_TYPE ?= $(shell dpkg\-architecture \-qDEB_HOST_GNU_TYPE)
316[...]
317ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
318 confflags += \-\-build=$(DEB_HOST_GNU_TYPE)
319else
320 confflags += \-\-build=$(DEB_BUILD_GNU_TYPE) \\
321 \-\-host=$(DEB_HOST_GNU_TYPE)
322endif
323[...]
324\&./configure $(confflags)
325.fi
326.RE
327.PP
328Doing something only for a specific architecture:
329.PP
330.RS 4
331.nf
332DEB_HOST_ARCH ?= $(shell dpkg\-architecture \-qDEB_HOST_ARCH)
333
334ifeq ($(DEB_HOST_ARCH),alpha)
335 [...]
336endif
337.fi
338.RE
339.PP
340or if you only need to check the CPU or OS type, use the
341\fBDEB_HOST_ARCH_CPU\fP or \fBDEB_HOST_ARCH_OS\fP variables.
342.PP
343Note that you can also rely on an external Makefile snippet to properly
344set all the variables that \fBdpkg\-architecture\fP can provide:
345.PP
346.RS 4
347.nf
348include %PKGDATADIR%/architecture.mk
349
350ifeq ($(DEB_HOST_ARCH),alpha)
351 [...]
352endif
353.fi
354.RE
355.PP
356In any case, you should never use \fBdpkg \-\-print\-architecture\fP to get
357architecture information during a package build.
358.
359.SH ENVIRONMENT
360.TP
361.B DPKG_DATADIR
362If set, it will be used as the \fBdpkg\fP data directory, where the
363architecture tables are located (since dpkg 1.14.17).
364Defaults to «%PKGDATADIR%».
365.SH NOTES
366All long command and option names available only since dpkg 1.17.17.
367.
368.SH SEE ALSO
369.BR dpkg\-buildpackage (1),
370.BR dpkg\-cross (1).