dpkg-architecture.man 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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 utilities"
  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 wildcard" 4
  143. A Debian architecture wildcard is a special architecture string that will match
  144. any real architecture being part of it. The general form is <kernel>\-<cpu>.
  145. Examples: linux\-any, any\-i386, hurd\-any.
  146. .IP "GNU system type" 4
  147. An architecture specification string consisting of two parts separated by
  148. a hyphen: cpu and system.
  149. Examples: i586\-linux\-gnu, sparc\-linux\-gnu, i686\-gnu, x86_64\-netbsd.
  150. .IP "multiarch triplet" 4
  151. The clarified GNU system type, used for filesystem paths.
  152. This triplet does not change even when the baseline ISA gets bumped,
  153. so that the resulting paths are stable over time.
  154. The only current difference with the GNU system type is that the CPU part
  155. for i386 based systems is always i386.
  156. Examples: i386\-linux\-gnu, x86_64\-linux\-gnu.
  157. Example paths: /lib/powerpc64le-linux-gnu/, /usr/lib/i386-kfreebsd-gnu/.
  158. .
  159. .SH VARIABLES
  160. The following variables are set by \fBdpkg\-architecture\fP:
  161. .IP "\fBDEB_BUILD_ARCH\fP" 4
  162. The Debian architecture of the build machine.
  163. .IP "\fBDEB_BUILD_ARCH_OS\fP" 4
  164. The Debian system name of the build machine (since dpkg 1.13.2).
  165. .IP "\fBDEB_BUILD_ARCH_CPU\fP" 4
  166. The Debian cpu name of the build machine (since dpkg 1.13.2).
  167. .IP "\fBDEB_BUILD_ARCH_BITS\fP" 4
  168. The pointer size of the build machine (in bits; since dpkg 1.15.4).
  169. .IP "\fBDEB_BUILD_ARCH_ENDIAN\fP" 4
  170. The endianness of the build machine (little / big; since dpkg 1.15.4).
  171. .IP "\fBDEB_BUILD_GNU_CPU\fP" 4
  172. The CPU part of \fBDEB_BUILD_GNU_TYPE\fP.
  173. .IP "\fBDEB_BUILD_GNU_SYSTEM\fP" 4
  174. The System part of \fBDEB_BUILD_GNU_TYPE\fP.
  175. .IP "\fBDEB_BUILD_GNU_TYPE\fP" 4
  176. The GNU system type of the build machine.
  177. .IP "\fBDEB_BUILD_MULTIARCH\fP" 4
  178. The clarified GNU system type of the build machine, used for filesystem
  179. paths (since dpkg 1.16.0).
  180. .IP "\fBDEB_HOST_ARCH\fP" 4
  181. The Debian architecture of the host machine.
  182. .IP "\fBDEB_HOST_ARCH_OS\fP" 4
  183. The Debian system name of the host machine (since dpkg 1.13.2).
  184. .IP "\fBDEB_HOST_ARCH_CPU\fP" 4
  185. The Debian cpu name of the host machine (since dpkg 1.13.2).
  186. .IP "\fBDEB_HOST_ARCH_BITS\fP" 4
  187. The pointer size of the host machine (in bits; since dpkg 1.15.4).
  188. .IP "\fBDEB_HOST_ARCH_ENDIAN\fP" 4
  189. The endianness of the host machine (little / big; since dpkg 1.15.4).
  190. .IP "\fBDEB_HOST_GNU_CPU\fP" 4
  191. The CPU part of \fBDEB_HOST_GNU_TYPE\fP.
  192. .IP "\fBDEB_HOST_GNU_SYSTEM\fP" 4
  193. The System part of \fBDEB_HOST_GNU_TYPE\fP.
  194. .IP "\fBDEB_HOST_GNU_TYPE\fP" 4
  195. The GNU system type of the host machine.
  196. .IP "\fBDEB_HOST_MULTIARCH\fP" 4
  197. The clarified GNU system type of the host machine, used for filesystem
  198. paths (since dpkg 1.16.0).
  199. .IP "\fBDEB_TARGET_ARCH\fP" 4
  200. The Debian architecture of the target machine (since dpkg 1.17.14).
  201. .IP "\fBDEB_TARGET_ARCH_OS\fP" 4
  202. The Debian system name of the target machine (since dpkg 1.17.14).
  203. .IP "\fBDEB_TARGET_ARCH_CPU\fP" 4
  204. The Debian cpu name of the target machine (since dpkg 1.17.14).
  205. .IP "\fBDEB_TARGET_ARCH_BITS\fP" 4
  206. The pointer size of the target machine (in bits; since dpkg 1.17.14).
  207. .IP "\fBDEB_TARGET_ARCH_ENDIAN\fP" 4
  208. The endianness of the target machine (little / big; since dpkg 1.17.14).
  209. .IP "\fBDEB_TARGET_GNU_CPU\fP" 4
  210. The CPU part of \fBDEB_TARGET_GNU_TYPE\fP (since dpkg 1.17.14).
  211. .IP "\fBDEB_TARGET_GNU_SYSTEM\fP" 4
  212. The System part of \fBDEB_TARGET_GNU_TYPE\fP (since dpkg 1.17.14).
  213. .IP "\fBDEB_TARGET_GNU_TYPE\fP" 4
  214. The GNU system type of the target machine (since dpkg 1.17.14).
  215. .IP "\fBDEB_TARGET_MULTIARCH\fP" 4
  216. The clarified GNU system type of the target machine, used for filesystem
  217. paths (since dpkg 1.17.14).
  218. .
  219. .SH FILES
  220. .SS Architecture tables
  221. All these files have to be present for \fBdpkg\-architecture\fP to
  222. work. Their location can be overridden at runtime with the environment
  223. variable \fBDPKG_DATADIR\fP.
  224. .TP
  225. .I %PKGDATADIR%/cputable
  226. Table of known CPU names and mapping to their GNU name.
  227. .TP
  228. .I %PKGDATADIR%/ostable
  229. Table of known operating system names and mapping to their GNU name.
  230. .TP
  231. .I %PKGDATADIR%/triplettable
  232. Mapping between Debian architecture triplets and Debian architecture
  233. names.
  234. .TP
  235. .I %PKGDATADIR%/abitable
  236. Table of Debian architecture ABI attribute overrides.
  237. .SS Packaging support
  238. .TP
  239. .I %PKGDATADIR%/architecture.mk
  240. Makefile snippet that properly sets and exports all the variables that
  241. \fBdpkg\-architecture\fP outputs (since dpkg 1.16.1).
  242. .
  243. .SH EXAMPLES
  244. \fBdpkg\-buildpackage\fP accepts the \fB\-a\fR option and passes it to
  245. \fBdpkg\-architecture\fP. Other examples:
  246. .IP
  247. CC=i386\-gnu\-gcc dpkg\-architecture \-c debian/rules build
  248. .IP
  249. eval \`dpkg\-architecture \-u\`
  250. .PP
  251. Check if the current or specified host architecture is equal to an
  252. architecture:
  253. .IP
  254. dpkg\-architecture \-elinux\-alpha
  255. .IP
  256. dpkg\-architecture \-amips \-elinux\-mips
  257. .PP
  258. Check if the current or specified host architecture is a Linux system:
  259. .IP
  260. dpkg\-architecture \-ilinux\-any
  261. .IP
  262. dpkg\-architecture \-ai386 \-ilinux\-any
  263. .
  264. .SS Usage in debian/rules
  265. The environment variables set by \fBdpkg\-architecture\fP are passed to
  266. \fIdebian/rules\fP as make variables (see make documentation). However,
  267. you should not rely on them, as this breaks manual invocation of the
  268. script. Instead, you should always initialize them using
  269. \fBdpkg\-architecture\fP with the \fB\-q\fP option. Here are some examples,
  270. which also show how you can improve the cross compilation support in your
  271. package:
  272. .PP
  273. Retrieving the GNU system type and forwarding it to ./configure:
  274. .PP
  275. .RS 4
  276. .nf
  277. DEB_BUILD_GNU_TYPE ?= $(shell dpkg\-architecture \-qDEB_BUILD_GNU_TYPE)
  278. DEB_HOST_GNU_TYPE ?= $(shell dpkg\-architecture \-qDEB_HOST_GNU_TYPE)
  279. [...]
  280. ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  281. confflags += \-\-build=$(DEB_HOST_GNU_TYPE)
  282. else
  283. confflags += \-\-build=$(DEB_BUILD_GNU_TYPE) \\
  284. \-\-host=$(DEB_HOST_GNU_TYPE)
  285. endif
  286. [...]
  287. \&./configure $(confflags)
  288. .fi
  289. .RE
  290. .PP
  291. Doing something only for a specific architecture:
  292. .PP
  293. .RS 4
  294. .nf
  295. DEB_HOST_ARCH ?= $(shell dpkg\-architecture \-qDEB_HOST_ARCH)
  296. ifeq ($(DEB_HOST_ARCH),alpha)
  297. [...]
  298. endif
  299. .fi
  300. .RE
  301. .PP
  302. or if you only need to check the CPU or OS type, use the
  303. \fBDEB_HOST_ARCH_CPU\fP or \fBDEB_HOST_ARCH_OS\fP variables.
  304. .PP
  305. Note that you can also rely on an external Makefile snippet to properly
  306. set all the variables that \fBdpkg\-architecture\fP can provide:
  307. .PP
  308. .RS 4
  309. .nf
  310. include %PKGDATADIR%/architecture.mk
  311. ifeq ($(DEB_HOST_ARCH),alpha)
  312. [...]
  313. endif
  314. .fi
  315. .RE
  316. .PP
  317. In any case, you should never use \fBdpkg \-\-print\-architecture\fP to get
  318. architecture information during a package build.
  319. .
  320. .SH NOTES
  321. All long command and option names available only since dpkg 1.17.17.
  322. .
  323. .SH SEE ALSO
  324. .BR dpkg\-buildpackage (1),
  325. .BR dpkg\-cross (1).