iphlpapi: Clean up memory allocation.
[wine/wine64.git] / tools / winebuild / winebuild.man.in
blob6c9bafcbdd5d66bbe1e6ab4a74652862ec6e1ccb
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 WinMain
77 for executables (if
78 .B WinMain
79 is not defined, the standard C
80 .B main
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 .BI \-f\  flags
89 Ignored for compatibility with the C compiler.
90 .TP
91 .BI \-F,\ --filename= filename
92 Set the file name of the module. The default is to use the base name
93 of the spec file (without any extension).
94 .TP
95 .B \-h, --help
96 Display a usage message and exit.
97 .TP
98 .BI \-H,\ --heap= size
99 Specify the size of the module local heap in bytes (only valid for
100 Win16 modules); default is no local heap.
102 .BI \-i,\ --ignore= [-]symbol[,[-]symbol]
103 Specify a list of symbols that should be ignored when resolving
104 undefined symbols against the imported libraries. This forces these
105 symbols to be resolved from the Unix C library (or from another Unix
106 library linked with the application). If a symbol is prefixed by '-'
107 it is removed from the list instead of being added; a stand-alone '-'
108 clears the whole list.
110 .BI \-I\  directory
111 Ignored for compatibility with the C compiler.
113 .B \-k, --kill-at
114 Remove the stdcall decorations from the symbol names in the
115 generated .def file. Only meaningful in \fB--def\fR mode.
117 .BI \-K\  flags
118 Ignored for compatibility with the C compiler.
120 .BI \--ld-cmd= ld-command
121 Specify the command to use to link the object files; the default is
122 \fBld\fR.
124 .BI \-L,\ --library-path= directory
125 Append the specified directory to the list of directories that are
126 searched for import libraries.
128 .BI \-l,\ --library= name
129 Import the specified library, looking for a corresponding
130 \fIlibname.def\fR file in the directories specified with the \fB-L\fR
131 option.
133 .BI \-M,\ --main-module= module
134 Specify that we are building a 16-bit dll, that will ultimately be
135 linked together with the 32-bit dll specified in \fImodule\fR.  Only
136 meaningful in \fB--dll\fR mode.
138 .BI \-N,\ --dll-name= dllname
139 Set the internal name of the module. It is only used in Win16
140 modules. The default is to use the base name of the spec file (without
141 any extension). This is used for KERNEL, since it lives in
142 KRNL386.EXE. It shouldn't be needed otherwise.
144 .BI \--nm-cmd= nm-command
145 Specify the command to use to get the list of undefined symbols; the
146 default is \fBnm\fR.
148 .BI \-o,\ --output= file
149 Set the name of the output file (default is standard output). If the
150 output file name end in \fB.o\fR, the text output is sent to a
151 temporary file that is then assembled to produce the specified .o
152 file.
154 .BI \-r,\ --res= rsrc.res
155 Load resources from the specified binary resource file. The
156 \fIrsrc.res\fR file can be produced from a source resource file with
157 .BR wrc(1)
158 (or with a Windows resource compiler).
160 This option is only necessary for Win16 resource files, the Win32 ones
161 can simply listed as
162 .I input files
163 and will automatically be handled correctly (though the
164 .B \-r
165 option will also work for Win32 files).
167 .B --save-temps
168 Do not delete the various temporary files that \fBwinebuild\fR generates.
170 .BI --subsystem= subsystem[:major[.minor]]
171 Set the subsystem of the executable, which can be one of the following:
173 .B console
174 for a command line executable,
176 .B windows
177 for a graphical executable,
179 .B native
180 for a native-mode dll.
182 The entry point of a command line executable is a normal C \fBmain\fR
183 function. A \fBwmain\fR function can be used instead if you need the
184 argument array to use Unicode strings. A graphical executable has a
185 \fBWinMain\fR entry point.
187 Optionally a major and minor subsystem version can also be specified;
188 the default subsystem version is 4.0.
190 .BI --target= cpu-manufacturer[-kernel]-os
191 Specify the target CPU and platform on which the generated code will
192 be built. The target specification is in the standard autoconf format
193 as returned by config.sub.
195 .BI \-u,\ --undefined= symbol
196 Add \fIsymbol\fR to the list of undefined symbols when invoking the
197 linker. This makes it possible to force a specific module of a static
198 library to be included when resolving imports.
200 .B \-v, --verbose
201 Display the various subcommands being invoked by
202 .B winebuild.
204 .B \--version
205 Display the program version and exit.
207 .B \-w, --warnings
208 Turn on warnings.
209 .SH "SPEC FILE SYNTAX"
210 .SS "General syntax"
211 A spec file should contain a list of ordinal declarations. The general
212 syntax is the following:
214 .I ordinal functype
215 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
217 .IB ordinal\  variable
218 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
220 .IB ordinal\  extern
221 .RI [ flags ]\  exportname \ [ symbolname ]
223 .IB ordinal\  stub
224 .RI [ flags ]\  exportname
226 .IB ordinal\  equate
227 .RI [ flags ]\  exportname\ data
229 .BI #\  comments
231 Declarations must fit on a single line, except if the end of line is
232 escaped using a backslash character. The
233 .B #
234 character anywhere in a line causes the rest of the line to be ignored
235 as a comment.
237 .I ordinal
238 specifies the ordinal number corresponding to the entry point, or '@'
239 for automatic ordinal allocation (Win32 only).
241 .I flags
242 is a series of optional flags, preceded by a '-' character. The
243 supported flags are:
246 .B -norelay
247 The entry point is not displayed in relay debugging traces (Win32
248 only).
250 .B -noname
251 The entry point will be imported by ordinal instead of by name.
253 .B -ret16
254 The function returns a 16-bit value (Win16 only).
256 .B -ret64
257 The function returns a 64-bit value (Win32 only).
259 .B -i386
260 The entry point is only available on i386 platforms.
262 .B -register
263 The function uses CPU register to pass arguments.
265 .B -private
266 The function cannot be imported from other dlls, it can only be
267 accessed through GetProcAddress.
268 .SS "Function ordinals"
269 Syntax:
271 .I ordinal functype
272 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
275 This declaration defines a function entry point.  The prototype defined by
276 .IR exportname \ \fB(\fR\ [ args... ] \ \fB)
277 specifies the name available for dynamic linking and the format of the
278 arguments. '@' can be used instead of
279 .I exportname
280 for ordinal-only exports.
282 .I functype
283 should be one of:
286 .B stdcall
287 for a normal Win32 function
289 .B pascal
290 for a normal Win16 function
292 .B cdecl
293 for a Win16 or Win32 function using the C calling convention
295 .B varargs
296 for a Win16 or Win32 function using the C calling convention with a
297 variable number of arguments
300 .I args
301 should be one or several of:
304 .B word
305 (16-bit unsigned value)
307 .B s_word
308 (16-bit signed word)
310 .B long
311 (32-bit value)
313 .B double
314 (64-bit value)
316 .B ptr
317 (linear pointer)
319 .B str
320 (linear pointer to a null-terminated ASCII string)
322 .B wstr
323 (linear pointer to a null-terminated Unicode string)
325 .B segptr
326 (segmented pointer)
328 .B segstr
329 (segmented pointer to a null-terminated ASCII string).
331 .RB Only\  ptr ,\  str ,\  wstr ,\  long\  and\  double
332 are valid for Win32 functions.
335 .I handler
336 is the name of the actual C function that will implement that entry
337 point in 32-bit mode. The handler can also be specified as
338 .IB dllname . function
339 to define a forwarded function (one whose implementation is in another
340 dll). If
341 .I handler
342 is not specified, it is assumed to be identical to
343 .I exportname.
345 This first example defines an entry point for the 32-bit GetFocus()
346 call:
348 @ stdcall GetFocus() GetFocus
350 This second example defines an entry point for the 16-bit
351 CreateWindow() call (the ordinal 100 is just an example); it also
352 shows how long lines can be split using a backslash:
354 100 pascal CreateWindow(ptr ptr long s_word s_word s_word \\
355     s_word word word word ptr) WIN_CreateWindow
357 To declare a function using a variable number of arguments, specify
358 the function as
359 .B varargs
360 and declare it in the C file with a '...' parameter for a Win32
361 function, or with an extra VA_LIST16 argument for a Win16 function.
362 See the wsprintf* functions in user.exe.spec and user32.spec for an
363 example.
364 .SS "Variable ordinals"
365 Syntax:
367 .IB ordinal\  variable
368 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
370 This declaration defines data storage as 32-bit words at the ordinal
371 specified.
372 .I exportname
373 will be the name available for dynamic
374 linking.
375 .I data
376 can be a decimal number or a hex number preceded by "0x".  The
377 following example defines the variable VariableA at ordinal 2 and
378 containing 4 ints:
380 2 variable VariableA(-1 0xff 0 0)
382 This declaration only works in Win16 spec files. In Win32 you should
384 .B extern
385 instead (see below).
386 .SS "Extern ordinals"
387 Syntax:
389 .IB ordinal\  extern
390 .RI [ flags ]\  exportname \ [ symbolname ]
392 This declaration defines an entry that simply maps to a C symbol
393 (variable or function). It only works in Win32 spec files.
394 .I exportname
395 will point to the symbol
396 .I symbolname
397 that must be defined in the C code. Alternatively, it can be of the
398 form
399 .IB dllname . symbolname
400 to define a forwarded symbol (one whose implementation is in another
401 dll). If
402 .I symbolname
403 is not specified, it is assumed to be identical to
404 .I exportname.
405 .SS "Stub ordinals"
406 Syntax:
408 .IB ordinal\  stub
409 .RI [ flags ]\  exportname
411 This declaration defines a stub function. It makes the name and
412 ordinal available for dynamic linking, but will terminate execution
413 with an error message if the function is ever called.
414 .SS "Equate ordinals"
415 Syntax:
417 .IB ordinal\  equate
418 .RI [ flags ]\  exportname\ data
420 This declaration defines an ordinal as an absolute value.
421 .I exportname
422 will be the name available for dynamic linking.
423 .I data
424 can be a decimal number or a hex number preceded by "0x".
425 .SH AUTHORS
426 .B winebuild
427 has been worked on by many people over the years. The main authors are
428 Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich
429 Weigand and Eric Youngdale. Many other Wine developers have
430 contributed, please check the file Changelog in the Wine distribution
431 for the complete details.
432 .SH BUGS
433 It is not yet possible to use a PE-format dll in an import
434 specification; only Wine dlls can be imported.
436 If you find a bug, please submit a bug report at
437 .UR http://bugs.winehq.org
438 .B http://bugs.winehq.org.
440 .SH AVAILABILITY
441 .B winebuild
442 is part of the wine distribution, which is available through WineHQ,
444 .B wine
445 development headquarters, at
446 .UR http://www.winehq.org/
447 .B http://www.winehq.org/.
449 .SH "SEE ALSO"
450 .BR wine (1),
451 .BR winegcc (1),
452 .BR wrc (1).