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