Automatically detect whether the entry point is main or WinMain
[wine.git] / tools / winebuild / winebuild.man.in
blobde9a79255c1b09954240d8732979f3a1444f5ecb
1 .\" -*- nroff -*-
2 .TH WINEBUILD 1 "March 2003" "@PACKAGE_STRING@" "Wine dll builder"
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 C and assembly files that are necessary to build a Wine
10 dll, which is basically a Win32 dll encapsulated inside a Unix
11 library.
12 .PP
13 .B winebuild
14 has different modes, depending on what kind of file it is asked to
15 generate. The mode is specified by one of the mode options specified
16 below. In addition to the mode option, various other command-line
17 option can be specified, as described in the \fBOPTIONS\fR section.
18 .SH "MODE OPTIONS"
19 You have to specify exactly one of the following options, depending on
20 what you want winebuild to generate.
21 .TP
22 .BI \--dll= filename
23 Build a C file from a .spec file (see \fBSPEC FILE SYNTAX\fR for
24 details), or from a standard Windows .def file. The resulting C file
25 must be compiled and linked to the other object files to build a
26 working Wine dll.
27 .br
28 In that mode, the
29 .I input files
30 should be the list of all object files that will be linked into the
31 final dll, to allow
32 .B winebuild
33 to get the list of all undefined symbols that need to be imported from
34 other dlls.
35 .TP
36 .BI \--exe= name
37 Build a C file for the named executable. This is basically the same as
38 the --dll mode except that it doesn't require a .spec file as input,
39 since an executable doesn't export functions. The resulting C file
40 must be compiled and linked to the other object files to build a
41 working Wine executable, and all the other object files must be listed
43 .I input files.
44 .TP
45 .BI \--def= file.spec
46 Build a .def file from a spec file. This is used when building dlls
47 with a PE (Win32) compiler.
48 .TP
49 .B \--debug
50 Build a C file containing the definitions for debugging channels. In
51 that mode the
52 .I input files
53 should be a list of C files to search for debug channel
54 definitions. The resulting C file must be compiled and linked with the
55 dll.
56 .TP
57 .B \--relay16
58 Generate the assembly code for the 16-bit relay routines. This is for
59 Wine internal usage only, you should never need to use this option.
60 .TP
61 .B \--relay32
62 Generate the assembly code for the 32-bit relay routines. This is for
63 Wine internal usage only, you should never need to use this option.
64 .SH OPTIONS
65 .TP
66 .BI \-C,\ --source-dir= directory
67 Change to the specified directory before reading source files. Only
68 meaningful in
69 .BR \--debug\  mode.
70 .TP
71 .BI \-D\  symbol
72 Ignored for compatibility with the C compiler.
73 .TP
74 .BI \-e,\ --entry= function
75 Specify the module entry point function; if not specified, the default
77 .B DllMain
78 for dlls, and
79 .B WinMain
80 for executables (if
81 .B WinMain
82 is not defined, the standard C
83 .B main
84 is used instead). This is only valid for Win32 modules.
85 .TP
86 .BI \-f\  flags
87 Ignored for compatibility with the C compiler.
88 .TP
89 .BI \-F,\ --filename= filename
90 Set the file name of the module. The default is to use the base name
91 of the spec file (without any extension).
92 .TP
93 .B \-h, --help
94 Display a usage message and exit.
95 .TP
96 .BI \-H,\ --heap= size
97 Specify the size of the module local heap in bytes (only valid for
98 Win16 modules); default is no local heap.
99 .TP
100 .BI \-i,\ --ignore= [-]symbol[,[-]symbol]
101 Specify a list of symbols that should be ignored when resolving
102 undefined symbols against the imported libraries. This forces these
103 symbols to be resolved from the Unix C library (or from another Unix
104 library linked with the application). If a symbol is prefixed by '-'
105 it is removed from the list instead of being added; a stand-alone '-'
106 clears the whole list.
108 .BI \-I\  directory
109 Ignored for compatibility with the C compiler.
111 .B \-k, --kill-at
112 Remove the stdcall decorations from the symbol names in the
113 generated .def file. Only meaningful in \fB--def\fR mode.
115 .BI \-K\  flags
116 Ignored for compatibility with the C compiler.
118 .BI \-L,\ --library-path= directory
119 Append the specified directory to the list of directories that are
120 searched for import libraries.
122 .BI \-l,\ --library= name
123 Import the specified library, looking for a corresponding
124 \fIlibname.def\fR file in the directories specified with the \fB-L\fR
125 option.
127 .BI \-d,\ --delay-lib= name
128 Same as the \fB-l\fR option, but import the specified library in
129 delayed mode (i.e. the library won't be loaded until a function
130 imported from it is actually called).
132 .BI \-M,\ --main-module= module
133 Specify that we are building a 16-bit dll, that will ultimately be
134 linked together with the 32-bit dll specified in \fImodule\fR.  Only
135 meaningful in \fB--dll\fR mode.
137 .BI \-N,\ --dll-name= dllname
138 Set the internal name of the module. It is only used in Win16
139 modules. The default is to use the base name of the spec file (without
140 any extension). This is used for KERNEL, since it lives in
141 KRNL386.EXE. It shouldn't be needed otherwise.
143 .BI \-o,\ --output= file
144 Set the name of the output file (default is standard output).
146 .BI \-r,\ --res= rsrc.res
147 Load resources from the specified binary resource file. The
148 \fIrsrc.res\fR can be produced from a source resource file with
149 .BR wrc(1)
150 (or with a Windows resource compiler).
152 This option is only necessary for Win16 resource files, the Win32 ones
153 can simply listed as
154 .I input files
155 and will automatically be handled correctly (though the
156 .B \-r
157 option will also work for Win32 files).
159 .BI --subsystem= subsystem[:major[.minor]]
160 Set the subsystem of the executable, which can be one of the following:
162 .B console
163 for a command line executable,
165 .B windows
166 for a graphical executable,
168 .B native
169 for a native-mode dll.
171 The entry point of a command line executable is a normal C \fBmain\fR
172 function. A \fBwmain\fR function can be used instead if you need the
173 argument array to use Unicode strings. A graphical executable has a
174 \fBWinMain\fR entry point.
176 Optionally a major and minor subsystem version can also be specified;
177 the default subsystem version is 4.0.
179 .B \--version
180 Display the program version and exit.
182 .B \-w, --warnings
183 Turn on warnings.
184 .SH "SPEC FILE SYNTAX"
185 .SS "General syntax"
186 A spec file should contain a list of ordinal declarations. The general
187 syntax is the following:
189 .I ordinal functype
190 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
192 .IB ordinal\  variable
193 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
195 .IB ordinal\  extern
196 .RI [ flags ]\  exportname \ [ symbolname ]
198 .IB ordinal\  stub
199 .RI [ flags ]\  exportname
201 .IB ordinal\  equate
202 .RI [ flags ]\  exportname\ data
204 .BI #\  comments
206 Declarations must fit on a single line, except if the end of line is
207 escaped using a backslash character. The
208 .B #
209 character anywhere in a line causes the rest of the line to be ignored
210 as a comment.
212 .I ordinal
213 specifies the ordinal number corresponding to the entry point, or '@'
214 for automatic ordinal allocation (Win32 only).
216 .I flags
217 is a series of optional flags, preceded by a '-' character. The
218 supported flags are:
221 .B -norelay
222 The entry point is not displayed in relay debugging traces (Win32
223 only).
225 .B -noname
226 The entry point will be imported by ordinal instead of by name.
228 .B -ret16
229 The function returns a 16-bit value (Win16 only).
231 .B -ret64
232 The function returns a 64-bit value (Win32 only).
234 .B -i386
235 The entry point is only available on i386 platforms.
237 .B -register
238 The function uses CPU register to pass arguments.
240 .B -private
241 The function cannot be imported from other dlls, it can only be
242 accessed through GetProcAddress.
243 .SS "Function ordinals"
244 Syntax:
246 .I ordinal functype
247 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
250 This declaration defines a function entry point.  The prototype defined by
251 .IR exportname \ \fB(\fR\ [ args... ] \ \fB)
252 specifies the name available for dynamic linking and the format of the
253 arguments. '@' can be used instead of
254 .I exportname
255 for ordinal-only exports.
257 .I functype
258 should be one of:
261 .B stdcall
262 for a normal Win32 function
264 .B pascal
265 for a normal Win16 function
267 .B cdecl
268 for a Win16 or Win32 function using the C calling convention
270 .B varargs
271 for a Win16 or Win32 function using the C calling convention with a
272 variable number of arguments
275 .I args
276 should be one or several of:
279 .B word
280 (16-bit unsigned value)
282 .B s_word
283 (16-bit signed word)
285 .B long
286 (32-bit value)
288 .B double
289 (64-bit value)
291 .B ptr
292 (linear pointer)
294 .B str
295 (linear pointer to a null-terminated ASCII string)
297 .B wstr
298 (linear pointer to a null-terminated Unicode string)
300 .B segptr
301 (segmented pointer)
303 .B segstr
304 (segmented pointer to a null-terminated ASCII string).
306 .RB Only\  ptr ,\  str ,\  wstr ,\  long\  and\  double
307 are valid for Win32 functions.
310 .I handler
311 is the name of the actual C function that will implement that entry
312 point in 32-bit mode. The handler can also be specified as
313 .IB dllname . function
314 to define a forwarded function (one whose implementation is in another
315 dll). If
316 .I handler
317 is not specified, it is assumed to be identical to
318 .I exportname.
320 This first example defines an entry point for the 32-bit GetFocus()
321 call:
323 @ stdcall GetFocus() GetFocus
325 This second example defines an entry point for the 16-bit
326 CreateWindow() call (the ordinal 100 is just an example); it also
327 shows how long lines can be split using a backslash:
329 100 pascal CreateWindow(ptr ptr long s_word s_word s_word \\
330     s_word word word word ptr) WIN_CreateWindow
332 To declare a function using a variable number of arguments, specify
333 the function as
334 .B varargs
335 and declare it in the C file with a '...' parameter for a Win32
336 function, or with an extra VA_LIST16 argument for a Win16 function.
337 See the wsprintf* functions in user.exe.spec and user32.spec for an
338 example.
339 .SS "Variable ordinals"
340 Syntax:
342 .IB ordinal\  variable
343 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
345 This declaration defines data storage as 32-bit words at the ordinal
346 specified.
347 .I exportname
348 will be the name available for dynamic
349 linking.
350 .I data
351 can be a decimal number or a hex number preceeded by "0x".  The
352 following example defines the variable VariableA at ordinal 2 and
353 containing 4 ints:
355 2 variable VariableA(-1 0xff 0 0)
357 This declaration only works in Win16 spec files. In Win32 you should
359 .B extern
360 instead (see below).
361 .SS "Extern ordinals"
362 Syntax:
364 .IB ordinal\  extern
365 .RI [ flags ]\  exportname \ [ symbolname ]
367 This declaration defines an entry that simply maps to a C symbol
368 (variable or function). It only works in Win32 spec files.
369 .I exportname
370 will point to the symbol
371 .I symbolname
372 that must be defined in the C code. Alternatively, it can be of the
373 form
374 .IB dllname . symbolname
375 to define a forwarded symbol (one whose implementation is in another
376 dll). If
377 .I symbolname
378 is not specified, it is assumed to be identical to
379 .I exportname.
380 .SS "Stub ordinals"
381 Syntax:
383 .IB ordinal\  stub
384 .RI [ flags ]\  exportname
386 This declaration defines a stub function. It makes the name and
387 ordinal available for dynamic linking, but will terminate execution
388 with an error message if the function is ever called.
389 .SS "Equate ordinals"
390 Syntax:
392 .IB ordinal\  equate
393 .RI [ flags ]\  exportname\ data
395 This declaration defines an ordinal as an absolute value.
396 .I exportname
397 will be the name available for dynamic linking.
398 .I data
399 can be a decimal number or a hex number preceeded by "0x".
400 .SH AUTHORS
401 .B winebuild
402 has been worked on by many people over the years. The main authors are
403 Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich
404 Weigand and Eric Youngdale. Many other Wine developers have
405 contributed, please check the file Changelog in the Wine distribution
406 for the complete details.
407 .SH BUGS
408 It is not yet possible to use a PE-format dll in an import
409 specification; only Wine dlls can be imported.
411 If you find a bug, please submit a bug report at
412 .UR http://bugs.winehq.org
413 .B http://bugs.winehq.org.
415 .SH AVAILABILITY
416 .B winebuild
417 is part of the wine distribution, which is available through WineHQ,
419 .B wine
420 development headquarters, at
421 .UR http://www.winehq.org/
422 .B http://www.winehq.org/.
424 .SH "SEE ALSO"
425 .BR wine (1),
426 .BR wrc (1).