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