Removed support for 'rsrc' spec file statement.
[wine/multimedia.git] / tools / winebuild / winebuild.man.in
blobbebf686a7912c9ad6d39016f54750702178cf27c
1 .\" -*- nroff -*-
2 .TH WINEBUILD 1 "July 2002" "@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 \--spec\  file.spec
23 Build a C file from a spec file (see \fBSPEC FILE SYNTAX\fR for
24 details). The resulting C file must be compiled and linked to the
25 other object files to build a working Wine dll.
26 .br
27 In that mode, the
28 .I input files
29 should be the list of all object files that will be linked into the
30 final dll, to allow
31 .B winebuild
32 to get the list of all undefined symbols that need to be imported from
33 other dlls.
34 .TP
35 .BI \--exe\  name
36 Build a C file for the named executable. This is basically the same as
37 the --spec mode except that it doesn't require a .spec file as input,
38 since an executable doesn't export functions. The resulting C file
39 must be compiled and linked to the other object files to build a
40 working Wine executable, and all the other object files must be listed
42 .I input files.
43 .TP
44 .BI \--def\  file.spec
45 Build a .def file from a spec file. This is used when building dlls
46 with a PE (Win32) compiler.
47 .TP
48 .B \--debug
49 Build a C file containing the definitions for debugging channels. In
50 that mode the
51 .I input files
52 should be a list of C files to search for debug channel
53 definitions. The resulting C file must be compiled and linked with the
54 dll.
55 .TP
56 .B \--glue
57 Build a C file containing the glue code for the 16-bit calls contained
58 in the
59 .I input files.
60 These calls must be specified in the source files using special
61 markers, as described in the \fBGLUE FUNCTIONS\fR section.
62 .TP
63 .B \--relay16
64 Generate the assembly code for the 16-bit relay routines. This is for
65 Wine internal usage only, you should never need to use this option.
66 .TP
67 .B \--relay32
68 Generate the assembly code for the 32-bit relay routines. This is for
69 Wine internal usage only, you should never need to use this option.
70 .SH OPTIONS
71 .TP
72 .BI \-C\  directory
73 Change to the specified directory before reading source files. Only
74 meaningful in
75 .BR \--debug\  and\  --glue\  modes.
76 .TP
77 .BI \-D\  symbol
78 Ignored for compatibility with the C compiler.
79 .TP
80 .BI \-e\  function
81 Specify the module entry point function; if not specified, the default
83 .B DllMain
84 for dlls, and
85 .B main
87 .B WinMain
88 for CUI or GUI executables respectively. This is only valid for Win32
89 modules.
90 .TP
91 .BI \-f\  flags
92 Ignored for compatibility with the C compiler.
93 .TP
94 .B \-h
95 Display a usage message and exit.
96 .TP
97 .BI \-H\  size
98 Specify the size of the module local heap in bytes (only valid for
99 Win16 modules); default is no local heap.
101 .BI \-I\  directory
102 Ignored for compatibility with the C compiler.
104 .BI \-K\  flags
105 Ignored for compatibility with the C compiler.
107 .BI \-L\  directory
108 Append the specified directory to the list of directories that are
109 searched for import libraries.
111 .BI \-l\  lib.dll
112 Import the specified library, looking for a corresponding
113 \fIlib.dll.so\fR file in the directories specified with the \fB-L\fR
114 option.
116 .BI \-dl\  lib.dll
117 Same as the \fB-l\fR option, but import the specified library in
118 delayed mode (i.e. the library won't be loaded until a function
119 imported from it is actually called).
121 .BI \-M\  module
122 Specify that we are building a 16-bit dll, that will ultimately be
123 linked together with the 32-bit dll specified in \fImodule\fR.  Only
124 meaningful in \fB--spec\fR mode.
126 .BI \-m\  mode
127 Set the executable mode, which can be one of the following:
129 .B cui
130 for a command line ASCII executable,
132 .B gui
133 for a graphical ASCII executable,
135 .B cuiw
136 for a command line Unicode executable,
138 .B guiw
139 for a graphical Unicode executable.
141 A command line executable entry point is a normal C \fBmain\fR
142 function. A graphical executable has a \fBWinMain\fR entry point
143 instead. The ASCII/Unicode distinction applies to the strings that are
144 passed to the entry point.
146 This option is only meaningful in \fB--exe\fR mode.
148 .BI \-N\  dllname
149 Set the internal name of the module. It is only used in Win16
150 modules. The default is to use the base name of the spec file (without
151 any extension). This is used for KERNEL, since it lives in
152 KRNL386.EXE. It shouldn't be needed otherwise.
154 .BI \-o\  file
155 Set the name of the output file (default is standard output).
157 .BI \-r\  rsrc.res
158 Load resources from the specified binary resource file. The
159 \fIrsrc.res\fR can be produced from a source resource file with
160 .BR wrc(1)
161 (or with a Windows resource compiler).
163 .B \-w
164 Turn on warnings.
165 .SH "SPEC FILE SYNTAX"
166 .SS "General syntax"
167 A spec file should contain a number of optional directives, and then a
168 list of ordinal declarations. The general syntax is the following:
170 .RB [ ignore\ (\  [ \fIsymbols...\fR ]\  )\  ]
172 .BI #\  comments
174 .I ordinal functype
175 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB)\fI\ handler
177 .IB ordinal\  variable
178 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
180 .IB ordinal\  stub
181 .RI [ flags ]\  exportname
183 .IB ordinal\  equate
184 .RI [ flags ]\  exportname\ data
186 .IB ordinal\  extern
187 .RI [ flags ]\  exportname\ symbolname
189 .IB ordinal\  forward
190 .RI [ flags ]\  exportname\ forwardname
191 .SS "Optional directives"
192 .B ignore
193 specifies a list of symbols that should be ignored when
194 resolving undefined symbols against the imported libraries.
196 Lines whose first character is a
197 .B #
198 will be ignored as comments.
199 .SS "Ordinal specifications"
200 .I ordinal
201 specifies the ordinal number corresponding to the entry point, or '@'
202 for automatic ordinal allocation (Win32 only).
204 .I flags
205 is a series of optional flags, preceded by a '-' character. The
206 supported flags are:
209 .B -noimport
210 The entry point is not made available for importing from Winelib
211 applications (Win32 only).
213 .B -norelay
214 The entry point is not displayed in relay debugging traces (Win32
215 only).
217 .B -noname
218 The entry point will be imported by ordinal instead of by name.
220 .B -ret64
221 The function returns a 64-bit value (Win32 only).
223 .B -i386
224 The entry point is only available on i386 platforms.
226 .B -register
227 The function uses CPU register to pass arguments.
229 .B -interrupt
230 The function is an interrupt handler routine.
231 .SS "Function ordinals"
232 Syntax:
234 .I ordinal functype
235 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB)\fI\ handler
238 This declaration defines a function entry point.  The prototype defined by
239 .IR exportname \ \fB(\fR\ [ args... ] \ \fB)
240 specifies the name available for dynamic linking and the format of the
241 arguments. '@' can be used instead of
242 .I exportname
243 for ordinal-only exports.
245 .I functype
246 should be one of:
249 .B stdcall
250 for a normal Win32 function
252 .B cdecl
253 for a Win32 function using the C calling convention
255 .B varargs
256 for a Win32 function taking a variable number of arguments
258 .B pascal
259 for a Win16 function returning a 32-bit value
261 .B pascal16
262 for a Win16 function returning a 16-bit value.
265 .I args
266 should be one or several of:
269 .B word
270 (16-bit unsigned value)
272 .B s_word
273 (16-bit signed word)
275 .B long
276 (32-bit value)
278 .B double
279 (64-bit value)
281 .B ptr
282 (linear pointer)
284 .B str
285 (linear pointer to a null-terminated ASCII string)
287 .B wstr
288 (linear pointer to a null-terminated Unicode string)
290 .B segptr
291 (segmented pointer)
293 .B segstr
294 (segmented pointer to a null-terminated ASCII string).
296 .RB Only\  ptr ,\  str ,\  wstr ,\  long\  and\  double
297 are valid for Win32 functions.
300 .I handler
301 is the name of the actual C function that will implement that entry
302 point in 32-bit mode.
304 This first example defines an entry point for the 16-bit
305 CreateWindow() call (the ordinal 100 is just an example):
307 100 pascal CreateWindow(ptr ptr long s_word s_word s_word s_word word word word ptr) WIN_CreateWindow
309 This second example defines an entry point for the 32-bit GetFocus()
310 call:
312 @ stdcall GetFocus() GetFocus
314 To declare a function using a variable number of arguments in Win16,
315 specify the function as taking no arguments. The arguments are then
316 available with CURRENT_STACK16->args. In Win32, specify the function
318 .B varargs
319 and declare it with a '...' parameter in the C file.  See the
320 wsprintf* functions in user.spec and user32.spec for an example.
321 .SS "Variable ordinals"
322 Syntax:
324 .IB ordinal\  variable
325 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
327 This declaration defines data storage as 32-bit words at the ordinal
328 specified.
329 .I exportname
330 will be the name available for dynamic
331 linking.
332 .I data
333 can be a decimal number or a hex number preceeded by "0x".  The
334 following example defines the variable VariableA at ordinal 2 and
335 containing 4 ints:
337 2 variable VariableA(-1 0xff 0 0)
338 .SS "Stub ordinals"
339 Syntax:
341 .IB ordinal\  stub
342 .RI [ flags ]\  exportname
344 This declaration defines a stub function. It makes the name and
345 ordinal available for dynamic linking, but will terminate execution
346 with an error message if the function is ever called.
347 .SS "Equate ordinals"
348 Syntax:
350 .IB ordinal\  equate
351 .RI [ flags ]\  exportname\ data
353 This declaration defines an ordinal as an absolute value.
354 .I exportname
355 will be the name available for dynamic linking.
356 .I data
357 can be a decimal number or a hex number preceeded by "0x".
358 .SS "Extern ordinals"
359 Syntax:
361 .IB ordinal\  extern
362 .RI [ flags ]\  exportname\ symbolname
364 This declaration defines an entry that simply maps to a C symbol
365 (variable or function).
366 .I exportname
367 will point to the symbol
368 .I symbolname
369 that must be defined in C code. This declaration only works in Win32
370 spec files.
371 .SS "Forwarded ordinals"
372 Syntax:
374 .IB ordinal\  forward
375 .RI [ flags ]\  exportname\ forwardname
377 This declaration defines an entry that is forwarded to another entry
378 point (kind of a symbolic link).
379 .I exportname
380 will forward to the
381 entry point
382 .I forwardname
383 that must be of the form
384 .B DLL.Function.
385 This declaration only works in Win32 spec files.
386 .SH "GLUE FUNCTIONS"
387 Glue functions are used to call down to 16-bit code from a 32-bit
388 function. This is done by declaring a special type of function
389 prototype in the source file that needs to call to 16-bit code, and
390 processing the source file through
391 .I winebuild --glue.
393 These prototypes must be of one of the following forms:
395 .B extern WORD CALLBACK \fIprefix\fB_CallTo16_word_\fIxxx\fB( FARPROC16 func, \fIargs\fB );
397 .B extern LONG CALLBACK \fIprefix\fB_CallTo16_long_\fIxxx\fB( FARPROC16 func, \fIargs\fB );
400 .I prefix
401 can be anything you need to make the function names unique inside a
402 given dll. The
403 .I xxx
404 characters specify the type of the arguments, with one letter for each
405 argument. A \fBw\fR indicates a WORD argument, a \fBl\fR indicates a
406 LONG argument.
408 All the CallTo16 prototypes must be located between the special
409 markers
410 .B ### start build ###
412 .B ### stop build ###
413 (which have to be inside C comments of course).
415 Here's what a real life example looks like:
417 .B /* ### start build ### */
419 .B extern WORD CALLBACK PRTDRV_CallTo16_word_ww(FARPROC16,WORD,WORD);
421 .B /* ### stop build ### */
422 .SH AUTHORS
423 .B winebuild
424 has been worked on by many people over the years. The main authors are
425 Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich
426 Weigand and Eric Youngdale. Many other Wine developers have
427 contributed, please check the file Changelog in the Wine distribution
428 for the complete details.
429 .SH BUGS
430 It is not yet possible to use a PE-format dll in an import
431 specification; only Wine dlls can be imported.
433 If you find a bug, please submit a bug report at
434 .UR http://bugs.winehq.com
435 .B http://bugs.winehq.com.
437 .SH AVAILABILITY
438 .B winebuild
439 is part of the wine distribution, which is available through WineHQ,
441 .B wine
442 development headquarters, at
443 .UR http://www.winehq.com/
444 .B http://www.winehq.com/.
446 .SH "SEE ALSO"
447 .BR wine (1),
448 .BR wrc (1).