dpkg-architecture.1 8.8 KB

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