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