msvcr100: Use Context blocking functions in critical_section class.
[wine.git] / tools / winebuild / winebuild.man.in
blob23ef34957446ca5c4c77a3c88115eb190ebd058b
1 .TH WINEBUILD 1 "October 2005" "@PACKAGE_STRING@" "Wine Developers Manual"
2 .SH NAME
3 winebuild \- Wine dll builder
4 .SH SYNOPSIS
5 .B winebuild
6 .RI [ options ]\ [ inputfile ...]
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 \fB-E\fR 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 \fB--dll\fR 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 \fB-E\fR option. The executable is named from the .spec/.def file name if
40 present, or explicitly through the \fB-F\fR 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 \fB-E\fR option. This is used when building dlls with a PE (Win32) compiler.
48 .TP
49 .BI \--implib
50 Build a .a import library from a spec file. The .spec file is
51 specified via the \fB-E\fR option. If the output library name ends
52 in .delay.a, a delayed import library is built.
53 .TP
54 .BI \--staticlib
55 Build a .a static library from object files.
56 .TP
57 .B \--resources
58 Generate a .o file containing all the input resources. This is useful
59 when building with a PE compiler, since the PE binutils cannot handle
60 multiple resource files as input. For a standard Unix build, the
61 resource files are automatically included when building the spec file,
62 so there's no need for an intermediate .o file.
63 .TP
64 .BI \--builtin
65 Mark a PE module as a Wine builtin module, by adding the "Wine builtin
66 DLL" signature string after the DOS header.
67 .TP
68 .BI \--fixup-ctors
69 Fixup constructors after a module has been built. This should be done
70 on the final .so module if its code contains constructors, to ensure
71 that Wine has a chance to initialize the module before the
72 constructors are executed.
73 .SH OPTIONS
74 .TP
75 .BI \--as-cmd= as-command
76 Specify the command to use to compile assembly files; the default is
77 \fBas\fR.
78 .TP
79 .BI \-b,\ --target= cpu-manufacturer\fR[\fB-\fIkernel\fR]\fB-\fIos
80 Specify the target CPU and platform on which the generated code will
81 be built. The target specification is in the standard autoconf format
82 as returned by config.sub.
83 .TP
84 .BI \-B\  directory
85 Add the directory to the search path for the various binutils tools
86 like \fBas\fR, \fBnm\fR and \fBld\fR.
87 .TP
88 .BI \--cc-cmd= cc-command
89 Specify the C compiler to use to compile assembly files; the default
90 is to instead use the assembler specified with \fB--as-cmd\fR.
91 .TP
92 .B \--data-only
93 Build a module that contains only data and resources, and no
94 executable code.  With this option, \fBwinebuild\fR directly outputs a
95 PE file, instead of an assembly or object file.
96 .TP
97 .BI \-d,\ --delay-lib= name
98 Set the delayed import mode for the specified library, which must be
99 one of the libraries imported with the \fB-l\fR option. Delayed mode
100 means that the library won't be loaded until a function imported from
101 it is actually called.
103 .BI \-D\  symbol
104 Ignored for compatibility with the C compiler.
106 .BI \-e,\ --entry= function
107 Specify the module entry point function; if not specified, the default
109 .B DllMain
110 for dlls, and
111 .B main
112 for executables (if the standard C
113 .B main
114 is not defined,
115 .B WinMain
116 is used instead). This is only valid for Win32 modules.
118 .BI \-E,\ --export= filename
119 Specify a .spec file (see \fBSPEC FILE SYNTAX\fR for details), 
120 or a standard Windows .def file that defines the exports
121 of the DLL or executable that is being built.
123 .B \--external-symbols
124 Allow linking to external symbols directly from the spec
125 file. Normally symbols exported by a dll have to be defined in the dll
126 itself; this option makes it possible to use symbols defined in
127 another Unix library (for symbols defined in another dll, a
128 .I forward
129 specification must be used instead).
131 .BI \-f\  option
132 Specify a code generation option. Currently \fB\-fPIC\fR and
133 \fB\-fasynchronous-unwind-tables\fR are supported. Other options are
134 ignored for compatibility with the C compiler.
136 .B \--fake-module
137 Create a fake PE module for a dll or exe, instead of the normal
138 assembly or object file. The PE module contains the resources for the
139 module, but no executable code.
141 .BI \-F,\ --filename= filename
142 Set the file name of the module. The default is to use the base name
143 of the spec file (without any extension).
145 .B \-h, --help
146 Display a usage message and exit.
148 .BI \-H,\ --heap= size
149 Specify the size of the module local heap in bytes (only valid for
150 Win16 modules); default is no local heap.
152 .BI \-I\  directory
153 Ignored for compatibility with the C compiler.
155 .B \-k, --kill-at
156 Remove the stdcall decorations from the symbol names in the
157 generated .def file. Only meaningful in \fB--def\fR mode.
159 .BI \-K\  flags
160 Ignored for compatibility with the C compiler.
162 .BI \--large-address-aware
163 Set a flag in the executable to notify the loader that this
164 application supports address spaces larger than 2 gigabytes.
166 .BI \--ld-cmd= ld-command
167 Specify the command to use to link the object files; the default is
168 \fBld\fR.
170 .BI \-L,\ --library-path= directory
171 Append the specified directory to the list of directories that are
172 searched for import libraries.
174 .BI \-l,\ --library= name
175 Import the specified library, looking for a corresponding
176 \fIlibname.def\fR file in the directories specified with the \fB-L\fR
177 option.
179 .B \-m16, -m32, -m64
180 Generate respectively 16-bit, 32-bit or 64-bit code.
182 .BI \-marm,\ \-mthumb,\ \-march= option ,\ \-mcpu= option ,\ \-mfpu= option ,\ \-mfloat-abi= option
183 Set code generation options for the assembler.
185 .B \-mno-cygwin
186 Build a library that uses the Windows runtime instead of the Unix C
187 library.
189 .BI \-M,\ --main-module= module
190 When building a 16-bit dll, set the name of its 32-bit counterpart to
191 \fImodule\fR. This is used to enforce that the load order for the
192 16-bit dll matches that of the 32-bit one.
194 .BI \-N,\ --dll-name= dllname
195 Set the internal name of the module. It is only used in Win16
196 modules. The default is to use the base name of the spec file (without
197 any extension). This is used for KERNEL, since it lives in
198 KRNL386.EXE. It shouldn't be needed otherwise.
200 .BI \--nm-cmd= nm-command
201 Specify the command to use to get the list of undefined symbols; the
202 default is \fBnm\fR.
204 .BI --nxcompat= yes\fR|\fIno
205 Specify whether the module is compatible with no-exec support. The
206 default is yes.
208 .BI \-o,\ --output= file
209 Set the name of the output file (default is standard output). If the
210 output file name ends in .o, the text output is sent to a
211 temporary file that is then assembled to produce the specified .o
212 file.
214 .B --prefer-native
215 Specify that the native DLL should be preferred if available at run
216 time. This can be used on modules that are mostly unimplemented.
218 .BI \-r,\ --res= rsrc.res
219 Load resources from the specified binary resource file. The
220 \fIrsrc.res\fR file can be produced from a source resource file with
221 .BR wrc (1)
222 (or with a Windows resource compiler).
224 This option is only necessary for Win16 resource files, the Win32 ones
225 can simply listed as
226 .I input files
227 and will automatically be handled correctly (though the
228 .B \-r
229 option will also work for Win32 files).
231 .B --safeseh
232 Mark object files as SEH compatible.
234 .B --save-temps
235 Do not delete the various temporary files that \fBwinebuild\fR generates.
237 .BI --subsystem= subsystem\fR[\fB:\fImajor\fR[\fB.\fIminor\fR]]
238 Set the subsystem of the executable, which can be one of the following:
240 .B console
241 for a command line executable,
243 .B windows
244 for a graphical executable,
246 .B native
247 for a native-mode dll,
249 .B wince
250 for a ce dll.
252 The entry point of a command line executable is a normal C \fBmain\fR
253 function. A \fBwmain\fR function can be used instead if you need the
254 argument array to use Unicode strings. A graphical executable has a
255 \fBWinMain\fR entry point.
257 Optionally a major and minor subsystem version can also be specified;
258 the default subsystem version is 4.0.
260 .BI --syscall-table= id
261 Set the system call table id, between 0 and 3. The default is 0, the
262 ntdll syscall table. Only useful in modules that define syscall entry
263 points.
265 .BI \-u,\ --undefined= symbol
266 Add \fIsymbol\fR to the list of undefined symbols when invoking the
267 linker. This makes it possible to force a specific module of a static
268 library to be included when resolving imports.
270 .B \-v, --verbose
271 Display the various subcommands being invoked by
272 .BR winebuild .
274 .B \--version
275 Display the program version and exit.
277 .B \-w, --warnings
278 Turn on warnings.
280 .B \--without-dlltool
281 Generate import library without using dlltool.
282 .SH "SPEC FILE SYNTAX"
283 .SS "General syntax"
284 A spec file should contain a list of ordinal declarations. The general
285 syntax is the following:
287 .I ordinal functype
288 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
290 .IB ordinal\  variable
291 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
293 .IB ordinal\  extern
294 .RI [ flags ]\  exportname \ [ symbolname ]
296 .IB ordinal\  stub
297 .RI [ flags ]\  exportname \ [\ \fB( args... \fB)\fR\ ]
299 .IB ordinal\  equate
300 .RI [ flags ]\  exportname\ data
302 .BI #\  comments
304 Declarations must fit on a single line, except if the end of line is
305 escaped using a backslash character. The
306 .B #
307 character anywhere in a line causes the rest of the line to be ignored
308 as a comment.
310 .I ordinal
311 specifies the ordinal number corresponding to the entry point, or '@'
312 for automatic ordinal allocation (Win32 only).
314 .I flags
315 is a series of optional flags, preceded by a '-' character. The
316 supported flags are:
319 .B -norelay
320 The entry point is not displayed in relay debugging traces (Win32
321 only).
323 .B -noname
324 The entry point will be exported by ordinal instead of by name. The
325 name is still available for importing.
327 .B -ret16
328 The function returns a 16-bit value (Win16 only).
330 .B -ret64
331 The function returns a 64-bit value (Win32 only).
333 .B -register
334 The function uses CPU register to pass arguments.
336 .B -private
337 The function cannot be imported from other dlls, it can only be
338 accessed through GetProcAddress.
340 .B -ordinal
341 The entry point will be imported by ordinal instead of by name. The
342 name is still exported.
344 .B -thiscall
345 The function uses the
346 .I thiscall
347 calling convention (first parameter in %ecx register on i386).
349 .B -fastcall
350 The function uses the
351 .I fastcall
352 calling convention (first two parameters in %ecx/%edx registers on
353 i386).
355 .B -syscall
356 The function is an NT system call. A system call thunk will be
357 generated, and the actual function will be called by the
358 \fI__wine_syscall_dispatcher\fR function that will be generated on the
359 Unix library side.
361 .B -import
362 The function is imported from another module. This can be used instead
363 of a
364 .I forward
365 specification when an application expects to find the function's
366 implementation inside the dll.
368 .B -arch=\fR[\fB!\fR]\fIcpu\fR[\fB,\fIcpu\fR]
369 The entry point is only available on the specified CPU
370 architecture(s). The names \fBwin32\fR and \fBwin64\fR match all
371 32-bit or 64-bit CPU architectures respectively. In 16-bit dlls,
372 specifying \fB-arch=win32\fR causes the entry point to be exported
373 from the 32-bit wrapper module. A CPU name can be prefixed with
374 \fB!\fR to exclude only that specific architecture.
376 .SS "Function ordinals"
377 Syntax:
379 .I ordinal functype
380 .RI [ flags ]\  exportname \ \fB(\fR\ [ args... ] \ \fB) \ [ handler ]
383 This declaration defines a function entry point.  The prototype defined by
384 .IR exportname \ \fB(\fR\ [ args... ] \ \fB)
385 specifies the name available for dynamic linking and the format of the
386 arguments. '@' can be used instead of
387 .I exportname
388 for ordinal-only exports.
390 .I functype
391 should be one of:
394 .B stdcall
395 for a normal Win32 function
397 .B pascal
398 for a normal Win16 function
400 .B cdecl
401 for a Win16 or Win32 function using the C calling convention
403 .B varargs
404 for a Win16 or Win32 function using the C calling convention with a
405 variable number of arguments
408 .I args
409 should be one or several of:
412 .B word
413 (16-bit unsigned value)
415 .B s_word
416 (16-bit signed word)
418 .B long
419 (pointer-sized integer value)
421 .B int64
422 (64-bit integer value)
424 .B int128
425 (128-bit integer value)
427 .B float
428 (32-bit floating point value)
430 .B double
431 (64-bit floating point value)
433 .B ptr
434 (linear pointer)
436 .B str
437 (linear pointer to a null-terminated ASCII string)
439 .B wstr
440 (linear pointer to a null-terminated Unicode string)
442 .B segptr
443 (segmented pointer)
445 .B segstr
446 (segmented pointer to a null-terminated ASCII string).
448 Note: The 16-bit and segmented pointer types are only valid for Win16
449 functions.
452 .I handler
453 is the name of the actual C function that will implement that entry
454 point in 32-bit mode. The handler can also be specified as
455 .IB dllname . function
456 to define a forwarded function (one whose implementation is in another
457 dll). If
458 .I handler
459 is not specified, it is assumed to be identical to
460 .I exportname.
462 This first example defines an entry point for the 32-bit GetFocus()
463 call:
465 @ stdcall GetFocus() GetFocus
467 This second example defines an entry point for the 16-bit
468 CreateWindow() call (the ordinal 100 is just an example); it also
469 shows how long lines can be split using a backslash:
471 100 pascal CreateWindow(ptr ptr long s_word s_word s_word \\
472     s_word word word word ptr) WIN_CreateWindow
474 To declare a function using a variable number of arguments, specify
475 the function as
476 .B varargs
477 and declare it in the C file with a '...' parameter for a Win32
478 function, or with an extra VA_LIST16 argument for a Win16 function.
479 See the wsprintf* functions in user.exe.spec and user32.spec for an
480 example.
481 .SS "Variable ordinals"
482 Syntax:
484 .IB ordinal\  variable
485 .RI [ flags ]\  exportname \ \fB(\fR\ [ data... ] \ \fB)
487 This declaration defines data storage as 32-bit words at the ordinal
488 specified.
489 .I exportname
490 will be the name available for dynamic
491 linking.
492 .I data
493 can be a decimal number or a hex number preceded by "0x".  The
494 following example defines the variable VariableA at ordinal 2 and
495 containing 4 ints:
497 2 variable VariableA(-1 0xff 0 0)
499 This declaration only works in Win16 spec files. In Win32 you should
501 .B extern
502 instead (see below).
503 .SS "Extern ordinals"
504 Syntax:
506 .IB ordinal\  extern
507 .RI [ flags ]\  exportname \ [ symbolname ]
509 This declaration defines an entry that simply maps to a C symbol
510 (variable or function). It only works in Win32 spec files.
511 .I exportname
512 will point to the symbol
513 .I symbolname
514 that must be defined in the C code. Alternatively, it can be of the
515 form
516 .IB dllname . symbolname
517 to define a forwarded symbol (one whose implementation is in another
518 dll). If
519 .I symbolname
520 is not specified, it is assumed to be identical to
521 .I exportname.
522 .SS "Stub ordinals"
523 Syntax:
525 .IB ordinal\  stub
526 .RI [ flags ]\  exportname \ [\ \fB( args... \fB)\fR\ ]
528 This declaration defines a stub function. It makes the name and
529 ordinal available for dynamic linking, but will terminate execution
530 with an error message if the function is ever called.
531 .SS "Equate ordinals"
532 Syntax:
534 .IB ordinal\  equate
535 .RI [ flags ]\  exportname\ data
537 This declaration defines an ordinal as an absolute value.
538 .I exportname
539 will be the name available for dynamic linking.
540 .I data
541 can be a decimal number or a hex number preceded by "0x".
542 .SS "Api sets"
543 Syntax:
545 .BI apiset\  apiset_dll\  =\  target.dll\ [host.dll:target.dll]
547 This declaration defines that the \fIapiset_dll\fR (of the form
548 api-ms-*) resolves to the \fItarget\fR dll. Optionally other targets
549 can be specified to resolve differently for specific host dlls. For
550 example:
552 api-ms-win-core-processenvironment-l1-1-0 = kernelbase.dll
554 api-ms-win-core-processthreads-l1-1-0 = kernel32.dll \\
556   kernel32.dll:kernelbase.dll
558 If apisets are defined, a corresponding .apiset section will be
559 generated in the PE binary. This requires building the module with the
560 --data-only option.
561 .SH AUTHORS
562 .B winebuild
563 has been worked on by many people over the years. The main authors are
564 Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich
565 Weigand and Eric Youngdale. Many other people have contributed new features
566 and bug fixes. For a complete list, see the git commit logs.
567 .SH BUGS
568 It is not yet possible to use a PE-format dll in an import
569 specification; only Wine dlls can be imported.
571 Bugs can be reported on the
572 .UR https://bugs.winehq.org
573 .B Wine bug tracker
574 .UE .
575 .SH AVAILABILITY
576 .B winebuild
577 is part of the Wine distribution, which is available through WineHQ,
579 .UR https://www.winehq.org/
580 .B Wine development headquarters
581 .UE .
582 .SH "SEE ALSO"
583 .BR wine (1),
584 .BR winegcc (1),
585 .BR wrc (1),
587 .UR https://www.winehq.org/help
588 .B Wine documentation and support
589 .UE .