dpkg-architecture.1 10 KB

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