dpkg-architecture.man 14 KB

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