winebuild.man.in 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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 --syscall-table= id
  259. Set the system call table id, between 0 and 3. The default is 0, the
  260. ntdll syscall table. Only useful in modules that define syscall entry
  261. points.
  262. .TP
  263. .BI \-u,\ --undefined= symbol
  264. Add \fIsymbol\fR to the list of undefined symbols when invoking the
  265. linker. This makes it possible to force a specific module of a static
  266. library to be included when resolving imports.
  267. .TP
  268. .B \-v, --verbose
  269. Display the various subcommands being invoked by
  270. .BR winebuild .
  271. .TP
  272. .B \--version
  273. Display the program version and exit.
  274. .TP
  275. .B \-w, --warnings
  276. Turn on warnings.
  277. .SH "SPEC FILE SYNTAX"
  278. .SS "General syntax"
  279. A spec file should contain a list of ordinal declarations. The general
  280. syntax is the following:
  281. .PP
  282. .I ordinal functype
  283. .RI [ flags ]\ exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
  284. .br
  285. .IB ordinal\ variable
  286. .RI [ flags ]\ exportname \ \fB(\fR\ [ data... ] \ \fB)
  287. .br
  288. .IB ordinal\ extern
  289. .RI [ flags ]\ exportname \ [ symbolname ]
  290. .br
  291. .IB ordinal\ stub
  292. .RI [ flags ]\ exportname \ [\ \fB( args... \fB)\fR\ ]
  293. .br
  294. .IB ordinal\ equate
  295. .RI [ flags ]\ exportname\ data
  296. .br
  297. .BI #\ comments
  298. .PP
  299. Declarations must fit on a single line, except if the end of line is
  300. escaped using a backslash character. The
  301. .B #
  302. character anywhere in a line causes the rest of the line to be ignored
  303. as a comment.
  304. .PP
  305. .I ordinal
  306. specifies the ordinal number corresponding to the entry point, or '@'
  307. for automatic ordinal allocation (Win32 only).
  308. .PP
  309. .I flags
  310. is a series of optional flags, preceded by a '-' character. The
  311. supported flags are:
  312. .RS
  313. .TP
  314. .B -norelay
  315. The entry point is not displayed in relay debugging traces (Win32
  316. only).
  317. .TP
  318. .B -noname
  319. The entry point will be exported by ordinal instead of by name. The
  320. name is still available for importing.
  321. .TP
  322. .B -ret16
  323. The function returns a 16-bit value (Win16 only).
  324. .TP
  325. .B -ret64
  326. The function returns a 64-bit value (Win32 only).
  327. .TP
  328. .B -register
  329. The function uses CPU register to pass arguments.
  330. .TP
  331. .B -private
  332. The function cannot be imported from other dlls, it can only be
  333. accessed through GetProcAddress.
  334. .TP
  335. .B -ordinal
  336. The entry point will be imported by ordinal instead of by name. The
  337. name is still exported.
  338. .TP
  339. .B -thiscall
  340. The function uses the
  341. .I thiscall
  342. calling convention (first parameter in %ecx register on i386).
  343. .TP
  344. .B -fastcall
  345. The function uses the
  346. .I fastcall
  347. calling convention (first two parameters in %ecx/%edx registers on
  348. i386).
  349. .TP
  350. .B -syscall
  351. The function is an NT system call. A system call thunk will be
  352. generated, and the actual function will be called by the
  353. \fI__wine_syscall_dispatcher\fR function that will be generated on the
  354. Unix library side.
  355. .TP
  356. .B -import
  357. The function is imported from another module. This can be used instead
  358. of a
  359. .I forward
  360. specification when an application expects to find the function's
  361. implementation inside the dll.
  362. .TP
  363. .B -arch=\fR[\fB!\fR]\fIcpu\fR[\fB,\fIcpu\fR]
  364. The entry point is only available on the specified CPU
  365. architecture(s). The names \fBwin32\fR and \fBwin64\fR match all
  366. 32-bit or 64-bit CPU architectures respectively. In 16-bit dlls,
  367. specifying \fB-arch=win32\fR causes the entry point to be exported
  368. from the 32-bit wrapper module. A CPU name can be prefixed with
  369. \fB!\fR to exclude only that specific architecture.
  370. .RE
  371. .SS "Function ordinals"
  372. Syntax:
  373. .br
  374. .I ordinal functype
  375. .RI [ flags ]\ exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
  376. .br
  377. This declaration defines a function entry point. The prototype defined by
  378. .IR exportname \ \fB(\fR\ [ args... ] \ \fB)
  379. specifies the name available for dynamic linking and the format of the
  380. arguments. '@' can be used instead of
  381. .I exportname
  382. for ordinal-only exports.
  383. .PP
  384. .I functype
  385. should be one of:
  386. .RS
  387. .TP
  388. .B stdcall
  389. for a normal Win32 function
  390. .TP
  391. .B pascal
  392. for a normal Win16 function
  393. .TP
  394. .B cdecl
  395. for a Win16 or Win32 function using the C calling convention
  396. .TP
  397. .B varargs
  398. for a Win16 or Win32 function using the C calling convention with a
  399. variable number of arguments
  400. .RE
  401. .PP
  402. .I args
  403. should be one or several of:
  404. .RS
  405. .TP
  406. .B word
  407. (16-bit unsigned value)
  408. .TP
  409. .B s_word
  410. (16-bit signed word)
  411. .TP
  412. .B long
  413. (pointer-sized integer value)
  414. .TP
  415. .B int64
  416. (64-bit integer value)
  417. .TP
  418. .B int128
  419. (128-bit integer value)
  420. .TP
  421. .B float
  422. (32-bit floating point value)
  423. .TP
  424. .B double
  425. (64-bit floating point value)
  426. .TP
  427. .B ptr
  428. (linear pointer)
  429. .TP
  430. .B str
  431. (linear pointer to a null-terminated ASCII string)
  432. .TP
  433. .B wstr
  434. (linear pointer to a null-terminated Unicode string)
  435. .TP
  436. .B segptr
  437. (segmented pointer)
  438. .TP
  439. .B segstr
  440. (segmented pointer to a null-terminated ASCII string).
  441. .HP
  442. Note: The 16-bit and segmented pointer types are only valid for Win16
  443. functions.
  444. .RE
  445. .PP
  446. .I handler
  447. is the name of the actual C function that will implement that entry
  448. point in 32-bit mode. The handler can also be specified as
  449. .IB dllname . function
  450. to define a forwarded function (one whose implementation is in another
  451. dll). If
  452. .I handler
  453. is not specified, it is assumed to be identical to
  454. .I exportname.
  455. .PP
  456. This first example defines an entry point for the 32-bit GetFocus()
  457. call:
  458. .IP
  459. @ stdcall GetFocus() GetFocus
  460. .PP
  461. This second example defines an entry point for the 16-bit
  462. CreateWindow() call (the ordinal 100 is just an example); it also
  463. shows how long lines can be split using a backslash:
  464. .IP
  465. 100 pascal CreateWindow(ptr ptr long s_word s_word s_word \\
  466. s_word word word word ptr) WIN_CreateWindow
  467. .PP
  468. To declare a function using a variable number of arguments, specify
  469. the function as
  470. .B varargs
  471. and declare it in the C file with a '...' parameter for a Win32
  472. function, or with an extra VA_LIST16 argument for a Win16 function.
  473. See the wsprintf* functions in user.exe.spec and user32.spec for an
  474. example.
  475. .SS "Variable ordinals"
  476. Syntax:
  477. .br
  478. .IB ordinal\ variable
  479. .RI [ flags ]\ exportname \ \fB(\fR\ [ data... ] \ \fB)
  480. .PP
  481. This declaration defines data storage as 32-bit words at the ordinal
  482. specified.
  483. .I exportname
  484. will be the name available for dynamic
  485. linking.
  486. .I data
  487. can be a decimal number or a hex number preceded by "0x". The
  488. following example defines the variable VariableA at ordinal 2 and
  489. containing 4 ints:
  490. .IP
  491. 2 variable VariableA(-1 0xff 0 0)
  492. .PP
  493. This declaration only works in Win16 spec files. In Win32 you should
  494. use
  495. .B extern
  496. instead (see below).
  497. .SS "Extern ordinals"
  498. Syntax:
  499. .br
  500. .IB ordinal\ extern
  501. .RI [ flags ]\ exportname \ [ symbolname ]
  502. .PP
  503. This declaration defines an entry that simply maps to a C symbol
  504. (variable or function). It only works in Win32 spec files.
  505. .I exportname
  506. will point to the symbol
  507. .I symbolname
  508. that must be defined in the C code. Alternatively, it can be of the
  509. form
  510. .IB dllname . symbolname
  511. to define a forwarded symbol (one whose implementation is in another
  512. dll). If
  513. .I symbolname
  514. is not specified, it is assumed to be identical to
  515. .I exportname.
  516. .SS "Stub ordinals"
  517. Syntax:
  518. .br
  519. .IB ordinal\ stub
  520. .RI [ flags ]\ exportname \ [\ \fB( args... \fB)\fR\ ]
  521. .PP
  522. This declaration defines a stub function. It makes the name and
  523. ordinal available for dynamic linking, but will terminate execution
  524. with an error message if the function is ever called.
  525. .SS "Equate ordinals"
  526. Syntax:
  527. .br
  528. .IB ordinal\ equate
  529. .RI [ flags ]\ exportname\ data
  530. .PP
  531. This declaration defines an ordinal as an absolute value.
  532. .I exportname
  533. will be the name available for dynamic linking.
  534. .I data
  535. can be a decimal number or a hex number preceded by "0x".
  536. .SH AUTHORS
  537. .B winebuild
  538. has been worked on by many people over the years. The main authors are
  539. Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich
  540. Weigand and Eric Youngdale. Many other people have contributed new features
  541. and bug fixes. For a complete list, see the git commit logs.
  542. .SH BUGS
  543. It is not yet possible to use a PE-format dll in an import
  544. specification; only Wine dlls can be imported.
  545. .PP
  546. Bugs can be reported on the
  547. .UR https://bugs.winehq.org
  548. .B Wine bug tracker
  549. .UE .
  550. .SH AVAILABILITY
  551. .B winebuild
  552. is part of the Wine distribution, which is available through WineHQ,
  553. the
  554. .UR https://www.winehq.org/
  555. .B Wine development headquarters
  556. .UE .
  557. .SH "SEE ALSO"
  558. .BR wine (1),
  559. .BR winegcc (1),
  560. .BR wrc (1),
  561. .br
  562. .UR https://www.winehq.org/help
  563. .B Wine documentation and support
  564. .UE .