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