dpkg-architecture.1 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 "2013-03-28" "Debian Project" "dpkg utilities"
  22. .SH NAME
  23. dpkg\-architecture \- set and determine the architecture for package building
  24. .
  25. .SH SYNOPSIS
  26. .B dpkg\-architecture
  27. .RI [ option "...] [" command ]
  28. .PP
  29. .
  30. .SH DESCRIPTION
  31. .B dpkg\-architecture
  32. does provide a facility to determine and set the build and
  33. host architecture for package building.
  34. .PP
  35. The build architecture is always determined by an external call to
  36. \fBdpkg\fP(1), and can not be set at the command line.
  37. .PP
  38. You can specify the host architecture by providing one or both of the options
  39. \fB\-\-host\-arch\fR and \fB\-\-host\-type\fR. The default is determined by
  40. an external call to
  41. .BR gcc (1),
  42. or the same as the build architecture if \fBCC\fP or gcc are both not
  43. available. One out of \fB\-\-host\-arch\fR and \fB\-\-host\-type\fR is
  44. sufficient, the value of the
  45. other will be set to a usable default. Indeed, it is often better to only
  46. specify one, because \fB\%dpkg\-architecture\fP will warn you if your choice
  47. does not match the default.
  48. .
  49. .SH COMMANDS
  50. .TP
  51. .BR \-l ", " \-\-list
  52. Print the environment variables, one each line, in the format
  53. \fIVARIABLE=value\fP. This is the default action.
  54. .TP
  55. .BR \-e ", " \-\-equal " \fIarchitecture\fP"
  56. Check for equality of architecture (since dpkg 1.13.13).
  57. It compares the current or specified Debian host architecture against
  58. \fIarchitecture\fP, to check if they are equal.
  59. This action will not expand the architecture wildcards.
  60. Command finishes with an exit status of 0 if matched, 1 if not matched.
  61. .TP
  62. .BR \-i ", " \-\-is " \fIarchitecture-wildcard\fP"
  63. Check for identity of architecture (since dpkg 1.13.13).
  64. It compares the current or specified Debian host architecture against
  65. \fIarchitecture-wildcard\fP after having expanded it as an architecture
  66. wildcard, to check if they match.
  67. Command finishes with an exit status of 0 if matched, 1 if not matched.
  68. .TP
  69. .BR \-q ", " \-\-query " \fIvariable-name\fP"
  70. Print the value of a single variable.
  71. .TP
  72. .BR \-s ", " \-\-print\-set
  73. Print an export command. This can be used to set the environment variables
  74. using eval.
  75. .TP
  76. .BR \-u ", " \-\-print\-unset
  77. Print a similar command to \fB\-\-print\-unset\fP but to unset all variables.
  78. .TP
  79. .BR \-c ", " \-\-command " \fIcommand\fP"
  80. Execute a \fIcommand\fP in an environment which has all variables set to
  81. the determined value.
  82. .TP
  83. .BR \-L ", " \-\-list\-known
  84. Print a list of valid architecture names.
  85. Possibly restricted by one or more of the matching options
  86. \fB\-\-match\-wildcard\fP, \fB\-\-match\-bits\fP or \fB\-\-match\-endian\fP
  87. (since dpkg 1.17.14).
  88. .TP
  89. .BR \-? ", " \-\-help
  90. Show the usage message and exit.
  91. .TP
  92. .B \-\-version
  93. Show the version and exit.
  94. .
  95. .SH OPTIONS
  96. .TP
  97. .BR \-a ", " \-\-host\-arch " \fIarchitecture\fP"
  98. Set the host Debian architecture.
  99. .TP
  100. .BR \-t ", " \-\-host\-type " \fIgnu-system-type\fP"
  101. Set the host GNU system type.
  102. .TP
  103. .BR \-A ", " \-\-target\-arch " \fIarchitecture\fP"
  104. Set the target Debian architecture (since dpkg 1.17.14).
  105. This is only needed when building a
  106. cross-toolchain, one that will be built on the build architecture, to be
  107. run on the host architecture, and to build code for the target architecture.
  108. .TP
  109. .BR \-T ", " \-\-target\-type " \fIgnu-system-type\fP"
  110. Set the target GNU system type (since dpkg 1.17.14).
  111. .TP
  112. .BR \-W ", " \-\-match\-wildcard " \fIarchitecture-wildcard\fP"
  113. Restrict the architectures listed by \fB\-\-list\-known\fP to ones matching
  114. the specified architecture wildcard (since dpkg 1.17.14).
  115. .TP
  116. .BR \-B ", " \-\-match\-bits " \fIarchitecture-bits\fP"
  117. Restrict the architectures listed by \fB\-\-list\-known\fP to ones with the
  118. specified CPU bits (since dpkg 1.17.14). Either \fB32\fP or \fB64\fP.
  119. .TP
  120. .BR \-E ", " \-\-match\-endian " \fIarchitecture-endianness\fP"
  121. Restrict the architectures listed by \fB\-\-list\-known\fP to ones with the
  122. specified endianness (since dpkg 1.17.14). Either \fBlittle\fP or \fBbig\fP.
  123. .TP
  124. .BR \-f ", " \-\-force
  125. Values set by existing environment variables with the same name as used by
  126. the scripts are honored (i.e. used by \fB\%dpkg\-architecture\fP), except if
  127. this force flag is present. This allows the user
  128. to override a value even when the call to \fB\%dpkg\-architecture\fP is buried
  129. in some other script (for example \fB\%dpkg\-buildpackage\fP(1)).
  130. .
  131. .SH TERMS
  132. .IP "build machine" 4
  133. The machine the package is built on.
  134. .IP "host machine" 4
  135. The machine the package is built for.
  136. .IP "target machine" 4
  137. The machine the compiler is building for.
  138. .IP "Debian architecture" 4
  139. The Debian architecture string, which specifies the binary tree in the
  140. FTP archive. Examples: i386, sparc, hurd\-i386.
  141. .IP "architecture wildcard" 4
  142. An architecture wildcard is a special architecture string that will match
  143. any real architecture being part of it. The general form is <kernel>\-<cpu>.
  144. Examples: linux\-any, any\-i386, hurd\-any.
  145. .IP "GNU system type" 4
  146. An architecture specification string consisting of two parts separated by
  147. a hyphen: cpu and system. Examples: i386\-linux\-gnu, sparc\-linux\-gnu,
  148. i386\-gnu, x86_64\-netbsd.
  149. .
  150. .SH VARIABLES
  151. The following variables are set by \fBdpkg\-architecture\fP:
  152. .IP "\fBDEB_BUILD_ARCH\fP" 4
  153. The Debian architecture of the build machine.
  154. .IP "\fBDEB_BUILD_ARCH_OS\fP" 4
  155. The Debian system name of the build machine (since dpkg 1.13.2).
  156. .IP "\fBDEB_BUILD_ARCH_CPU\fP" 4
  157. The Debian cpu name of the build machine (since dpkg 1.13.2).
  158. .IP "\fBDEB_BUILD_ARCH_BITS\fP" 4
  159. The pointer size of the build machine (in bits; since dpkg 1.15.4).
  160. .IP "\fBDEB_BUILD_ARCH_ENDIAN\fP" 4
  161. The endianness of the build machine (little / big; since dpkg 1.15.4).
  162. .IP "\fBDEB_BUILD_GNU_CPU\fP" 4
  163. The CPU part of \fBDEB_BUILD_GNU_TYPE\fP.
  164. .IP "\fBDEB_BUILD_GNU_SYSTEM\fP" 4
  165. The System part of \fBDEB_BUILD_GNU_TYPE\fP.
  166. .IP "\fBDEB_BUILD_GNU_TYPE\fP" 4
  167. The GNU system type of the build machine.
  168. .IP "\fBDEB_BUILD_MULTIARCH\fP" 4
  169. The clarified GNU system type of the build machine, used for filesystem
  170. paths (since dpkg 1.16.0).
  171. .IP "\fBDEB_HOST_ARCH\fP" 4
  172. The Debian architecture of the host machine.
  173. .IP "\fBDEB_HOST_ARCH_OS\fP" 4
  174. The Debian system name of the host machine (since dpkg 1.13.2).
  175. .IP "\fBDEB_HOST_ARCH_CPU\fP" 4
  176. The Debian cpu name of the host machine (since dpkg 1.13.2).
  177. .IP "\fBDEB_HOST_ARCH_BITS\fP" 4
  178. The pointer size of the host machine (in bits; since dpkg 1.15.4).
  179. .IP "\fBDEB_HOST_ARCH_ENDIAN\fP" 4
  180. The endianness of the host machine (little / big; since dpkg 1.15.4).
  181. .IP "\fBDEB_HOST_GNU_CPU\fP" 4
  182. The CPU part of \fBDEB_HOST_GNU_TYPE\fP.
  183. .IP "\fBDEB_HOST_GNU_SYSTEM\fP" 4
  184. The System part of \fBDEB_HOST_GNU_TYPE\fP.
  185. .IP "\fBDEB_HOST_GNU_TYPE\fP" 4
  186. The GNU system type of the host machine.
  187. .IP "\fBDEB_HOST_MULTIARCH\fP" 4
  188. The clarified GNU system type of the host machine, used for filesystem
  189. paths (since dpkg 1.16.0).
  190. .IP "\fBDEB_TARGET_ARCH\fP" 4
  191. The Debian architecture of the target machine (since dpkg 1.17.14).
  192. .IP "\fBDEB_TARGET_ARCH_OS\fP" 4
  193. The Debian system name of the target machine (since dpkg 1.17.14).
  194. .IP "\fBDEB_TARGET_ARCH_CPU\fP" 4
  195. The Debian cpu name of the target machine (since dpkg 1.17.14).
  196. .IP "\fBDEB_TARGET_ARCH_BITS\fP" 4
  197. The pointer size of the target machine (in bits; since dpkg 1.17.14).
  198. .IP "\fBDEB_TARGET_ARCH_ENDIAN\fP" 4
  199. The endianness of the target machine (little / big; since dpkg 1.17.14).
  200. .IP "\fBDEB_TARGET_GNU_CPU\fP" 4
  201. The CPU part of \fBDEB_TARGET_GNU_TYPE\fP (since dpkg 1.17.14).
  202. .IP "\fBDEB_TARGET_GNU_SYSTEM\fP" 4
  203. The System part of \fBDEB_TARGET_GNU_TYPE\fP (since dpkg 1.17.14).
  204. .IP "\fBDEB_TARGET_GNU_TYPE\fP" 4
  205. The GNU system type of the target machine (since dpkg 1.17.14).
  206. .IP "\fBDEB_TARGET_MULTIARCH\fP" 4
  207. The clarified GNU system type of the target machine, used for filesystem
  208. paths (since dpkg 1.17.14).
  209. .
  210. .SH FILES
  211. .SS Architecture tables
  212. All these files have to be present for \fBdpkg\-architecture\fP to
  213. work. Their location can be overridden at runtime with the environment
  214. variable \fBDPKG_DATADIR\fP.
  215. .TP
  216. .I /usr/share/dpkg/cputable
  217. Table of known CPU names and mapping to their GNU name.
  218. .TP
  219. .I /usr/share/dpkg/ostable
  220. Table of known operating system names and mapping to their GNU name.
  221. .TP
  222. .I /usr/share/dpkg/triplettable
  223. Mapping between Debian architecture triplets and Debian architecture
  224. names.
  225. .SS Packaging support
  226. .TP
  227. .I /usr/share/dpkg/architecture.mk
  228. Makefile snippet that properly sets and exports all the variables that
  229. \fBdpkg\-architecture\fP outputs (since dpkg 1.16.1).
  230. .
  231. .SH EXAMPLES
  232. \fBdpkg\-buildpackage\fP accepts the \fB\-a\fR option and passes it to
  233. \fB\%dpkg\-architecture\fP. Other examples:
  234. .IP
  235. CC=i386\-gnu\-gcc dpkg\-architecture \-c debian/rules build
  236. .IP
  237. eval \`dpkg\-architecture \-u\`
  238. .PP
  239. Check if the current or specified host architecture is equal to an
  240. architecture:
  241. .IP
  242. dpkg\-architecture \-elinux\-alpha
  243. .IP
  244. dpkg\-architecture \-amips \-elinux\-mips
  245. .PP
  246. Check if the current or specified host architecture is a Linux system:
  247. .IP
  248. dpkg\-architecture \-ilinux\-any
  249. .IP
  250. dpkg\-architecture \-ai386 \-ilinux\-any
  251. .
  252. .SS Usage in debian/rules
  253. The environment variables set by \fBdpkg\-architecture\fP are passed to
  254. \fIdebian/rules\fP as make variables (see make documentation). However,
  255. you should not rely on them, as this breaks manual invocation of the
  256. script. Instead, you should always initialize them using
  257. \fB\%dpkg\-architecture\fP with the \fB\-q\fP option. Here are some examples,
  258. which also show how you can improve the cross compilation support in your
  259. package:
  260. .PP
  261. Retrieving the GNU system type and forwarding it to ./configure:
  262. .PP
  263. .RS 4
  264. .nf
  265. DEB_BUILD_GNU_TYPE ?= $(shell dpkg\-architecture \-qDEB_BUILD_GNU_TYPE)
  266. DEB_HOST_GNU_TYPE ?= $(shell dpkg\-architecture \-qDEB_HOST_GNU_TYPE)
  267. [...]
  268. ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  269. confflags += \-\-build=$(DEB_HOST_GNU_TYPE)
  270. else
  271. confflags += \-\-build=$(DEB_BUILD_GNU_TYPE) \\
  272. \-\-host=$(DEB_HOST_GNU_TYPE)
  273. endif
  274. [...]
  275. \&./configure $(confflags)
  276. .fi
  277. .RE
  278. .PP
  279. Doing something only for a specific architecture:
  280. .PP
  281. .RS 4
  282. .nf
  283. DEB_HOST_ARCH ?= $(shell dpkg\-architecture \-qDEB_HOST_ARCH)
  284. ifeq ($(DEB_HOST_ARCH),alpha)
  285. [...]
  286. endif
  287. .fi
  288. .RE
  289. .PP
  290. or if you only need to check the CPU or OS type, use the
  291. \fBDEB_HOST_ARCH_CPU\fP or \fBDEB_HOST_ARCH_OS\fP variables.
  292. .PP
  293. Note that you can also rely on an external Makefile snippet to properly
  294. set all the variables that \fBdpkg\-architecture\fP can provide:
  295. .PP
  296. .RS 4
  297. .nf
  298. include /usr/share/dpkg/architecture.mk
  299. ifeq ($(DEB_HOST_ARCH),alpha)
  300. [...]
  301. endif
  302. .fi
  303. .RE
  304. .PP
  305. In any case, you should never use \fBdpkg \-\-print\-architecture\fP to get
  306. architecture information during a package build.
  307. .
  308. .SH NOTES
  309. All long command and option names available only since dpkg 1.17.17.
  310. .
  311. .SH SEE ALSO
  312. .BR dpkg\-buildpackage (1),
  313. .BR dpkg\-cross (1).