man-pages/man1/dpkg-architecture.1.html
2021-03-31 01:06:50 +01:00

490 lines
16 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of dpkg-architecture</TITLE>
</HEAD><BODY>
<H1>dpkg-architecture</H1>
Section: dpkg suite (1)<BR>Updated: 2020-03-23<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
dpkg-architecture - set and determine the architecture for package building
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>dpkg-architecture</B>
[<I>option</I>...] [<I>command</I>]
<P>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>dpkg-architecture</B>
provides a facility to determine and set the build and
host architecture for package building.
<P>
The build architecture is always determined by an external call to
<B><A HREF="/cgi-bin/man/man2html?1+dpkg">dpkg</A></B>(1), and cannot be set at the command line.
<P>
You can specify the host architecture by providing one or both of the options
<B>--host-arch</B> and <B>--host-type</B>. The default is determined by
an external call to
<B><A HREF="/cgi-bin/man/man2html?1+gcc">gcc</A></B>(1),
or the same as the build architecture if <B>CC</B> or gcc are both not
available. One out of <B>--host-arch</B> and <B>--host-type</B> is
sufficient, the value of the
other will be set to a usable default. Indeed, it is often better to only
specify one, because <B>dpkg-architecture</B> will warn you if your choice
does not match the default.
<A NAME="lbAE">&nbsp;</A>
<H2>COMMANDS</H2>
<DL COMPACT>
<DT id="1"><B>-l</B>, <B>--list</B>
<DD>
Print the environment variables, one each line, in the format
<I>VARIABLE=value</I>. This is the default action.
<DT id="2"><B>-e</B>, <B>--equal</B> <I>architecture</I>
<DD>
Check for equality of architecture (since dpkg 1.13.13).
It compares the current or specified Debian host architecture against
<I>architecture</I>, to check if they are equal.
This action will not expand the architecture wildcards.
Command finishes with an exit status of 0 if matched, 1 if not matched.
<P>
<DT id="3"><B>-i</B>, <B>--is</B> <I>architecture-wildcard</I>
<DD>
Check for identity of architecture (since dpkg 1.13.13).
It compares the current or specified Debian host architecture against
<I>architecture-wildcard</I> after having expanded it as an architecture
wildcard, to check if they match.
Command finishes with an exit status of 0 if matched, 1 if not matched.
<DT id="4"><B>-q</B>, <B>--query</B> <I>variable-name</I>
<DD>
Print the value of a single variable.
<DT id="5"><B>-s</B>, <B>--print-set</B>
<DD>
Print an export command. This can be used to set the environment variables
using eval.
<DT id="6"><B>-u</B>, <B>--print-unset</B>
<DD>
Print a similar command to <B>--print-unset</B> but to unset all variables.
<DT id="7"><B>-c</B>, <B>--command</B> <I>command-string</I>
<DD>
Execute a <I>command-string</I> in an environment which has all variables
set to the determined value.
<DT id="8"><B>-L</B>, <B>--list-known</B>
<DD>
Print a list of valid architecture names.
Possibly restricted by one or more of the matching options
<B>--match-wildcard</B>, <B>--match-bits</B> or <B>--match-endian</B>
(since dpkg 1.17.14).
<DT id="9"><B>-?</B>, <B>--help</B>
<DD>
Show the usage message and exit.
<DT id="10"><B>--version</B>
<DD>
Show the version and exit.
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>OPTIONS</H2>
<DL COMPACT>
<DT id="11"><B>-a</B>, <B>--host-arch</B> <I>architecture</I>
<DD>
Set the host Debian architecture.
<DT id="12"><B>-t</B>, <B>--host-type</B> <I>gnu-system-type</I>
<DD>
Set the host GNU system type.
<DT id="13"><B>-A</B>, <B>--target-arch</B> <I>architecture</I>
<DD>
Set the target Debian architecture (since dpkg 1.17.14).
<DT id="14"><B>-T</B>, <B>--target-type</B> <I>gnu-system-type</I>
<DD>
Set the target GNU system type (since dpkg 1.17.14).
<DT id="15"><B>-W</B>, <B>--match-wildcard</B> <I>architecture-wildcard</I>
<DD>
Restrict the architectures listed by <B>--list-known</B> to ones matching
the specified architecture wildcard (since dpkg 1.17.14).
<DT id="16"><B>-B</B>, <B>--match-bits</B> <I>architecture-bits</I>
<DD>
Restrict the architectures listed by <B>--list-known</B> to ones with the
specified CPU bits (since dpkg 1.17.14). Either <B>32</B> or <B>64</B>.
<DT id="17"><B>-E</B>, <B>--match-endian</B> <I>architecture-endianness</I>
<DD>
Restrict the architectures listed by <B>--list-known</B> to ones with the
specified endianness (since dpkg 1.17.14). Either <B>little</B> or <B>big</B>.
<DT id="18"><B>-f</B>, <B>--force</B>
<DD>
Values set by existing environment variables with the same name as used by
the scripts are honored (i.e. used by <B>dpkg-architecture</B>), except if
this force flag is present. This allows the user
to override a value even when the call to <B>dpkg-architecture</B> is buried
in some other script (for example <B><A HREF="/cgi-bin/man/man2html?1+dpkg-buildpackage">dpkg-buildpackage</A></B>(1)).
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>TERMS</H2>
<DL COMPACT>
<DT id="19">build machine<DD>
The machine the package is built on.
<DT id="20">host machine<DD>
The machine the package is built for.
<DT id="21">target machine<DD>
The machine the compiler is building for.
This is only needed when building a cross-toolchain, one that will be built
on the build architecture, to be run on the host architecture, and to build
code for the target architecture.
<DT id="22">Debian architecture<DD>
The Debian architecture string, which specifies the binary tree in the
FTP archive. Examples: i386, sparc, hurd-i386.
<DT id="23">Debian architecture tuple<DD>
A Debian architecture tuple is the fully qualified architecture with all its
components spelled out.
This differs with Debian architectures in that at least the <I>cpu</I>
component does not embed the <I>abi</I>.
The current tuple has the form <I>abi</I>-<I>libc</I>-<I>os</I>-<I>cpu</I>.
Examples: base-gnu-linux-amd64, eabihf-musl-linux-arm.
<DT id="24">Debian architecture wildcard<DD>
A Debian architecture wildcard is a special architecture string that will
match any real architecture being part of it.
The general form is a Debian architecture tuple with four or less elements,
and with at least one of them being <B>any</B>.
Missing elements of the tuple are prefixed implicitly as <B>any</B>, and thus
the following pairs are equivalent:
<PRE>
<B>any</B>-<B>any</B>-<B>any</B>-<B>any</B> = <B>any</B>
<B>any</B>-<B>any</B>-<I>os</I>-<B>any</B> = <I>os</I>-<B>any</B>
<B>any</B>-<I>libc</I>-<B>any</B>-<B>any</B> = <I>libc</I>-<B>any</B>-<B>any</B>
</PRE>
Examples: linux-any, any-i386, hurd-any, eabi-any-any-arm,
musl-any-any.
<DT id="25">GNU system type<DD>
An architecture specification string consisting of two parts separated by
a hyphen: cpu and system.
Examples: i586-linux-gnu, sparc-linux-gnu, i686-gnu, x86_64-netbsd.
<DT id="26">multiarch triplet<DD>
The clarified GNU system type, used for filesystem paths.
This triplet does not change even when the baseline ISA gets bumped,
so that the resulting paths are stable over time.
The only current difference with the GNU system type is that the CPU part
for i386 based systems is always i386.
Examples: i386-linux-gnu, x86_64-linux-gnu.
Example paths: /lib/powerpc64le-linux-gnu/, /usr/lib/i386-kfreebsd-gnu/.
</DL>
<A NAME="lbAH">&nbsp;</A>
<H2>VARIABLES</H2>
The following variables are set by <B>dpkg-architecture</B> (see the
<B>TERMS</B> section for a description of the naming scheme):
<DL COMPACT>
<DT id="27"><B>DEB_BUILD_ARCH</B><DD>
The Debian architecture of the build machine.
<DT id="28"><B>DEB_BUILD_ARCH_ABI</B><DD>
The Debian abi name of the build machine (since dpkg 1.18.11).
<DT id="29"><B>DEB_BUILD_ARCH_LIBC</B><DD>
The Debian libc name of the build machine (since dpkg 1.18.11).
<DT id="30"><B>DEB_BUILD_ARCH_OS</B><DD>
The Debian system name of the build machine (since dpkg 1.13.2).
<DT id="31"><B>DEB_BUILD_ARCH_CPU</B><DD>
The Debian cpu name of the build machine (since dpkg 1.13.2).
<DT id="32"><B>DEB_BUILD_ARCH_BITS</B><DD>
The pointer size of the build machine (in bits; since dpkg 1.15.4).
<DT id="33"><B>DEB_BUILD_ARCH_ENDIAN</B><DD>
The endianness of the build machine (little / big; since dpkg 1.15.4).
<DT id="34"><B>DEB_BUILD_GNU_CPU</B><DD>
The CPU part of <B>DEB_BUILD_GNU_TYPE</B>.
<DT id="35"><B>DEB_BUILD_GNU_SYSTEM</B><DD>
The System part of <B>DEB_BUILD_GNU_TYPE</B>.
<DT id="36"><B>DEB_BUILD_GNU_TYPE</B><DD>
The GNU system type of the build machine.
<DT id="37"><B>DEB_BUILD_MULTIARCH</B><DD>
The clarified GNU system type of the build machine, used for filesystem
paths (since dpkg 1.16.0).
<DT id="38"><B>DEB_HOST_ARCH</B><DD>
The Debian architecture of the host machine.
<DT id="39"><B>DEB_HOST_ARCH_ABI</B><DD>
The Debian abi name of the host machine (since dpkg 1.18.11).
<DT id="40"><B>DEB_HOST_ARCH_LIBC</B><DD>
The Debian libc name of the host machine (since dpkg 1.18.11).
<DT id="41"><B>DEB_HOST_ARCH_OS</B><DD>
The Debian system name of the host machine (since dpkg 1.13.2).
<DT id="42"><B>DEB_HOST_ARCH_CPU</B><DD>
The Debian cpu name of the host machine (since dpkg 1.13.2).
<DT id="43"><B>DEB_HOST_ARCH_BITS</B><DD>
The pointer size of the host machine (in bits; since dpkg 1.15.4).
<DT id="44"><B>DEB_HOST_ARCH_ENDIAN</B><DD>
The endianness of the host machine (little / big; since dpkg 1.15.4).
<DT id="45"><B>DEB_HOST_GNU_CPU</B><DD>
The CPU part of <B>DEB_HOST_GNU_TYPE</B>.
<DT id="46"><B>DEB_HOST_GNU_SYSTEM</B><DD>
The System part of <B>DEB_HOST_GNU_TYPE</B>.
<DT id="47"><B>DEB_HOST_GNU_TYPE</B><DD>
The GNU system type of the host machine.
<DT id="48"><B>DEB_HOST_MULTIARCH</B><DD>
The clarified GNU system type of the host machine, used for filesystem
paths (since dpkg 1.16.0).
<DT id="49"><B>DEB_TARGET_ARCH</B><DD>
The Debian architecture of the target machine (since dpkg 1.17.14).
<DT id="50"><B>DEB_TARGET_ARCH_ABI</B><DD>
The Debian abi name of the target machine (since dpkg 1.18.11).
<DT id="51"><B>DEB_TARGET_ARCH_LIBC</B><DD>
The Debian libc name of the target machine (since dpkg 1.18.11).
<DT id="52"><B>DEB_TARGET_ARCH_OS</B><DD>
The Debian system name of the target machine (since dpkg 1.17.14).
<DT id="53"><B>DEB_TARGET_ARCH_CPU</B><DD>
The Debian cpu name of the target machine (since dpkg 1.17.14).
<DT id="54"><B>DEB_TARGET_ARCH_BITS</B><DD>
The pointer size of the target machine (in bits; since dpkg 1.17.14).
<DT id="55"><B>DEB_TARGET_ARCH_ENDIAN</B><DD>
The endianness of the target machine (little / big; since dpkg 1.17.14).
<DT id="56"><B>DEB_TARGET_GNU_CPU</B><DD>
The CPU part of <B>DEB_TARGET_GNU_TYPE</B> (since dpkg 1.17.14).
<DT id="57"><B>DEB_TARGET_GNU_SYSTEM</B><DD>
The System part of <B>DEB_TARGET_GNU_TYPE</B> (since dpkg 1.17.14).
<DT id="58"><B>DEB_TARGET_GNU_TYPE</B><DD>
The GNU system type of the target machine (since dpkg 1.17.14).
<DT id="59"><B>DEB_TARGET_MULTIARCH</B><DD>
The clarified GNU system type of the target machine, used for filesystem
paths (since dpkg 1.17.14).
</DL>
<A NAME="lbAI">&nbsp;</A>
<H2>FILES</H2>
<A NAME="lbAJ">&nbsp;</A>
<H3>Architecture tables</H3>
All these files have to be present for <B>dpkg-architecture</B> to
work. Their location can be overridden at runtime with the environment
variable <B>DPKG_DATADIR</B>.
These tables contain a format <B>Version</B> pseudo-field on their first
line to mark their format, so that parsers can check if they understand
it, such as &quot;# Version=1.0&quot;.
<DL COMPACT>
<DT id="60"><I>/usr/share/dpkg/cputable</I>
<DD>
Table of known CPU names and mapping to their GNU name.
Format version 1.0 (since dpkg 1.13.2).
<DT id="61"><I>/usr/share/dpkg/ostable</I>
<DD>
Table of known operating system names and mapping to their GNU name.
Format version 2.0 (since dpkg 1.18.11).
<DT id="62"><I>/usr/share/dpkg/tupletable</I>
<DD>
Mapping between Debian architecture tuples and Debian architecture
names.
Format version 1.0 (since dpkg 1.18.11).
<DT id="63"><I>/usr/share/dpkg/abitable</I>
<DD>
Table of Debian architecture ABI attribute overrides.
Format version 2.0 (since dpkg 1.18.11).
</DL>
<A NAME="lbAK">&nbsp;</A>
<H3>Packaging support</H3>
<DL COMPACT>
<DT id="64"><I>/usr/share/dpkg/architecture.mk</I>
<DD>
Makefile snippet that properly sets and exports all the variables that
<B>dpkg-architecture</B> outputs (since dpkg 1.16.1).
</DL>
<A NAME="lbAL">&nbsp;</A>
<H2>EXAMPLES</H2>
<B>dpkg-buildpackage</B> accepts the <B>-a</B> option and passes it to
<B>dpkg-architecture</B>. Other examples:
<DL COMPACT>
<DT id="65"><DD>
CC=i386-gnu-gcc dpkg-architecture -c debian/rules build
<DT id="66"><DD>
eval `dpkg-architecture -u`
</DL>
<P>
Check if the current or specified host architecture is equal to an
architecture:
<DL COMPACT>
<DT id="67"><DD>
dpkg-architecture -elinux-alpha
<DT id="68"><DD>
dpkg-architecture -amips -elinux-mips
</DL>
<P>
Check if the current or specified host architecture is a Linux system:
<DL COMPACT>
<DT id="69"><DD>
dpkg-architecture -ilinux-any
<DT id="70"><DD>
dpkg-architecture -ai386 -ilinux-any
</DL>
<A NAME="lbAM">&nbsp;</A>
<H3>Usage in debian/rules</H3>
The environment variables set by <B>dpkg-architecture</B> are passed to
<I>debian/rules</I> as make variables (see make documentation). However,
you should not rely on them, as this breaks manual invocation of the
script. Instead, you should always initialize them using
<B>dpkg-architecture</B> with the <B>-q</B> option. Here are some examples,
which also show how you can improve the cross compilation support in your
package:
<P>
Retrieving the GNU system type and forwarding it to ./configure:
<P>
<DL COMPACT><DT id="71"><DD>
<PRE>
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
[...]
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
confflags += --build=$(DEB_HOST_GNU_TYPE)
else
confflags += --build=$(DEB_BUILD_GNU_TYPE) \
--host=$(DEB_HOST_GNU_TYPE)
endif
[...]
./configure $(confflags)
</PRE>
</DL>
<P>
Doing something only for a specific architecture:
<P>
<DL COMPACT><DT id="72"><DD>
<PRE>
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
ifeq ($(DEB_HOST_ARCH),alpha)
[...]
endif
</PRE>
</DL>
<P>
or if you only need to check the CPU or OS type, use the
<B>DEB_HOST_ARCH_CPU</B> or <B>DEB_HOST_ARCH_OS</B> variables.
<P>
Note that you can also rely on an external Makefile snippet to properly
set all the variables that <B>dpkg-architecture</B> can provide:
<P>
<DL COMPACT><DT id="73"><DD>
<PRE>
include /usr/share/dpkg/architecture.mk
ifeq ($(DEB_HOST_ARCH),alpha)
[...]
endif
</PRE>
</DL>
<P>
In any case, you should never use <B>dpkg --print-architecture</B> to get
architecture information during a package build.
<A NAME="lbAN">&nbsp;</A>
<H2>ENVIRONMENT</H2>
<DL COMPACT>
<DT id="74"><B>DPKG_DATADIR</B>
<DD>
If set, it will be used as the <B>dpkg</B> data directory, where the
architecture tables are located (since dpkg 1.14.17).
Defaults to &laquo;/usr/share/dpkg&raquo;.
<DT id="75"><B>DPKG_COLORS</B>
<DD>
Sets the color mode (since dpkg 1.18.5).
The currently accepted values are: <B>auto</B> (default), <B>always</B> and
<B>never</B>.
<DT id="76"><B>DPKG_NLS</B>
<DD>
If set, it will be used to decide whether to activate Native Language Support,
also known as internationalization (or i18n) support (since dpkg 1.19.0).
The accepted values are: <B>0</B> and <B>1</B> (default).
</DL>
<A NAME="lbAO">&nbsp;</A>
<H2>NOTES</H2>
All long command and option names available only since dpkg 1.17.17.
<A NAME="lbAP">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?1+dpkg-buildpackage">dpkg-buildpackage</A></B>(1).
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="77"><A HREF="#lbAB">NAME</A><DD>
<DT id="78"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="79"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="80"><A HREF="#lbAE">COMMANDS</A><DD>
<DT id="81"><A HREF="#lbAF">OPTIONS</A><DD>
<DT id="82"><A HREF="#lbAG">TERMS</A><DD>
<DT id="83"><A HREF="#lbAH">VARIABLES</A><DD>
<DT id="84"><A HREF="#lbAI">FILES</A><DD>
<DL>
<DT id="85"><A HREF="#lbAJ">Architecture tables</A><DD>
<DT id="86"><A HREF="#lbAK">Packaging support</A><DD>
</DL>
<DT id="87"><A HREF="#lbAL">EXAMPLES</A><DD>
<DL>
<DT id="88"><A HREF="#lbAM">Usage in debian/rules</A><DD>
</DL>
<DT id="89"><A HREF="#lbAN">ENVIRONMENT</A><DD>
<DT id="90"><A HREF="#lbAO">NOTES</A><DD>
<DT id="91"><A HREF="#lbAP">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:11 GMT, March 31, 2021
</BODY>
</HTML>