winebuild.man.in 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. .TH WINEBUILD 1 "October 2005" "@PACKAGE_STRING@" "Wine Developers Manual"
  2. .SH NAME
  3. winebuild \- Wine dll builder
  4. .SH SYNOPSIS
  5. .B winebuild
  6. .RI [ options ]\ [ inputfile ...]
  7. .SH DESCRIPTION
  8. .B winebuild
  9. generates the assembly files that are necessary to build a Wine dll,
  10. which is basically a Win32 dll encapsulated inside a Unix library.
  11. .PP
  12. .B winebuild
  13. has different modes, depending on what kind of file it is asked to
  14. generate. The mode is specified by one of the mode options specified
  15. below. In addition to the mode option, various other command-line
  16. option can be specified, as described in the \fBOPTIONS\fR section.
  17. .SH "MODE OPTIONS"
  18. You have to specify exactly one of the following options, depending on
  19. what you want winebuild to generate.
  20. .TP
  21. .BI \--dll
  22. Build an assembly file from a .spec file (see \fBSPEC FILE SYNTAX\fR
  23. for details), or from a standard Windows .def file. The .spec/.def
  24. file is specified via the \fB-E\fR option. The resulting file must be
  25. assembled and linked to the other object files to build a working Wine
  26. dll. In this mode, the
  27. .I input files
  28. should be the list of all object files that will be linked into the
  29. final dll, to allow
  30. .B winebuild
  31. to get the list of all undefined symbols that need to be imported from
  32. other dlls.
  33. .TP
  34. .BI \--exe
  35. Build an assembly file for an executable. This is basically the same as
  36. the \fB--dll\fR mode except that it doesn't require a .spec/.def file as input,
  37. since an executable need not export functions. Some executables however
  38. do export functions, and for those a .spec/.def file can be specified via
  39. the \fB-E\fR option. The executable is named from the .spec/.def file name if
  40. present, or explicitly through the \fB-F\fR option. The resulting file must be
  41. assembled and linked to the other object files to build a working Wine
  42. executable, and all the other object files must be listed as
  43. .I input files.
  44. .TP
  45. .BI \--def
  46. Build a .def file from a spec file. The .spec file is specified via the
  47. \fB-E\fR option. This is used when building dlls with a PE (Win32) compiler.
  48. .TP
  49. .BI \--implib
  50. Build a .a import library from a spec file. The .spec file is
  51. specified via the \fB-E\fR option. If the output library name ends
  52. in .delay.a, a delayed import library is built.
  53. .TP
  54. .BI \--staticlib
  55. Build a .a static library from object files.
  56. .TP
  57. .B \--resources
  58. Generate a .o file containing all the input resources. This is useful
  59. when building with a PE compiler, since the PE binutils cannot handle
  60. multiple resource files as input. For a standard Unix build, the
  61. resource files are automatically included when building the spec file,
  62. so there's no need for an intermediate .o file.
  63. .TP
  64. .BI \--builtin
  65. Mark a PE module as a Wine builtin module, by adding the "Wine builtin
  66. DLL" signature string after the DOS header.
  67. .TP
  68. .BI \--fixup-ctors
  69. Fixup constructors after a module has been built. This should be done
  70. on the final .so module if its code contains constructors, to ensure
  71. that Wine has a chance to initialize the module before the
  72. constructors are executed.
  73. .SH OPTIONS
  74. .TP
  75. .BI \--as-cmd= as-command
  76. Specify the command to use to compile assembly files; the default is
  77. \fBas\fR.
  78. .TP
  79. .BI \-b,\ --target= cpu-manufacturer\fR[\fB-\fIkernel\fR]\fB-\fIos
  80. Specify the target CPU and platform on which the generated code will
  81. be built. The target specification is in the standard autoconf format
  82. as returned by config.sub.
  83. .TP
  84. .BI \-B\ directory
  85. Add the directory to the search path for the various binutils tools
  86. like \fBas\fR, \fBnm\fR and \fBld\fR.
  87. .TP
  88. .BI \--cc-cmd= cc-command
  89. Specify the C compiler to use to compile assembly files; the default
  90. is to instead use the assembler specified with \fB--as-cmd\fR.
  91. .TP
  92. .BI \-d,\ --delay-lib= name
  93. Set the delayed import mode for the specified library, which must be
  94. one of the libraries imported with the \fB-l\fR option. Delayed mode
  95. means that the library won't be loaded until a function imported from
  96. it is actually called.
  97. .TP
  98. .BI \-D\ symbol
  99. Ignored for compatibility with the C compiler.
  100. .TP
  101. .BI \-e,\ --entry= function
  102. Specify the module entry point function; if not specified, the default
  103. is
  104. .B DllMain
  105. for dlls, and
  106. .B main
  107. for executables (if the standard C
  108. .B main
  109. is not defined,
  110. .B WinMain
  111. is used instead). This is only valid for Win32 modules.
  112. .TP
  113. .BI \-E,\ --export= filename
  114. Specify a .spec file (see \fBSPEC FILE SYNTAX\fR for details),
  115. or a standard Windows .def file that defines the exports
  116. of the DLL or executable that is being built.
  117. .TP
  118. .B \--external-symbols
  119. Allow linking to external symbols directly from the spec
  120. file. Normally symbols exported by a dll have to be defined in the dll
  121. itself; this option makes it possible to use symbols defined in
  122. another Unix library (for symbols defined in another dll, a
  123. .I forward
  124. specification must be used instead).
  125. .TP
  126. .BI \-f\ option
  127. Specify a code generation option. Currently \fB\-fPIC\fR and
  128. \fB\-fasynchronous-unwind-tables\fR are supported. Other options are
  129. ignored for compatibility with the C compiler.
  130. .TP
  131. .B \--fake-module
  132. Create a fake PE module for a dll or exe, instead of the normal
  133. assembly or object file. The PE module contains the resources for the
  134. module, but no executable code.
  135. .TP
  136. .BI \-F,\ --filename= filename
  137. Set the file name of the module. The default is to use the base name
  138. of the spec file (without any extension).
  139. .TP
  140. .B \-h, --help
  141. Display a usage message and exit.
  142. .TP
  143. .BI \-H,\ --heap= size
  144. Specify the size of the module local heap in bytes (only valid for
  145. Win16 modules); default is no local heap.
  146. .TP
  147. .BI \-I\ directory
  148. Ignored for compatibility with the C compiler.
  149. .TP
  150. .B \-k, --kill-at
  151. Remove the stdcall decorations from the symbol names in the
  152. generated .def file. Only meaningful in \fB--def\fR mode.
  153. .TP
  154. .BI \-K\ flags
  155. Ignored for compatibility with the C compiler.
  156. .TP
  157. .BI \--large-address-aware
  158. Set a flag in the executable to notify the loader that this
  159. application supports address spaces larger than 2 gigabytes.
  160. .TP
  161. .BI \--ld-cmd= ld-command
  162. Specify the command to use to link the object files; the default is
  163. \fBld\fR.
  164. .TP
  165. .BI \-L,\ --library-path= directory
  166. Append the specified directory to the list of directories that are
  167. searched for import libraries.
  168. .TP
  169. .BI \-l,\ --library= name
  170. Import the specified library, looking for a corresponding
  171. \fIlibname.def\fR file in the directories specified with the \fB-L\fR
  172. option.
  173. .TP
  174. .B \-m16, -m32, -m64
  175. Generate respectively 16-bit, 32-bit or 64-bit code.
  176. .TP
  177. .BI \-marm,\ \-mthumb,\ \-march= option ,\ \-mcpu= option ,\ \-mfpu= option ,\ \-mfloat-abi= option
  178. Set code generation options for the assembler.
  179. .TP
  180. .B \-mno-cygwin
  181. Build a library that uses the Windows runtime instead of the Unix C
  182. library.
  183. .TP
  184. .B \-munix
  185. Build the Unix counterpart of a builtin module.
  186. .TP
  187. .BI \-M,\ --main-module= module
  188. When building a 16-bit dll, set the name of its 32-bit counterpart to
  189. \fImodule\fR. This is used to enforce that the load order for the
  190. 16-bit dll matches that of the 32-bit one.
  191. .TP
  192. .BI \-N,\ --dll-name= dllname
  193. Set the internal name of the module. It is only used in Win16
  194. modules. The default is to use the base name of the spec file (without
  195. any extension). This is used for KERNEL, since it lives in
  196. KRNL386.EXE. It shouldn't be needed otherwise.
  197. .TP
  198. .BI \--nm-cmd= nm-command
  199. Specify the command to use to get the list of undefined symbols; the
  200. default is \fBnm\fR.
  201. .TP
  202. .BI --nxcompat= yes\fR|\fIno
  203. Specify whether the module is compatible with no-exec support. The
  204. default is yes.
  205. .TP
  206. .BI \-o,\ --output= file
  207. Set the name of the output file (default is standard output). If the
  208. output file name ends in .o, the text output is sent to a
  209. temporary file that is then assembled to produce the specified .o
  210. file.
  211. .TP
  212. .B --prefer-native
  213. Specify that the native DLL should be preferred if available at run
  214. time. This can be used on modules that are mostly unimplemented.
  215. .TP
  216. .BI \-r,\ --res= rsrc.res
  217. Load resources from the specified binary resource file. The
  218. \fIrsrc.res\fR file can be produced from a source resource file with
  219. .BR wrc (1)
  220. (or with a Windows resource compiler).
  221. .br
  222. This option is only necessary for Win16 resource files, the Win32 ones
  223. can simply listed as
  224. .I input files
  225. and will automatically be handled correctly (though the
  226. .B \-r
  227. option will also work for Win32 files).
  228. .TP
  229. .B --safeseh
  230. Mark object files as SEH compatible.
  231. .TP
  232. .B --save-temps
  233. Do not delete the various temporary files that \fBwinebuild\fR generates.
  234. .TP
  235. .BI --subsystem= subsystem\fR[\fB:\fImajor\fR[\fB.\fIminor\fR]]
  236. Set the subsystem of the executable, which can be one of the following:
  237. .br
  238. .B console
  239. for a command line executable,
  240. .br
  241. .B windows
  242. for a graphical executable,
  243. .br
  244. .B native
  245. for a native-mode dll,
  246. .br
  247. .B wince
  248. for a ce dll.
  249. .br
  250. The entry point of a command line executable is a normal C \fBmain\fR
  251. function. A \fBwmain\fR function can be used instead if you need the
  252. argument array to use Unicode strings. A graphical executable has a
  253. \fBWinMain\fR entry point.
  254. .br
  255. Optionally a major and minor subsystem version can also be specified;
  256. the default subsystem version is 4.0.
  257. .TP
  258. .BI \-u,\ --undefined= symbol
  259. Add \fIsymbol\fR to the list of undefined symbols when invoking the
  260. linker. This makes it possible to force a specific module of a static
  261. library to be included when resolving imports.
  262. .TP
  263. .B \-v, --verbose
  264. Display the various subcommands being invoked by
  265. .BR winebuild .
  266. .TP
  267. .B \--version
  268. Display the program version and exit.
  269. .TP
  270. .B \-w, --warnings
  271. Turn on warnings.
  272. .SH "SPEC FILE SYNTAX"
  273. .SS "General syntax"
  274. A spec file should contain a list of ordinal declarations. The general
  275. syntax is the following:
  276. .PP
  277. .I ordinal functype
  278. .RI [ flags ]\ exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
  279. .br
  280. .IB ordinal\ variable
  281. .RI [ flags ]\ exportname \ \fB(\fR\ [ data... ] \ \fB)
  282. .br
  283. .IB ordinal\ extern
  284. .RI [ flags ]\ exportname \ [ symbolname ]
  285. .br
  286. .IB ordinal\ stub
  287. .RI [ flags ]\ exportname \ [\ \fB( args... \fB)\fR\ ]
  288. .br
  289. .IB ordinal\ equate
  290. .RI [ flags ]\ exportname\ data
  291. .br
  292. .BI #\ comments
  293. .PP
  294. Declarations must fit on a single line, except if the end of line is
  295. escaped using a backslash character. The
  296. .B #
  297. character anywhere in a line causes the rest of the line to be ignored
  298. as a comment.
  299. .PP
  300. .I ordinal
  301. specifies the ordinal number corresponding to the entry point, or '@'
  302. for automatic ordinal allocation (Win32 only).
  303. .PP
  304. .I flags
  305. is a series of optional flags, preceded by a '-' character. The
  306. supported flags are:
  307. .RS
  308. .TP
  309. .B -norelay
  310. The entry point is not displayed in relay debugging traces (Win32
  311. only).
  312. .TP
  313. .B -noname
  314. The entry point will be exported by ordinal instead of by name. The
  315. name is still available for importing.
  316. .TP
  317. .B -ret16
  318. The function returns a 16-bit value (Win16 only).
  319. .TP
  320. .B -ret64
  321. The function returns a 64-bit value (Win32 only).
  322. .TP
  323. .B -register
  324. The function uses CPU register to pass arguments.
  325. .TP
  326. .B -private
  327. The function cannot be imported from other dlls, it can only be
  328. accessed through GetProcAddress.
  329. .TP
  330. .B -ordinal
  331. The entry point will be imported by ordinal instead of by name. The
  332. name is still exported.
  333. .TP
  334. .B -thiscall
  335. The function uses the
  336. .I thiscall
  337. calling convention (first parameter in %ecx register on i386).
  338. .TP
  339. .B -fastcall
  340. The function uses the
  341. .I fastcall
  342. calling convention (first two parameters in %ecx/%edx registers on
  343. i386).
  344. .TP
  345. .B -syscall
  346. The function is an NT system call. A system call thunk will be
  347. generated, and the actual function will be called by the
  348. \fI__wine_syscall_dispatcher\fR function that will be generated on the
  349. Unix library side.
  350. .TP
  351. .B -import
  352. The function is imported from another module. This can be used instead
  353. of a
  354. .I forward
  355. specification when an application expects to find the function's
  356. implementation inside the dll.
  357. .TP
  358. .B -arch=\fR[\fB!\fR]\fIcpu\fR[\fB,\fIcpu\fR]
  359. The entry point is only available on the specified CPU
  360. architecture(s). The names \fBwin32\fR and \fBwin64\fR match all
  361. 32-bit or 64-bit CPU architectures respectively. In 16-bit dlls,
  362. specifying \fB-arch=win32\fR causes the entry point to be exported
  363. from the 32-bit wrapper module. A CPU name can be prefixed with
  364. \fB!\fR to exclude only that specific architecture.
  365. .RE
  366. .SS "Function ordinals"
  367. Syntax:
  368. .br
  369. .I ordinal functype
  370. .RI [ flags ]\ exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
  371. .br
  372. This declaration defines a function entry point. The prototype defined by
  373. .IR exportname \ \fB(\fR\ [ args... ] \ \fB)
  374. specifies the name available for dynamic linking and the format of the
  375. arguments. '@' can be used instead of
  376. .I exportname
  377. for ordinal-only exports.
  378. .PP
  379. .I functype
  380. should be one of:
  381. .RS
  382. .TP
  383. .B stdcall
  384. for a normal Win32 function
  385. .TP
  386. .B pascal
  387. for a normal Win16 function
  388. .TP
  389. .B cdecl
  390. for a Win16 or Win32 function using the C calling convention
  391. .TP
  392. .B varargs
  393. for a Win16 or Win32 function using the C calling convention with a
  394. variable number of arguments
  395. .RE
  396. .PP
  397. .I args
  398. should be one or several of:
  399. .RS
  400. .TP
  401. .B word
  402. (16-bit unsigned value)
  403. .TP
  404. .B s_word
  405. (16-bit signed word)
  406. .TP
  407. .B long
  408. (pointer-sized integer value)
  409. .TP
  410. .B int64
  411. (64-bit integer value)
  412. .TP
  413. .B int128
  414. (128-bit integer value)
  415. .TP
  416. .B float
  417. (32-bit floating point value)
  418. .TP
  419. .B double
  420. (64-bit floating point value)
  421. .TP
  422. .B ptr
  423. (linear pointer)
  424. .TP
  425. .B str
  426. (linear pointer to a null-terminated ASCII string)
  427. .TP
  428. .B wstr
  429. (linear pointer to a null-terminated Unicode string)
  430. .TP
  431. .B segptr
  432. (segmented pointer)
  433. .TP
  434. .B segstr
  435. (segmented pointer to a null-terminated ASCII string).
  436. .HP
  437. Note: The 16-bit and segmented pointer types are only valid for Win16
  438. functions.
  439. .RE
  440. .PP
  441. .I handler
  442. is the name of the actual C function that will implement that entry
  443. point in 32-bit mode. The handler can also be specified as
  444. .IB dllname . function
  445. to define a forwarded function (one whose implementation is in another
  446. dll). If
  447. .I handler
  448. is not specified, it is assumed to be identical to
  449. .I exportname.
  450. .PP
  451. This first example defines an entry point for the 32-bit GetFocus()
  452. call:
  453. .IP
  454. @ stdcall GetFocus() GetFocus
  455. .PP
  456. This second example defines an entry point for the 16-bit
  457. CreateWindow() call (the ordinal 100 is just an example); it also
  458. shows how long lines can be split using a backslash:
  459. .IP
  460. 100 pascal CreateWindow(ptr ptr long s_word s_word s_word \\
  461. s_word word word word ptr) WIN_CreateWindow
  462. .PP
  463. To declare a function using a variable number of arguments, specify
  464. the function as
  465. .B varargs
  466. and declare it in the C file with a '...' parameter for a Win32
  467. function, or with an extra VA_LIST16 argument for a Win16 function.
  468. See the wsprintf* functions in user.exe.spec and user32.spec for an
  469. example.
  470. .SS "Variable ordinals"
  471. Syntax:
  472. .br
  473. .IB ordinal\ variable
  474. .RI [ flags ]\ exportname \ \fB(\fR\ [ data... ] \ \fB)
  475. .PP
  476. This declaration defines data storage as 32-bit words at the ordinal
  477. specified.
  478. .I exportname
  479. will be the name available for dynamic
  480. linking.
  481. .I data
  482. can be a decimal number or a hex number preceded by "0x". The
  483. following example defines the variable VariableA at ordinal 2 and
  484. containing 4 ints:
  485. .IP
  486. 2 variable VariableA(-1 0xff 0 0)
  487. .PP
  488. This declaration only works in Win16 spec files. In Win32 you should
  489. use
  490. .B extern
  491. instead (see below).
  492. .SS "Extern ordinals"
  493. Syntax:
  494. .br
  495. .IB ordinal\ extern
  496. .RI [ flags ]\ exportname \ [ symbolname ]
  497. .PP
  498. This declaration defines an entry that simply maps to a C symbol
  499. (variable or function). It only works in Win32 spec files.
  500. .I exportname
  501. will point to the symbol
  502. .I symbolname
  503. that must be defined in the C code. Alternatively, it can be of the
  504. form
  505. .IB dllname . symbolname
  506. to define a forwarded symbol (one whose implementation is in another
  507. dll). If
  508. .I symbolname
  509. is not specified, it is assumed to be identical to
  510. .I exportname.
  511. .SS "Stub ordinals"
  512. Syntax:
  513. .br
  514. .IB ordinal\ stub
  515. .RI [ flags ]\ exportname \ [\ \fB( args... \fB)\fR\ ]
  516. .PP
  517. This declaration defines a stub function. It makes the name and
  518. ordinal available for dynamic linking, but will terminate execution
  519. with an error message if the function is ever called.
  520. .SS "Equate ordinals"
  521. Syntax:
  522. .br
  523. .IB ordinal\ equate
  524. .RI [ flags ]\ exportname\ data
  525. .PP
  526. This declaration defines an ordinal as an absolute value.
  527. .I exportname
  528. will be the name available for dynamic linking.
  529. .I data
  530. can be a decimal number or a hex number preceded by "0x".
  531. .SH AUTHORS
  532. .B winebuild
  533. has been worked on by many people over the years. The main authors are
  534. Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich
  535. Weigand and Eric Youngdale. Many other people have contributed new features
  536. and bug fixes. For a complete list, see the git commit logs.
  537. .SH BUGS
  538. It is not yet possible to use a PE-format dll in an import
  539. specification; only Wine dlls can be imported.
  540. .PP
  541. Bugs can be reported on the
  542. .UR https://bugs.winehq.org
  543. .B Wine bug tracker
  544. .UE .
  545. .SH AVAILABILITY
  546. .B winebuild
  547. is part of the Wine distribution, which is available through WineHQ,
  548. the
  549. .UR https://www.winehq.org/
  550. .B Wine development headquarters
  551. .UE .
  552. .SH "SEE ALSO"
  553. .BR wine (1),
  554. .BR winegcc (1),
  555. .BR wrc (1),
  556. .br
  557. .UR https://www.winehq.org/help
  558. .B Wine documentation and support
  559. .UE .