Handle multiline output from grep and don't grep for empty strings.
[wine] / tools / winebuild / winebuild.man.in
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 \--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
41 as
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,\ --source-dir= 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,\ --entry= function
81 Specify the module entry point function; if not specified, the default
82 is
83 .B DllMain
84 for dlls, and
85 .B main
86 or
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 .BI \-F,\ --filename= filename
95 Set the file name of the module. The default is to use the base name
96 of the spec file (without any extension).
97 .TP
98 .B \-h, --help
99 Display a usage message and exit.
100 .TP
101 .BI \-H,\ --heap= size
102 Specify the size of the module local heap in bytes (only valid for
103 Win16 modules); default is no local heap.
104 .TP
105 .BI \-i,\ --ignore= [-]symbol[,[-]symbol]
106 Specify a list of symbols that should be ignored when resolving
107 undefined symbols against the imported libraries. This forces these
108 symbols to be resolved from the Unix C library (or from another Unix
109 library linked with the application). If a symbol is prefixed by '-'
110 it is removed from the list instead of being added; a stand-alone '-'
111 clears the whole list.
112 .TP
113 .BI \-I\  directory
114 Ignored for compatibility with the C compiler.
115 .TP
116 .B \-k, --kill-at
117 Remove the stdcall decorations from the symbol names in the
118 generated .def file. Only meaningful in \fB--def\fR mode.
119 .TP
120 .BI \-K\  flags
121 Ignored for compatibility with the C compiler.
122 .TP
123 .BI \-L,\ --library-path= directory
124 Append the specified directory to the list of directories that are
125 searched for import libraries.
126 .TP
127 .BI \-l,\ --library= name
128 Import the specified library, looking for a corresponding
129 \fIlibname.def\fR file in the directories specified with the \fB-L\fR
130 option.
131 .TP
132 .BI \-d,\ --delay-lib= name
133 Same as the \fB-l\fR option, but import the specified library in
134 delayed mode (i.e. the library won't be loaded until a function
135 imported from it is actually called).
136 .TP
137 .BI \-M,\ --main-module= module
138 Specify that we are building a 16-bit dll, that will ultimately be
139 linked together with the 32-bit dll specified in \fImodule\fR.  Only
140 meaningful in \fB--spec\fR mode.
141 .TP
142 .BI \-m,\ --exe-mode= mode
143 Set the executable mode, which can be one of the following:
144 .br
145 .B cui
146 for a command line ASCII executable,
147 .br
148 .B gui
149 for a graphical ASCII executable,
150 .br
151 .B cuiw
152 for a command line Unicode executable,
153 .br
154 .B guiw
155 for a graphical Unicode executable.
156 .br
157 A command line executable entry point is a normal C \fBmain\fR
158 function. A graphical executable has a \fBWinMain\fR entry point
159 instead. The ASCII/Unicode distinction applies to the strings that are
160 passed to the entry point.
161 .br
162 This option is only meaningful in \fB--exe\fR mode.
163 .TP
164 .BI \-N,\ --dll-name= dllname
165 Set the internal name of the module. It is only used in Win16
166 modules. The default is to use the base name of the spec file (without
167 any extension). This is used for KERNEL, since it lives in
168 KRNL386.EXE. It shouldn't be needed otherwise.
169 .TP
170 .BI \-o,\ --output= file
171 Set the name of the output file (default is standard output).
172 .TP
173 .BI \-r,\ --res= rsrc.res
174 Load resources from the specified binary resource file. The
175 \fIrsrc.res\fR can be produced from a source resource file with
176 .BR wrc(1)
177 (or with a Windows resource compiler).
178 .br
179 This option is only necessary for Win16 resource files, the Win32 ones
180 can simply listed as
181 .I input files
182 and will automatically be handled correctly (though the
183 .B \-r
184 option will also work for Win32 files).
185 .TP
186 .B \--version
187 Display the program version and exit.
188 .TP
189 .B \-w, --warnings
190 Turn on warnings.
191 .SH "SPEC FILE SYNTAX"
192 .SS "General syntax"
193 A spec file should contain a list of ordinal declarations. The general
194 syntax is the following:
195 .PP
196 .I ordinal functype
197 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
198 .br
199 .IB ordinal\  variable
200 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
201 .br
202 .IB ordinal\  extern
203 .RI [ flags ]\  exportname \ [ symbolname ]
204 .br
205 .IB ordinal\  stub
206 .RI [ flags ]\  exportname
207 .br
208 .IB ordinal\  equate
209 .RI [ flags ]\  exportname\ data
210 .br
211 .BI #\  comments
212 .PP
213 Declarations must fit on a single line, except if the end of line is
214 escaped using a backslash character. The
215 .B #
216 character anywhere in a line causes the rest of the line to be ignored
217 as a comment.
218 .PP
219 .I ordinal
220 specifies the ordinal number corresponding to the entry point, or '@'
221 for automatic ordinal allocation (Win32 only).
222 .PP
223 .I flags
224 is a series of optional flags, preceded by a '-' character. The
225 supported flags are:
226 .RS
227 .TP
228 .B -norelay
229 The entry point is not displayed in relay debugging traces (Win32
230 only).
231 .TP
232 .B -noname
233 The entry point will be imported by ordinal instead of by name.
234 .TP
235 .B -ret64
236 The function returns a 64-bit value (Win32 only).
237 .TP
238 .B -i386
239 The entry point is only available on i386 platforms.
240 .TP
241 .B -register
242 The function uses CPU register to pass arguments.
243 .TP
244 .B -interrupt
245 The function is an interrupt handler routine.
246 .SS "Function ordinals"
247 Syntax:
248 .br
249 .I ordinal functype
250 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
251 .br
252
253 This declaration defines a function entry point.  The prototype defined by
254 .IR exportname \ \fB(\fR\ [ args... ] \ \fB)
255 specifies the name available for dynamic linking and the format of the
256 arguments. '@' can be used instead of
257 .I exportname
258 for ordinal-only exports.
259 .PP
260 .I functype
261 should be one of:
262 .RS
263 .TP
264 .B stdcall
265 for a normal Win32 function
266 .TP
267 .B cdecl
268 for a Win32 function using the C calling convention
269 .TP
270 .B varargs
271 for a Win32 function taking a variable number of arguments
272 .TP
273 .B pascal
274 for a Win16 function returning a 32-bit value
275 .TP
276 .B pascal16
277 for a Win16 function returning a 16-bit value.
278 .RE
279 .PP
280 .I args
281 should be one or several of:
282 .RS
283 .TP
284 .B word
285 (16-bit unsigned value)
286 .TP
287 .B s_word
288 (16-bit signed word)
289 .TP
290 .B long
291 (32-bit value)
292 .TP
293 .B double
294 (64-bit value)
295 .TP
296 .B ptr
297 (linear pointer)
298 .TP
299 .B str
300 (linear pointer to a null-terminated ASCII string)
301 .TP
302 .B wstr
303 (linear pointer to a null-terminated Unicode string)
304 .TP
305 .B segptr
306 (segmented pointer)
307 .TP
308 .B segstr
309 (segmented pointer to a null-terminated ASCII string).
310 .HP
311 .RB Only\  ptr ,\  str ,\  wstr ,\  long\  and\  double
312 are valid for Win32 functions.
313 .RE
314 .PP
315 .I handler
316 is the name of the actual C function that will implement that entry
317 point in 32-bit mode. The handler can also be specified as
318 .IB dllname . function
319 to define a forwarded function (one whose implementation is in another
320 dll). If
321 .I handler
322 is not specified, it is assumed to be identical to
323 .I exportname.
324 .PP
325 This first example defines an entry point for the 32-bit GetFocus()
326 call:
327 .IP
328 @ stdcall GetFocus() GetFocus
329 .PP
330 This second example defines an entry point for the 16-bit
331 CreateWindow() call (the ordinal 100 is just an example); it also
332 shows how long lines can be split using a backslash:
333 .IP
334 100 pascal CreateWindow(ptr ptr long s_word s_word s_word \\
335     s_word word word word ptr) WIN_CreateWindow
336 .PP
337 To declare a function using a variable number of arguments in Win16,
338 specify the function as taking no arguments. The arguments are then
339 available with CURRENT_STACK16->args. In Win32, specify the function
340 as
341 .B varargs
342 and declare it with a '...' parameter in the C file.  See the
343 wsprintf* functions in user.exe.spec and user32.spec for an example.
344 .SS "Variable ordinals"
345 Syntax:
346 .br
347 .IB ordinal\  variable
348 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
349 .PP
350 This declaration defines data storage as 32-bit words at the ordinal
351 specified.
352 .I exportname
353 will be the name available for dynamic
354 linking.
355 .I data
356 can be a decimal number or a hex number preceeded by "0x".  The
357 following example defines the variable VariableA at ordinal 2 and
358 containing 4 ints:
359 .IP
360 2 variable VariableA(-1 0xff 0 0)
361 .PP
362 This declaration only works in Win16 spec files. In Win32 you should
363 use
364 .B extern
365 instead (see below).
366 .SS "Extern ordinals"
367 Syntax:
368 .br
369 .IB ordinal\  extern
370 .RI [ flags ]\  exportname \ [ symbolname ]
371 .PP
372 This declaration defines an entry that simply maps to a C symbol
373 (variable or function). It only works in Win32 spec files.
374 .I exportname
375 will point to the symbol
376 .I symbolname
377 that must be defined in the C code. Alternatively, it can be of the
378 form
379 .IB dllname . symbolname
380 to define a forwarded symbol (one whose implementation is in another
381 dll). If
382 .I symbolname
383 is not specified, it is assumed to be identical to
384 .I exportname.
385 .SS "Stub ordinals"
386 Syntax:
387 .br
388 .IB ordinal\  stub
389 .RI [ flags ]\  exportname
390 .PP
391 This declaration defines a stub function. It makes the name and
392 ordinal available for dynamic linking, but will terminate execution
393 with an error message if the function is ever called.
394 .SS "Equate ordinals"
395 Syntax:
396 .br
397 .IB ordinal\  equate
398 .RI [ flags ]\  exportname\ data
399 .PP
400 This declaration defines an ordinal as an absolute value.
401 .I exportname
402 will be the name available for dynamic linking.
403 .I data
404 can be a decimal number or a hex number preceeded by "0x".
405 .SH "GLUE FUNCTIONS"
406 Glue functions are used to call down to 16-bit code from a 32-bit
407 function. This is done by declaring a special type of function
408 prototype in the source file that needs to call to 16-bit code, and
409 processing the source file through
410 .I winebuild --glue.
411 .PP
412 These prototypes must be of one of the following forms:
413 .PP
414 .B extern WORD CALLBACK \fIprefix\fB_CallTo16_word_\fIxxx\fB( FARPROC16 func, \fIargs\fB );
415 .br
416 .B extern LONG CALLBACK \fIprefix\fB_CallTo16_long_\fIxxx\fB( FARPROC16 func, \fIargs\fB );
417 .PP
418 The
419 .I prefix
420 can be anything you need to make the function names unique inside a
421 given dll. The
422 .I xxx
423 characters specify the type of the arguments, with one letter for each
424 argument. A \fBw\fR indicates a WORD argument, a \fBl\fR indicates a
425 LONG argument.
426 .PP
427 All the CallTo16 prototypes must be located between the special
428 markers
429 .B ### start build ###
430 and
431 .B ### stop build ###
432 (which have to be inside C comments of course).
433 .PP
434 Here's what a real life example looks like:
435 .PP
436 .B /* ### start build ### */
437 .br
438 .B extern WORD CALLBACK PRTDRV_CallTo16_word_ww(FARPROC16,WORD,WORD);
439 .br
440 .B /* ### stop build ### */
441 .SH AUTHORS
442 .B winebuild
443 has been worked on by many people over the years. The main authors are
444 Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich
445 Weigand and Eric Youngdale. Many other Wine developers have
446 contributed, please check the file Changelog in the Wine distribution
447 for the complete details.
448 .SH BUGS
449 It is not yet possible to use a PE-format dll in an import
450 specification; only Wine dlls can be imported.
451 .PP
452 If you find a bug, please submit a bug report at
453 .UR http://bugs.winehq.com
454 .B http://bugs.winehq.com.
455 .UE
456 .SH AVAILABILITY
457 .B winebuild
458 is part of the wine distribution, which is available through WineHQ,
459 the
460 .B wine
461 development headquarters, at
462 .UR http://www.winehq.com/
463 .B http://www.winehq.com/.
464 .UE
465 .SH "SEE ALSO"
466 .BR wine (1),
467 .BR wrc (1).