winebuild.man.in 18 KB

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