dpkg-architecture.1 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. .TH dpkg\-architecture 1 "2011-08-14" "Debian Project" "dpkg utilities"
  2. .SH "NAME"
  3. dpkg\-architecture \- set and determine the architecture for package building
  4. .
  5. .SH SYNOPSIS
  6. .B dpkg\-architecture
  7. .RI [ option "...] [" command ]
  8. .PP
  9. .
  10. .SH DESCRIPTION
  11. dpkg\-architecture does provide a facility to determine and set the build and
  12. host architecture for package building.
  13. .PP
  14. The build architecture is always determined by an external call to
  15. \fBdpkg\fP(1), and can not be set at the command line.
  16. .PP
  17. You can specify the host architecture by providing one or both of the options
  18. \fB\-a\fR and \fB\-t\fR. The default is determined by an external call to
  19. .BR gcc (1),
  20. or the same as the build architecture if \s-1CC\s0 or gcc are both not
  21. available. One out of \fB\-a\fR and \fB\-t\fR is sufficient, the value of the
  22. other will be set to a usable default. Indeed, it is often better to only
  23. specify one, because \fBdpkg\-architecture\fP will warn you if your choice
  24. does not match the default.
  25. .
  26. .SH COMMANDS
  27. .TP
  28. .B \-l
  29. Print the environment variables, one each line, in the format
  30. \fIVARIABLE=value\fP. This is the default action.
  31. .TP
  32. .BI \-e debian-architecture
  33. Check for equality of architecture. By default \fIdebian-architecture\fP
  34. is compared against the current Debian architecture, being the host.
  35. This action will not expand the architecture wildcards. Command finishes
  36. with an exit status of 0 if matched, 1 if not matched.
  37. .TP
  38. .BI \-i architecture-wildcard
  39. Check for identity of architecture by expanding \fIarchitecture-wildcard\fP
  40. as an architecture wildcard and comparing against the current Debian
  41. architecture. Command finishes with an exit status of 0 if matched, 1 if
  42. not matched.
  43. .TP
  44. .BI \-q variable-name
  45. Print the value of a single variable.
  46. .TP
  47. .B \-s
  48. Print an export command. This can be used to set the environment variables
  49. using eval.
  50. .TP
  51. .B \-u
  52. Print a similar command to \fB\-s\fP but to unset all variables.
  53. .TP
  54. .BI \-c " command"
  55. Execute a \fIcommand\fP in an environment which has all variables set to
  56. the determined value.
  57. .TP
  58. .B \-L
  59. Print a list of valid architecture names.
  60. .TP
  61. .B \-\-help
  62. Show the usage message and exit.
  63. .TP
  64. .B \-\-version
  65. Show the version and exit.
  66. .
  67. .SH OPTIONS
  68. .TP
  69. .BI \-a debian-architecture
  70. Set the Debian architecture.
  71. .TP
  72. .BI \-t gnu-system-type
  73. Set the GNU system type.
  74. .TP
  75. .B \-f
  76. Values set by existing environment variables with the same name as used by
  77. the scripts are honored (i.e. used by \fBdpkg\-architecture\fP), except if
  78. this force flag is present. This allows the user
  79. to override a value even when the call to \fBdpkg\-architecture\fP is buried
  80. in some other script (for example \fBdpkg\-buildpackage\fP(1)).
  81. .
  82. .SH TERMS
  83. .IP "build machine" 4
  84. The machine the package is built on.
  85. .IP "host machine" 4
  86. The machine the package is built for.
  87. .IP "Debian architecture" 4
  88. The Debian architecture string, which specifies the binary tree in the
  89. \s-1FTP\s0 archive. Examples: i386, sparc, hurd\-i386.
  90. .IP "architecture wildcard" 4
  91. An architecture wildcard is a special architecture string that will match
  92. any real architecture being part of it. The general form is <kernel>\-<cpu>.
  93. Examples: linux\-any, any\-i386, hurd\-any.
  94. .IP "\s-1GNU\s0 system type" 4
  95. An architecture specification string consisting of two parts separated by
  96. a dash: cpu and system. Examples: i386\-linux\-gnu, sparc\-linux\-gnu,
  97. i386\-gnu, x86_64\-netbsd.
  98. .
  99. .SH VARIABLES
  100. The following variables are set by \fBdpkg\-architecture\fP:
  101. .IP "\s-1DEB_BUILD_ARCH\s0" 4
  102. The Debian architecture of the build machine.
  103. .IP "\s-1DEB_BUILD_ARCH_OS\s0" 4
  104. The Debian system name of the build machine.
  105. .IP "\s-1DEB_BUILD_ARCH_CPU\s0" 4
  106. The Debian cpu name of the build machine.
  107. .IP "\s-1DEB_BUILD_ARCH_BITS\s0" 4
  108. The pointer size of the build machine (in bits).
  109. .IP "\s-1DEB_BUILD_ARCH_ENDIAN\s0" 4
  110. The endianness of the build machine (little / big).
  111. .IP "\s-1DEB_BUILD_GNU_CPU\s0" 4
  112. The \s-1CPU\s0 part of \s-1DEB_BUILD_GNU_TYPE\s0.
  113. .IP "\s-1DEB_BUILD_GNU_SYSTEM\s0" 4
  114. The System part of \s-1DEB_BUILD_GNU_TYPE\s0.
  115. .IP "\s-1DEB_BUILD_GNU_TYPE\s0" 4
  116. The \s-1GNU\s0 system type of the build machine.
  117. .IP "\s-1DEB_BUILD_MULTIARCH\s0" 4
  118. The clarified \s-1GNU\s0 system type of the build machine, used for filesystem
  119. paths.
  120. .IP "\s-1DEB_HOST_ARCH\s0" 4
  121. The Debian architecture of the host machine.
  122. .IP "\s-1DEB_HOST_ARCH_OS\s0" 4
  123. The Debian system name of the host machine.
  124. .IP "\s-1DEB_HOST_ARCH_CPU\s0" 4
  125. The Debian cpu name of the host machine.
  126. .IP "\s-1DEB_HOST_ARCH_BITS\s0" 4
  127. The pointer size of the host machine (in bits).
  128. .IP "\s-1DEB_HOST_ARCH_ENDIAN\s0" 4
  129. The endianness of the host machine (little / big).
  130. .IP "\s-1DEB_HOST_GNU_CPU\s0" 4
  131. The \s-1CPU\s0 part of \s-1DEB_HOST_GNU_TYPE\s0.
  132. .IP "\s-1DEB_HOST_GNU_SYSTEM\s0" 4
  133. The System part of \s-1DEB_HOST_GNU_TYPE\s0.
  134. .IP "\s-1DEB_HOST_GNU_TYPE\s0" 4
  135. The \s-1GNU\s0 system type of the host machine.
  136. .IP "\s-1DEB_HOST_MULTIARCH\s0" 4
  137. The clarified \s-1GNU\s0 system type of the host machine, used for filesystem
  138. paths.
  139. .
  140. .SH "DEBIAN/RULES"
  141. The environment variables set by \fBdpkg\-architecture\fP are passed to
  142. \fIdebian/rules\fP as make variables (see make documentation). However,
  143. you should not rely on them, as this breaks manual invocation of the
  144. script. Instead, you should always initialize them using
  145. \fBdpkg\-architecture\fP with the \-q option. Here are some examples,
  146. which also show how you can improve the cross compilation support in your
  147. package:
  148. .PP
  149. Instead of:
  150. .IP
  151. .nf
  152. ARCH=\`dpkg \-\-print\-architecture\`
  153. configure $(\s-1ARCH\s0)\-linux
  154. .fi
  155. .PP
  156. please use the following:
  157. .IP
  158. .nf
  159. \&\s-1DEB_BUILD_GNU_TYPE\s0 := $(shell dpkg\-architecture \-qDEB_BUILD_GNU_TYPE)
  160. \&\s-1DEB_HOST_GNU_TYPE\s0 := $(shell dpkg\-architecture \-qDEB_HOST_GNU_TYPE)
  161. configure \-\-build=$(\s-1DEB_BUILD_GNU_TYPE\s0) \-\-host=$(\s-1DEB_HOST_GNU_TYPE\s0)
  162. .fi
  163. .PP
  164. Instead of:
  165. .IP
  166. .nf
  167. ARCH=\`dpkg \-\-print\-architecture\`
  168. ifeq ($(\s-1ARCH\s0),alpha)
  169. ...
  170. endif
  171. .fi
  172. .PP
  173. please use:
  174. .IP
  175. .nf
  176. \&\s-1DEB_HOST_ARCH\s0 := $(shell dpkg\-architecture \-qDEB_HOST_ARCH)
  177. ifeq ($(\s-1DEB_HOST_ARCH\s0),alpha)
  178. ...
  179. endif
  180. .fi
  181. .PP
  182. or if you only need to check the CPU or OS type, use the DEB_HOST_ARCH_CPU
  183. or DEB_HOST_ARCH_OS variables.
  184. .PP
  185. In general, calling dpkg in the rules file to get architecture information
  186. is deprecated (unless you want to provide backward compatibility, see below).
  187. Especially the \-\-print\-architecture option is unreliable since we have
  188. Debian architectures which don't equal a processor name.
  189. .
  190. .SH "BACKWARD COMPATIBILITY"
  191. The DEB_*_ARCH_BITS and DEB_*_ARCH_ENDIAN variables were introduced
  192. in dpkg\-dev 1.15.4. Using them in \fIdebian/rules\fR thus requires a
  193. build-dependency on dpkg\-dev (>= 1.15.4).
  194. .PP
  195. The DEB_HOST_ARCH_CPU and DEB_HOST_ARCH_OS variables were introduced
  196. in dpkg\-dev 1.13.2. Before this \fIdebian/rules\fR files tended to check
  197. the values of the DEB_HOST_GNU_CPU or DEB_HOST_GNU_TYPE variables which
  198. have been subject to change.
  199. .PP
  200. Where \fIdebian/rules\fR files check these variables to decide how or what
  201. to compile, this should be updated to use the new variables and values.
  202. You may wish to retain backwards compatibility with older version of
  203. dpkg\-dev by using the following code:
  204. .IP
  205. .nf
  206. DEB_HOST_ARCH_CPU := $(shell dpkg\-architecture \-qDEB_HOST_ARCH_CPU 2>/dev/null)
  207. DEB_HOST_ARCH_OS := $(shell dpkg\-architecture \-qDEB_HOST_ARCH_OS 2>/dev/null)
  208. # Take account of old dpkg\-architecture output.
  209. ifeq ($(DEB_HOST_ARCH_CPU),)
  210. DEB_HOST_ARCH_CPU := $(shell dpkg\-architecture \-qDEB_HOST_GNU_CPU)
  211. ifeq ($(DEB_HOST_ARCH_CPU),x86_64)
  212. DEB_HOST_ARCH_CPU := amd64
  213. endif
  214. endif
  215. ifeq ($(DEB_HOST_ARCH_OS),)
  216. DEB_HOST_ARCH_OS := $(subst \-gnu,,$(shell dpkg\-architecture \-qDEB_HOST_GNU_SYSTEM))
  217. ifeq ($(DEB_HOST_ARCH_OS),gnu)
  218. DEB_HOST_ARCH_OS := hurd
  219. endif
  220. endif
  221. .fi
  222. .PP
  223. And similarly for DEB_BUILD_ARCH_CPU and DEB_BUILD_ARCH_OS.
  224. .PP
  225. If you still wish to support versions of dpkg\-dev that did not include
  226. \fBdpkg\-architecture\fR, the following does the job:
  227. .IP
  228. .nf
  229. \&\s-1DEB_BUILD_ARCH\s0 := $(shell dpkg \-\-print\-architecture)
  230. \&\s-1DEB_BUILD_GNU_CPU\s0 := $(patsubst hurd\-%,%,$(\s-1DEB_BUILD_ARCH\s0))
  231. ifeq ($(filter\-out hurd\-%,$(\s-1DEB_BUILD_ARCH\s0)),)
  232. \s-1DEB_BUILD_GNU_SYSTEM\s0 := gnu
  233. else
  234. \s-1DEB_BUILD_GNU_SYSTEM\s0 := linux\-gnu
  235. endif
  236. DEB_BUILD_GNU_TYPE=$(\s-1DEB_BUILD_GNU_CPU\s0)\-$(\s-1DEB_BUILD_GNU_SYSTEM\s0)
  237. \&\s-1DEB_HOST_ARCH\s0 := $(\s-1DEB_BUILD_ARCH\s0)
  238. \&\s-1DEB_HOST_GNU_CPU\s0 := $(\s-1DEB_BUILD_GNU_CPU\s0)
  239. \&\s-1DEB_HOST_GNU_SYSTEM\s0 := $(\s-1DEB_BUILD_GNU_SYSTEM\s0)
  240. \&\s-1DEB_HOST_GNU_TYPE\s0 := $(\s-1DEB_BUILD_GNU_TYPE\s0)
  241. .fi
  242. .PP
  243. Put a subset of these lines at the top of your debian/rules file; these
  244. default values will be overwritten if dpkg\-architecture is used.
  245. .PP
  246. You don't need the full set. Choose a consistent set which contains the
  247. values you use in the rules file. For example, if you only need the host
  248. Debian architecture, `DEB_HOST_ARCH=\`dpkg \-\-print\-architecture\`'
  249. is sufficient (this is indeed the Debian architecture of the build machine,
  250. but remember that we are only trying to be backward compatible with native
  251. compilation).
  252. .PP
  253. The \fB\-e\fP and \fB\-i\fP options were only introduced in relatively recent
  254. versions of \fBdpkg\-architecture\fR (since dpkg 1.13.13).
  255. .
  256. .SH EXAMPLES
  257. \fBdpkg\-buildpackage\fP accepts the \fB\-a\fR option and passes it to
  258. \fBdpkg\-architecture\fP. Other examples:
  259. .IP
  260. CC=i386\-gnu\-gcc dpkg\-architecture \-c debian/rules build
  261. .IP
  262. eval \`dpkg\-architecture \-u\`
  263. .PP
  264. Check if an architecture is equal to the current architecture or a given
  265. one:
  266. .IP
  267. dpkg\-architecture \-elinux\-alpha
  268. .IP
  269. dpkg\-architecture \-amips \-elinux\-mips
  270. .PP
  271. Check if the current architecture or an architecture provided with \-a are
  272. Linux systems:
  273. .IP
  274. dpkg\-architecture \-ilinux\-any
  275. .IP
  276. dpkg\-architecture \-ai386 \-ilinux\-any
  277. .
  278. .SH FILES
  279. All these files have to be present for \fBdpkg\-architecture\fP to
  280. work. Their location can be overridden at runtime with the environment
  281. variable \fBDPKG_DATADIR\fP.
  282. .TP
  283. .I /usr/share/dpkg/cputable
  284. Table of known CPU names and mapping to their GNU name.
  285. .TP
  286. .I /usr/share/dpkg/ostable
  287. Table of known operating system names and mapping to their GNU name.
  288. .TP
  289. .I /usr/share/dpkg/triplettable
  290. Mapping between Debian architecture triplets and Debian architecture
  291. names.
  292. .
  293. .SH "SEE ALSO"
  294. .BR dpkg\-buildpackage (1),
  295. .BR dpkg\-cross (1).
  296. .
  297. .SH AUTHOR
  298. .B dpkg\-architecture
  299. and this man page were initially written by
  300. Marcus Brinkmann <brinkmd@debian.org>.