dpkg-architecture.1 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. .TH dpkg\-architecture 1 "2007-03-06" "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_GNU_TYPE\s0" 4
  109. The \s-1GNU\s0 system type of the build machine.
  110. .IP "\s-1DEB_BUILD_GNU_CPU\s0" 4
  111. The \s-1CPU\s0 part of \s-1DEB_BUILD_GNU_TYPE\s0
  112. .IP "\s-1DEB_BUILD_GNU_SYSTEM\s0" 4
  113. The System part of \s-1DEB_BUILD_GNU_TYPE\s0.
  114. .IP "\s-1DEB_HOST_ARCH\s0" 4
  115. The Debian architecture of the host machine.
  116. .IP "\s-1DEB_HOST_ARCH_OS\s0" 4
  117. The Debian system name of the host machine.
  118. .IP "\s-1DEB_HOST_ARCH_CPU\s0" 4
  119. The Debian cpu name of the host machine.
  120. .IP "\s-1DEB_HOST_GNU_TYPE\s0" 4
  121. The \s-1GNU\s0 system type of the host machine.
  122. .IP "\s-1DEB_HOST_GNU_CPU\s0" 4
  123. The \s-1CPU\s0 part of \s-1DEB_HOST_GNU_TYPE\s0.
  124. .IP "\s-1DEB_HOST_GNU_SYSTEM\s0" 4
  125. The System part of \s-1DEB_HOST_GNU_TYPE\s0.
  126. .
  127. .SH "DEBIAN/RULES"
  128. The environment variables set by \fBdpkg\-architecture\fP are passed to
  129. \fIdebian/rules\fP as make variables (see make documentation). However,
  130. you should not rely on them, as this breaks manual invocation of the
  131. script. Instead, you should always initialize them using
  132. \fBdpkg\-architecture\fP with the \-q option. Here are some examples,
  133. which also show how you can improve the cross compilation support in your
  134. package:
  135. .PP
  136. Instead of:
  137. .IP
  138. .nf
  139. ARCH=\`dpkg \-\-print\-architecture\`
  140. configure $(\s-1ARCH\s0)\-linux
  141. .fi
  142. .PP
  143. please use the following:
  144. .IP
  145. .nf
  146. \&\s-1DEB_BUILD_GNU_TYPE\s0 := $(shell dpkg\-architecture \-qDEB_BUILD_GNU_TYPE)
  147. \&\s-1DEB_HOST_GNU_TYPE\s0 := $(shell dpkg\-architecture \-qDEB_HOST_GNU_TYPE)
  148. configure \-\-build=$(\s-1DEB_BUILD_GNU_TYPE\s0) \-\-host=$(\s-1DEB_HOST_GNU_TYPE\s0)
  149. .fi
  150. .PP
  151. Instead of:
  152. .IP
  153. .nf
  154. ARCH=\`dpkg \-\-print\-architecture\`
  155. ifeq ($(\s-1ARCH\s0),alpha)
  156. ...
  157. endif
  158. .fi
  159. .PP
  160. please use:
  161. .IP
  162. .nf
  163. \&\s-1DEB_HOST_ARCH\s0 := $(shell dpkg\-architecture \-qDEB_HOST_ARCH)
  164. ifeq ($(\s-1DEB_HOST_ARCH\s0),alpha)
  165. ...
  166. endif
  167. .fi
  168. .PP
  169. or if you only need to check the CPU or OS type, use the DEB_HOST_ARCH_CPU
  170. or DEB_HOST_ARCH_OS variables.
  171. .PP
  172. In general, calling dpkg in the rules file to get architecture information
  173. is deprecated (unless you want to provide backward compatibility, see below).
  174. Especially the \-\-print\-architecture option is unreliable since we have
  175. Debian architectures which don't equal a processor name.
  176. .
  177. .SH "BACKWARD COMPATIBILITY"
  178. The DEB_HOST_ARCH_CPU and DEB_HOST_ARCH_OS variables were only introduced
  179. in relatively recent versions of \fBdpkg\-architecture\fR (since dpkg 1.13.2),
  180. before this \fIdebian/rules\fR files tended to check the values of the
  181. DEB_HOST_GNU_CPU or DEB_HOST_GNU_TYPE variables which have been subject
  182. to change.
  183. .PP
  184. Where \fIdebian/rules\fR files check these variables to decide how or what
  185. to compile, this should be updated to use the new variables and values.
  186. You may wish to retain backwards compatibility with older version of
  187. dpkg-dev by using the following code:
  188. .IP
  189. .nf
  190. DEB_HOST_ARCH_CPU := $(shell dpkg\-architecture \-qDEB_HOST_ARCH_CPU 2>/dev/null)
  191. DEB_HOST_ARCH_OS := $(shell dpkg\-architecture \-qDEB_HOST_ARCH_OS 2>/dev/null)
  192. # Take account of old dpkg\-architecture output.
  193. ifeq ($(DEB_HOST_ARCH_CPU),)
  194. DEB_HOST_ARCH_CPU := $(shell dpkg\-architecture \-qDEB_HOST_GNU_CPU)
  195. ifeq ($(DEB_HOST_ARCH_CPU),x86_64)
  196. DEB_HOST_ARCH_CPU := amd64
  197. endif
  198. endif
  199. ifeq ($(DEB_HOST_ARCH_OS),)
  200. DEB_HOST_ARCH_OS := $(subst \-gnu,,$(shell dpkg\-architecture \-qDEB_HOST_GNU_SYSTEM))
  201. ifeq ($(DEB_HOST_ARCH_OS),gnu)
  202. DEB_HOST_ARCH_OS := hurd
  203. endif
  204. endif
  205. .fi
  206. .PP
  207. And similarly for DEB_BUILD_ARCH_CPU and DEB_BUILD_ARCH_OS.
  208. .PP
  209. If you still wish to support versions of dpkg-dev that did not include
  210. \fBdpkg-architecture\fR, the following does the job:
  211. .IP
  212. .nf
  213. \&\s-1DEB_BUILD_ARCH\s0 := $(shell dpkg \-\-print\-architecture)
  214. \&\s-1DEB_BUILD_GNU_CPU\s0 := $(patsubst hurd\-%,%,$(\s-1DEB_BUILD_ARCH\s0))
  215. ifeq ($(filter\-out hurd\-%,$(\s-1DEB_BUILD_ARCH\s0)),)
  216. \s-1DEB_BUILD_GNU_SYSTEM\s0 := gnu
  217. else
  218. \s-1DEB_BUILD_GNU_SYSTEM\s0 := linux-gnu
  219. endif
  220. DEB_BUILD_GNU_TYPE=$(\s-1DEB_BUILD_GNU_CPU\s0)\-$(\s-1DEB_BUILD_GNU_SYSTEM\s0)
  221. \&\s-1DEB_HOST_ARCH\s0 := $(\s-1DEB_BUILD_ARCH\s0)
  222. \&\s-1DEB_HOST_GNU_CPU\s0 := $(\s-1DEB_BUILD_GNU_CPU\s0)
  223. \&\s-1DEB_HOST_GNU_SYSTEM\s0 := $(\s-1DEB_BUILD_GNU_SYSTEM\s0)
  224. \&\s-1DEB_HOST_GNU_TYPE\s0 := $(\s-1DEB_BUILD_GNU_TYPE\s0)
  225. .fi
  226. .PP
  227. Put a subset of these lines at the top of your debian/rules file; these
  228. default values will be overwritten if dpkg-architecture is used.
  229. .PP
  230. You don't need the full set. Choose a consistent set which contains the
  231. values you use in the rules file. For example, if you only need the host
  232. Debian architecture, `DEB_HOST_ARCH=\`dpkg \-\-print\-architecture\`'
  233. is sufficient (this is indeed the Debian architecture of the build machine,
  234. but remember that we are only trying to be backward compatible with native
  235. compilation).
  236. .PP
  237. The \fB\-e\fP and \fB\-i\fP options were only introduced in relatively recent
  238. versions of \fBdpkg\-architecture\fR (since dpkg 1.13.13).
  239. .
  240. .SH EXAMPLES
  241. \fBdpkg\-buildpackage\fP accepts the \fB\-a\fR option and passes it to
  242. \fBdpkg\-architecture\fP. Other examples:
  243. .IP
  244. CC=i386\-gnu\-gcc dpkg\-architecture \-c debian/rules build
  245. .IP
  246. eval \`dpkg\-architecture \-u\`
  247. .PP
  248. Check if an architecture is equal to the current architecture or a given
  249. one:
  250. .IP
  251. dpkg\-architecture \-elinux\-alpha
  252. .IP
  253. dpkg\-architecture \-amips \-elinux\-mips
  254. .PP
  255. Check if the current architecture or an architecture provided with \-a are
  256. Linux systems:
  257. .IP
  258. dpkg\-architecture \-ilinux\-any
  259. .IP
  260. dpkg\-architecture \-ai386 \-ilinux\-any
  261. .
  262. .SH FILES
  263. All these files have to be present for \fBdpkg-architecture\fP to
  264. work. Their location can be overriden at runtime with the environment
  265. variable DPKG_DATADIR.
  266. .TP
  267. .I /usr/share/dpkg/cputable
  268. Table of known CPU names and mapping to their GNU name.
  269. .TP
  270. .I /usr/share/dpkg/ostable
  271. Table of known operating system names and mapping to their GNU name.
  272. .TP
  273. .I /usr/share/dpkg/triplettable
  274. Mapping between Debian architecture triplets and Debian architecture
  275. names.
  276. .
  277. .SH "SEE ALSO"
  278. .BR dpkg\-buildpackage (1),
  279. .BR dpkg\-cross (1).
  280. .
  281. .SH AUTHOR
  282. .B dpkg\-architecture
  283. and this man page were initially written by
  284. Marcus Brinkmann <brinkmd@debian.org>.