WINEBUILD(1)

NAME
winebuild - Wine dll builder

SYNOPSIS
winebuild [options] [input files]

DESCRIPTION
winebuild generates the C and assembly files that are necessary to build a Wine dll, which is basically a Win32 dll encapsulated inside a Unix library.

winebuild has different modes, depending on what kind of file it is asked to generate. The mode is specified by one of the mode options specified below. In addition to the mode option, various other command-line option can be specified, as described in the OPTIONS section.

MODE OPTIONS
You have to specify exactly one of the following options, depending on what you want winebuild to generate.

--dll=filename
    Build a C file from a .spec file (see SPEC FILE SYNTAX for details), or from a standard Windows .def file. The resulting C file must be compiled and linked to the other object files to build a working Wine dll.
    In that mode, the input files should be the list of all object files that will be linked into the final dll, to allow winebuild to get the list of all undefined symbols that need to be imported from other dlls.

--exe=name
    Build a C file for the named executable. This is basically the same as the --dll mode except that it doesn't require a .spec file as input, since an executable doesn't export functions. The resulting C file must be compiled and linked to the other object files to build a working Wine executable, and all the other object files must be listed as input files.

--def=file.spec
    Build a .def file from a spec file. This is used when building dlls with a PE (Win32) compiler.

--debug
    Build a C file containing the definitions for debugging channels. In that mode the input files should be a list of C files to search for debug channel definitions. The resulting C file must be compiled and linked with the dll.

--relay16
    Generate the assembly code for the 16-bit relay routines. This is for Wine internal usage only, you should never need to use this option.

--relay32
    Generate the assembly code for the 32-bit relay routines. This is for Wine internal usage only, you should never need to use this option.

OPTIONS

-C, --source-dir=directory
    Change to the specified directory before reading source files. Only meaningful in --debug mode.

-D symbol
    Ignored for compatibility with the C compiler.

-e, --entry=function
    Specify the module entry point function; if not specified, the default is DllMain for dlls, and WinMain for executables (if WinMain is not defined, the standard C main is used instead). This is only valid for Win32 modules.

-f flags
    Ignored for compatibility with the C compiler.

-F, --filename=filename
    Set the file name of the module. The default is to use the base name of the spec file (without any extension).

-h, --help
    Display a usage message and exit.

-H, --heap=size
    Specify the size of the module local heap in bytes (only valid for Win16 modules); default is no local heap.

-i, --ignore=[-]symbol[,[-]symbol]
    Specify a list of symbols that should be ignored when resolving undefined symbols against the imported libraries. This forces these symbols to be resolved from the Unix C library (or from another Unix library linked with the application). If a symbol is prefixed by '-' it is removed from the list instead of being added; a stand-alone '-' clears the whole list.

-I directory
    Ignored for compatibility with the C compiler.

-k, --kill-at
    Remove the stdcall decorations from the symbol names in the generated .def file. Only meaningful in --def mode.

-K flags
    Ignored for compatibility with the C compiler.

-L, --library-path=directory
    Append the specified directory to the list of directories that are searched for import libraries.

-l, --library=name
    Import the specified library, looking for a corresponding libname.def file in the directories specified with the -L option.

-d, --delay-lib=name
    Same as the -l option, but import the specified library in delayed mode (i.e. the library won't be loaded until a function imported from it is actually called).

-M, --main-module=module
    Specify that we are building a 16-bit dll, that will ultimately be linked together with the 32-bit dll specified in module. Only meaningful in --dll mode.

-N, --dll-name=dllname
    Set the internal name of the module. It is only used in Win16 modules. The default is to use the base name of the spec file (without any extension). This is used for KERNEL, since it lives in KRNL386.EXE. It shouldn't be needed otherwise.

-o, --output=file
    Set the name of the output file (default is standard output).

-r, --res=rsrc.res
    Load resources from the specified binary resource file. The rsrc.res can be produced from a source resource file with wrc(1) (or with a Windows resource compiler).
    This option is only necessary for Win16 resource files, the Win32 ones can simply listed as input files and will automatically be handled correctly (though the -r option will also work for Win32 files).

--subsystem=subsystem[:major[.minor]]
    Set the subsystem of the executable, which can be one of the following:
    console for a command line executable,
    windows for a graphical executable,
    native for a native-mode dll.
    The entry point of a command line executable is a normal C main function. A wmain function can be used instead if you need the argument array to use Unicode strings. A graphical executable has a WinMain entry point.
    Optionally a major and minor subsystem version can also be specified; the default subsystem version is 4.0.

--version
    Display the program version and exit.

-w, --warnings
    Turn on warnings.

SPEC FILE SYNTAX

  General syntax
A spec file should contain a list of ordinal declarations. The general syntax is the following:

ordinal functype [flags] exportname ( [args...] ) [handler]
ordinal variable [flags] exportname ( [data...] )
ordinal extern [flags] exportname [symbolname]
ordinal stub [flags] exportname
ordinal equate [flags] exportname data
# comments

Declarations must fit on a single line, except if the end of line is escaped using a backslash character. The # character anywhere in a line causes the rest of the line to be ignored as a comment.

ordinal specifies the ordinal number corresponding to the entry point, or '@' for automatic ordinal allocation (Win32 only).

flags is a series of optional flags, preceded by a '-' character. The supported flags are:

    -norelay
        The entry point is not displayed in relay debugging traces (Win32 only).

    -noname
        The entry point will be imported by ordinal instead of by name.

    -ret16
        The function returns a 16-bit value (Win16 only).

    -ret64
        The function returns a 64-bit value (Win32 only).

    -i386
        The entry point is only available on i386 platforms.

    -register
        The function uses CPU register to pass arguments.

    -private
        The function cannot be imported from other dlls, it can only be accessed through GetProcAddress.

  Function ordinals
Syntax:
ordinal functype [flags] exportname ( [args...] ) [handler]
This declaration defines a function entry point. The prototype defined by exportname ( [args...] ) specifies the name available for dynamic linking and the format of the arguments. '@' can be used instead of exportname for ordinal-only exports.

functype should be one of:

    stdcall
        for a normal Win32 function

    pascal
        for a normal Win16 function

    cdecl
        for a Win16 or Win32 function using the C calling convention

    varargs
        for a Win16 or Win32 function using the C calling convention with a variable number of arguments

args should be one or several of:

    word
        (16-bit unsigned value)

    s_word
        (16-bit signed word)

    long
        (32-bit value)

    double
        (64-bit value)

    ptr (linear pointer)

    str (linear pointer to a null-terminated ASCII string)

    wstr
        (linear pointer to a null-terminated Unicode string)

    segptr
        (segmented pointer)

    segstr
        (segmented pointer to a null-terminated ASCII string).

    Only ptr, str, wstr, long and double are valid for Win32 functions.

handler is the name of the actual C function that will implement that entry point in 32-bit mode. The handler can also be specified as dllname.function to define a forwarded function (one whose implementation is in another dll). If handler is not specified, it is assumed to be identical to exportname.

This first example defines an entry point for the 32-bit GetFocus() call:

    @ stdcall GetFocus() GetFocus

This second example defines an entry point for the 16-bit CreateWindow() call (the ordinal 100 is just an example); it also shows how long lines can be split using a backslash:

    100 pascal CreateWindow(ptr ptr long s_word s_word s_word \
        s_word word word word ptr) WIN_CreateWindow

To declare a function using a variable number of arguments, specify the function as varargs and declare it in the C file with a '...' parameter for a Win32 function, or with an extra VA_LIST16 argument for a Win16 function. See the wsprintf* functions in user.exe.spec and user32.spec for an example.

  Variable ordinals
Syntax:
ordinal variable [flags] exportname ( [data...] )

This declaration defines data storage as 32-bit words at the ordinal specified. exportname will be the name available for dynamic linking. data can be a decimal number or a hex number preceeded by "0x". The following example defines the variable VariableA at ordinal 2 and containing 4 ints:

    2 variable VariableA(-1 0xff 0 0)

This declaration only works in Win16 spec files. In Win32 you should use extern instead (see below).

  Extern ordinals
Syntax:
ordinal extern [flags] exportname [symbolname]

This declaration defines an entry that simply maps to a C symbol (variable or function). It only works in Win32 spec files. exportname will point to the symbol symbolname that must be defined in the C code. Alternatively, it can be of the form dllname.symbolname to define a forwarded symbol (one whose implementation is in another dll). If symbolname is not specified, it is assumed to be identical to exportname.

  Stub ordinals
Syntax:
ordinal stub [flags] exportname

This declaration defines a stub function. It makes the name and ordinal available for dynamic linking, but will terminate execution with an error message if the function is ever called.

  Equate ordinals
Syntax:
ordinal equate [flags] exportname data

This declaration defines an ordinal as an absolute value. exportname will be the name available for dynamic linking. data can be a decimal number or a hex number preceeded by "0x".

AUTHORS
winebuild has been worked on by many people over the years. The main authors are Robert J. Amstadt, Alexandre Julliard, Martin von Loewis, Ulrich Weigand and Eric Youngdale. Many other Wine developers have contributed, please check the file Changelog in the Wine distribution for the complete details.

BUGS
It is not yet possible to use a PE-format dll in an import specification; only Wine dlls can be imported.

If you find a bug, please submit a bug report at http://bugs.winehq.org. (http://bugs.winehq.org)

AVAILABILITY
winebuild is part of the wine distribution, which is available through WineHQ, the wine development headquarters, at http://www.winehq.org/. (http://www.winehq.org/)

SEE ALSO
wine(1), wrc(1).