Winebuild vendor drop
Added: vendor/wine/tools/winebuild/current/
Added: vendor/wine/tools/winebuild/current/CVS/
Added: vendor/wine/tools/winebuild/current/CVS/Entries
Added: vendor/wine/tools/winebuild/current/CVS/Repository
Added: vendor/wine/tools/winebuild/current/CVS/Root
Added: vendor/wine/tools/winebuild/current/CVS/Tag
Added: vendor/wine/tools/winebuild/current/Makefile.in
Added: vendor/wine/tools/winebuild/current/build.h
Added: vendor/wine/tools/winebuild/current/import.c
Added: vendor/wine/tools/winebuild/current/main.c
Added: vendor/wine/tools/winebuild/current/parser.c
Added: vendor/wine/tools/winebuild/current/relay.c
Added: vendor/wine/tools/winebuild/current/res16.c
Added: vendor/wine/tools/winebuild/current/res32.c
Added: vendor/wine/tools/winebuild/current/spec16.c
Added: vendor/wine/tools/winebuild/current/spec32.c
Added: vendor/wine/tools/winebuild/current/utils.c
Added: vendor/wine/tools/winebuild/current/winebuild.man.in

Added: vendor/wine/tools/winebuild/current/CVS/Entries
--- vendor/wine/tools/winebuild/current/CVS/Entries	2005-02-14 16:14:12 UTC (rev 13564)
+++ vendor/wine/tools/winebuild/current/CVS/Entries	2005-02-14 16:16:27 UTC (rev 13565)
@@ -0,0 +1,14 @@
+/.cvsignore/1.2/Mon Feb 14 16:13:00 2005//TWine-20050211
+/Makefile.in/1.17/Mon Feb 14 16:13:00 2005//TWine-20050211
+/build.h/1.54/Mon Feb 14 16:13:00 2005//TWine-20050211
+/import.c/1.72/Mon Feb 14 16:13:00 2005//TWine-20050211
+/main.c/1.59/Mon Feb 14 16:13:00 2005//TWine-20050211
+/parser.c/1.55/Mon Feb 14 16:13:00 2005//TWine-20050211
+/relay.c/1.35/Mon Feb 14 16:13:00 2005//TWine-20050211
+/res16.c/1.12/Mon Feb 14 16:13:00 2005//TWine-20050211
+/res32.c/1.16/Mon Feb 14 16:13:00 2005//TWine-20050211
+/spec16.c/1.49/Mon Feb 14 16:13:00 2005//TWine-20050211
+/spec32.c/1.85/Mon Feb 14 16:13:00 2005//TWine-20050211
+/utils.c/1.20/Mon Feb 14 16:13:00 2005//TWine-20050211
+/winebuild.man.in/1.28/Mon Feb 14 16:13:00 2005//TWine-20050211
+D

Added: vendor/wine/tools/winebuild/current/CVS/Repository
--- vendor/wine/tools/winebuild/current/CVS/Repository	2005-02-14 16:14:12 UTC (rev 13564)
+++ vendor/wine/tools/winebuild/current/CVS/Repository	2005-02-14 16:16:27 UTC (rev 13565)
@@ -0,0 +1 @@
+wine/tools/winebuild

Added: vendor/wine/tools/winebuild/current/CVS/Root
--- vendor/wine/tools/winebuild/current/CVS/Root	2005-02-14 16:14:12 UTC (rev 13564)
+++ vendor/wine/tools/winebuild/current/CVS/Root	2005-02-14 16:16:27 UTC (rev 13565)
@@ -0,0 +1 @@
+:pserver:cvs@cvs.winehq.com:2401/home/wine

Added: vendor/wine/tools/winebuild/current/CVS/Tag
--- vendor/wine/tools/winebuild/current/CVS/Tag	2005-02-14 16:14:12 UTC (rev 13564)
+++ vendor/wine/tools/winebuild/current/CVS/Tag	2005-02-14 16:16:27 UTC (rev 13565)
@@ -0,0 +1 @@
+NWine-20050211

Added: vendor/wine/tools/winebuild/current/Makefile.in
--- vendor/wine/tools/winebuild/current/Makefile.in	2005-02-14 16:14:12 UTC (rev 13564)
+++ vendor/wine/tools/winebuild/current/Makefile.in	2005-02-14 16:16:27 UTC (rev 13565)
@@ -0,0 +1,42 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+EXEEXT    = @EXEEXT@
+
+PROGRAMS = winebuild$(EXEEXT)
+MODULE   = none
+
+C_SRCS = \
+	import.c \
+	main.c \
+	parser.c \
+	relay.c \
+	res16.c \
+	res32.c \
+	spec16.c \
+	spec32.c \
+	utils.c
+
+all: $(PROGRAMS) winebuild.man
+
+@MAKE_RULES@
+
+winebuild$(EXEEXT): $(OBJS)
+	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBPORT) $(LDFLAGS)
+
+winebuild.man: winebuild.man.in
+	sed -e 's,@PACKAGE_STRING\@,@PACKAGE_STRING@,g' $(SRCDIR)/winebuild.man.in >$@ || ($(RM) $@ && false)
+
+install:: $(PROGRAMS) winebuild.man
+	$(MKINSTALLDIRS) $(bindir) $(mandir)/man$(prog_manext)
+	$(INSTALL_PROGRAM) winebuild$(EXEEXT) $(bindir)/winebuild$(EXEEXT)
+	$(INSTALL_DATA) winebuild.man $(mandir)/man$(prog_manext)/winebuild.$(prog_manext)
+
+uninstall::
+	$(RM) $(bindir)/winebuild$(EXEEXT) $(mandir)/man$(prog_manext)/winebuild.$(prog_manext)
+
+clean::
+	$(RM) winebuild.man
+
+### Dependencies:
Property changes on: vendor/wine/tools/winebuild/current/Makefile.in
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: vendor/wine/tools/winebuild/current/build.h
--- vendor/wine/tools/winebuild/current/build.h	2005-02-14 16:14:12 UTC (rev 13564)
+++ vendor/wine/tools/winebuild/current/build.h	2005-02-14 16:16:27 UTC (rev 13565)
@@ -0,0 +1,212 @@
+/*
+ * Copyright 1993 Robert J. Amstadt
+ * Copyright 1995 Martin von Loewis
+ * Copyright 1995, 1996, 1997 Alexandre Julliard
+ * Copyright 1997 Eric Youngdale
+ * Copyright 1999 Ulrich Weigand
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __WINE_BUILD_H
+#define __WINE_BUILD_H
+
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef enum
+{
+    TYPE_VARIABLE,     /* variable */
+    TYPE_PASCAL,       /* pascal function (Win16) */
+    TYPE_ABS,          /* absolute value (Win16) */
+    TYPE_STUB,         /* unimplemented stub */
+    TYPE_STDCALL,      /* stdcall function (Win32) */
+    TYPE_CDECL,        /* cdecl function (Win32) */
+    TYPE_VARARGS,      /* varargs function (Win32) */
+    TYPE_EXTERN,       /* external symbol (Win32) */
+    TYPE_NBTYPES
+} ORD_TYPE;
+
+typedef enum
+{
+    SPEC_WIN16,
+    SPEC_WIN32
+} SPEC_TYPE;
+
+typedef struct
+{
+    int n_values;
+    int *values;
+} ORD_VARIABLE;
+
+typedef struct
+{
+    char arg_types[21];
+} ORD_FUNCTION;
+
+typedef struct
+{
+    int value;
+} ORD_ABS;
+
+typedef struct
+{
+    ORD_TYPE    type;
+    int         ordinal;
+    int         offset;
+    int         lineno;
+    int         flags;
+    char       *name;         /* public name of this function */
+    char       *link_name;    /* name of the C symbol to link to */
+    char       *export_name;  /* name exported under for noname exports */
+    union
+    {
+        ORD_VARIABLE   var;
+        ORD_FUNCTION   func;
+        ORD_ABS        abs;
+    } u;
+} ORDDEF;
+
+typedef struct
+{
+    char            *file_name;          /* file name of the dll */
+    char            *dll_name;           /* internal name of the dll */
+    char            *owner_name;         /* name of the 32-bit dll owning this one */
+    char            *init_func;          /* initialization routine */
+    SPEC_TYPE        type;               /* type of dll (Win16/Win32) */
+    int              base;               /* ordinal base */
+    int              limit;              /* ordinal limit */
+    int              stack_size;         /* exe stack size */
+    int              heap_size;          /* exe heap size */
+    int              nb_entry_points;    /* number of used entry points */
+    int              alloc_entry_points; /* number of allocated entry points */
+    int              nb_names;           /* number of entry points with names */
+    int              nb_resources;       /* number of resources */
+    int              characteristics;    /* characteristics for the PE header */
+    int              subsystem;          /* subsystem id */
+    int              subsystem_major;    /* subsystem version major number */
+    int              subsystem_minor;    /* subsystem version minor number */
+    ORDDEF          *entry_points;       /* dll entry points */
+    ORDDEF         **names;              /* array of entry point names (points into entry_points) */
+    ORDDEF         **ordinals;           /* array of dll ordinals (points into entry_points) */
+    struct resource *resources;          /* array of dll resources (format differs between Win16/Win32) */
+} DLLSPEC;
+
+/* entry point flags */
+#define FLAG_NORELAY   0x01  /* don't use relay debugging for this function */
+#define FLAG_NONAME    0x02  /* don't import function by name */
+#define FLAG_RET16     0x04  /* function returns a 16-bit value */
+#define FLAG_RET64     0x08  /* function returns a 64-bit value */
+#define FLAG_I386      0x10  /* function is i386 only */
+#define FLAG_REGISTER  0x20  /* use register calling convention */
+#define FLAG_PRIVATE   0x40  /* function is private (cannot be imported) */
+
+#define FLAG_FORWARD   0x80  /* function is a forwarded name */
+
+  /* Offset of a structure field relative to the start of the struct */
+#define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
+
+  /* Offset of register relative to the start of the CONTEXT struct */
+#define CONTEXTOFFSET(reg)  STRUCTOFFSET(CONTEXT86,reg)
+
+  /* Offset of register relative to the start of the STACK16FRAME struct */
+#define STACK16OFFSET(reg)  STRUCTOFFSET(STACK16FRAME,reg)
+
+  /* Offset of register relative to the start of the STACK32FRAME struct */
+#define STACK32OFFSET(reg)  STRUCTOFFSET(STACK32FRAME,reg)
+
+  /* Offset of the stack pointer relative to %fs:(0) */
+#define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack))
+
+
+#define MAX_ORDINALS  65535
+
+/* global functions */
+
+#ifndef __GNUC__
+#define __attribute__(X)
+#endif
+
+extern void *xmalloc (size_t size);
+extern void *xrealloc (void *ptr, size_t size);
+extern char *xstrdup( const char *str );
+extern char *strupper(char *s);
+extern void fatal_error( const char *msg, ... )
+   __attribute__ ((__format__ (__printf__, 1, 2)));
+extern void fatal_perror( const char *msg, ... )
+   __attribute__ ((__format__ (__printf__, 1, 2)));
+extern void error( const char *msg, ... )
+   __attribute__ ((__format__ (__printf__, 1, 2)));
+extern void warning( const char *msg, ... )
+   __attribute__ ((__format__ (__printf__, 1, 2)));
+extern void output_standard_file_header( FILE *outfile );
+extern FILE *open_input_file( const char *srcdir, const char *name );
+extern void close_input_file( FILE *file );
+extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
+                        const char *label, int constant );
+extern int remove_stdcall_decoration( char *name );
+extern DLLSPEC *alloc_dll_spec(void);
+extern void free_dll_spec( DLLSPEC *spec );
+extern const char *make_c_identifier( const char *str );
+extern int get_alignment(int alignBoundary);
+
+extern void add_import_dll( const char *name, int delay );
+extern void add_ignore_symbol( const char *name );
+extern void read_undef_symbols( char **argv );
+extern int resolve_imports( DLLSPEC *spec );
+extern int output_imports( FILE *outfile, DLLSPEC *spec );
+extern int load_res32_file( const char *name, DLLSPEC *spec );
+extern void output_resources( FILE *outfile, DLLSPEC *spec );
+extern void load_res16_file( const char *name, DLLSPEC *spec );
+extern int output_res16_data( FILE *outfile, DLLSPEC *spec );
+extern int output_res16_directory( unsigned char *buffer, DLLSPEC *spec );
+extern void output_dll_init( FILE *outfile, const char *constructor, const char *destructor );
+
+extern void BuildRelays16( FILE *outfile );
+extern void BuildRelays32( FILE *outfile );
+extern void BuildSpec16File( FILE *outfile, DLLSPEC *spec );
+extern void BuildSpec32File( FILE *outfile, DLLSPEC *spec );
+extern void BuildDef32File( FILE *outfile, DLLSPEC *spec );
+extern void BuildDebugFile( FILE *outfile, const char *srcdir, char **argv );
+
+extern int parse_spec_file( FILE *file, DLLSPEC *spec );
+extern int parse_def_file( FILE *file, DLLSPEC *spec );
+extern int parse_debug_channels( const char *srcdir, const char *filename );
+
+/* global variables */
+
+extern int current_line;
+extern int UsePIC;
+extern int debugging;
+extern int nb_debug_channels;
+extern int nb_lib_paths;
+extern int nb_errors;
+extern int display_warnings;
+extern int kill_at;
+
+extern char *input_file_name;
+extern const char *output_file_name;
+extern char **debug_channels;
+extern char **lib_path;
+
+extern char *ld_command;
+extern char *nm_command;
+
+#endif  /* __WINE_BUILD_H */
Property changes on: vendor/wine/tools/winebuild/current/build.h
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: vendor/wine/tools/winebuild/current/import.c
--- vendor/wine/tools/winebuild/current/import.c	2005-02-14 16:14:12 UTC (rev 13564)
+++ vendor/wine/tools/winebuild/current/import.c	2005-02-14 16:16:27 UTC (rev 13565)
@@ -0,0 +1,1107 @@
+/*
+ * DLL imports support
+ *
+ * Copyright 2000, 2004 Alexandre Julliard
+ * Copyright 2000 Eric Pouech
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <ctype.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include "windef.h"
+#include "winbase.h"
+#include "build.h"
+
+struct import
+{
+    DLLSPEC     *spec;         /* description of the imported dll */
+    int          delay;       /* delay or not dll loading ? */
+    ORDDEF     **exports;     /* functions exported from this dll */
+    int          nb_exports;  /* number of exported functions */
+    ORDDEF     **imports;     /* functions we want to import from this dll */
+    int          nb_imports;  /* number of imported functions */
+};
+
+static char **undef_symbols;  /* list of undefined symbols */
+static int nb_undef_symbols = -1;
+static int undef_size;
+
+static char **ignore_symbols; /* list of symbols to ignore */
+static int nb_ignore_symbols;
+static int ignore_size;
+
+static char *ld_tmp_file;  /* ld temp file name */
+
+static struct import **dll_imports = NULL;
+static int nb_imports = 0;      /* number of imported dlls (delayed or not) */
+static int nb_delayed = 0;      /* number of delayed dlls */
+static int total_imports = 0;   /* total number of imported functions */
+static int total_delayed = 0;   /* total number of imported functions in delayed DLLs */
+
+/* list of symbols that are ignored by default */
+static const char * const default_ignored_symbols[] =
+{
+    "abs",
+    "acos",
+    "asin",
+    "atan",
+    "atan2",
+    "atof",
+    "atoi",
+    "atol",
+    "bsearch",
+    "ceil",
+    "cos",
+    "cosh",
+    "exp",
+    "fabs",
+    "floor",
+    "fmod",
+    "frexp",
+    "labs",
+    "log",
+    "log10",
+    "memchr",
+    "memcmp",
+    "memcpy",
+    "memmove",
+    "memset",
+    "modf",
+    "pow",
+    "qsort",
+    "sin",
+    "sinh",
+    "sqrt",
+    "strcat",
+    "strchr",
+    "strcmp",
+    "strcpy",
+    "strcspn",
+    "strlen",
+    "strncat",
+    "strncmp",
+    "strncpy",
+    "strpbrk",
+    "strrchr",
+    "strspn",
+    "strstr",
+    "tan",
+    "tanh"
+};
+
+#ifdef __powerpc__
+# ifdef __APPLE__
+# define ppc_high(mem) "ha16(" mem ")"
+# define ppc_low(mem)  "lo16(" mem ")"
+static const char * const ppc_reg[32] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+                                          "r8", "r9", "r10","r11","r12","r13","r14","r15",
+                                          "r16","r17","r18","r19","r20","r21","r22","r23",
+                                          "r24","r25","r26","r27","r28","r29","r30","r31" };
+# else  /* __APPLE__ */
+# define ppc_high(mem) "(" mem ")@hi"
+# define ppc_low(mem)  "(" mem ")@l"
+static const char * const ppc_reg[32] = { "0", "1", "2", "3", "4", "5", "6", "7",
+                                          "8", "9", "10","11","12","13","14","15",
+                                          "16","17","18","19","20","21","22","23",
+                                          "24","25","26","27","28","29","30","31" };
+# endif  /* __APPLE__ */
+#endif  /* __powerpc__ */
+
+/* compare function names; helper for resolve_imports */
+static int name_cmp( const void *name, const void *entry )
+{
+    return strcmp( *(const char* const *)name, *(const char* const *)entry );
+}
+
+/* compare function names; helper for resolve_imports */
+static int func_cmp( const void *func1, const void *func2 )
+{
+    const ORDDEF *odp1 = *(const ORDDEF * const *)func1;
+    const ORDDEF *odp2 = *(const ORDDEF * const *)func2;
+    return strcmp( odp1->name ? odp1->name : odp1->export_name,
+                   odp2->name ? odp2->name : odp2->export_name );
+}
+
+/* locate a symbol in a (sorted) list */
+inline static const char *find_symbol( const char *name, char **table, int size )
+{
+    char **res = NULL;
+
+    if (table) {
+        res = bsearch( &name, table, size, sizeof(*table), name_cmp );
+    }
+
+    return res ? *res : NULL;
+}
+
+/* locate an export in a (sorted) export list */
+inline static ORDDEF *find_export( const char *name, ORDDEF **table, int size )
+{
+    ORDDEF func, *odp, **res = NULL;
+
+    func.name = (char *)name;
+    func.ordinal = -1;
+    odp = &func;
+    if (table) res = bsearch( &odp, table, size, sizeof(*table), func_cmp );
+    return res ? *res : NULL;
+}
+
+/* sort a symbol table */
+inline static void sort_symbols( char **table, int size )
+{
+    if (table )
+        qsort( table, size, sizeof(*table), name_cmp );
+}
+
+inline static void output_function_size( FILE *outfile, const char *name )
+{
+#ifdef HAVE_ASM_DOT_SIZE
+    fprintf( outfile, "    \"\\t.size " __ASM_NAME("%s") ", . - " __ASM_NAME("%s") "\\n\"\n", name, name);
+#endif
+}
+
+/* free an import structure */
+static void free_imports( struct import *imp )
+{
+    free( imp->exports );
+    free( imp->imports );
+    free_dll_spec( imp->spec );
+    free( imp );
+}
+
+/* remove the temp file at exit */
+static void remove_ld_tmp_file(void)
+{
+    if (ld_tmp_file) unlink( ld_tmp_file );
+}
+
+/* check whether a given dll has already been imported */
+static int is_already_imported( const char *name )
+{
+    int i;
+
+    for (i = 0; i < nb_imports; i++)
+    {
+        if (!strcmp( dll_imports[i]->spec->file_name, name )) return 1;
+    }
+    return 0;
+}
+
+/* open the .so library for a given dll in a specified path */
+static char *try_library_path( const char *path, const char *name )
+{
+    char *buffer;
+    int fd;
+
+    buffer = xmalloc( strlen(path) + strlen(name) + 9 );
+    sprintf( buffer, "%s/lib%s.def", path, name );
+
+    /* check if the file exists */
+    if ((fd = open( buffer, O_RDONLY )) != -1)
+    {
+        close( fd );
+        return buffer;
+    }
+    free( buffer );
+    return NULL;
+}
+
+/* open the .so library for a given dll */
+static char *open_library( const char *name )
+{
+    char *fullname;
+    int i;
+
+    for (i = 0; i < nb_lib_paths; i++)
+    {
+        if ((fullname = try_library_path( lib_path[i], name ))) return fullname;
+    }
+    fatal_error( "could not open .def file for %s\n", name );
+    return NULL;
+}
+
+/* read in the list of exported symbols of an import library */
+static int read_import_lib( const char *name, struct import *imp )
+{
+    FILE *f;
+    char *fullname;
+    int i, ret;
+    DLLSPEC *spec = imp->spec;
+
+    imp->exports    = NULL;
+    imp->nb_exports = 0;
+
+    fullname = open_library( name );
+    f = open_input_file( NULL, fullname );
+    free( fullname );
+
+    ret = parse_def_file( f, spec );
+    close_input_file( f );
+    if (!ret) return 0;
+    if (is_already_imported( spec->file_name )) return 0;
+
+    imp->exports = xmalloc( spec->nb_entry_points * sizeof(*imp->exports) );
+
+    for (i = 0; i < spec->nb_entry_points; i++)
+    {
+        ORDDEF *odp = &spec->entry_points[i];
+
+        if (odp->type != TYPE_STDCALL && odp->type != TYPE_CDECL) continue;
+        if (odp->flags & FLAG_PRIVATE) continue;
+        imp->exports[imp->nb_exports++] = odp;
+    }
+    imp->exports = xrealloc( imp->exports, imp->nb_exports * sizeof(*imp->exports) );
+    if (imp->nb_exports)
+        qsort( imp->exports, imp->nb_exports, sizeof(*imp->exports), func_cmp );
+    return 1;
+}
+
+/* add a dll to the list of imports */
+void add_import_dll( const char *name, int delay )
+{
+    struct import *imp;
+    char *fullname;
+
+    fullname = xmalloc( strlen(name) + 5 );
+    strcpy( fullname, name );
+    if (!strchr( fullname, '.' )) strcat( fullname, ".dll" );
+
+    /* check if we already imported it */
+    if (is_already_imported( fullname ))
+    {
+        free( fullname );
+        return;
+    }
+
+    imp = xmalloc( sizeof(*imp) );
+    imp->spec            = alloc_dll_spec();
+    imp->spec->file_name = fullname;
+    imp->delay           = delay;
+    imp->imports         = NULL;
+    imp->nb_imports      = 0;
+    if (delay) nb_delayed++;
+
+    if (read_import_lib( name, imp ))
+    {
+        dll_imports = xrealloc( dll_imports, (nb_imports+1) * sizeof(*dll_imports) );
+        dll_imports[nb_imports++] = imp;
+    }
+    else
+    {
+        free_imports( imp );
+        if (nb_errors) exit(1);
+    }
+}
+
+/* remove an imported dll, based on its index in the dll_imports array */
+static void remove_import_dll( int index )
+{
+    struct import *imp = dll_imports[index];
+
+    memmove( &dll_imports[index], &dll_imports[index+1], sizeof(imp) * (nb_imports - index - 1) );
+    nb_imports--;
+    if (imp->delay) nb_delayed--;
+    free_imports( imp );
+}
+
+/* initialize the list of ignored symbols */
+static void init_ignored_symbols(void)
+{
+    int i;
+
+    nb_ignore_symbols = sizeof(default_ignored_symbols)/sizeof(default_ignored_symbols[0]);
+    ignore_size = nb_ignore_symbols + 32;
+    ignore_symbols = xmalloc( ignore_size * sizeof(*ignore_symbols) );
+    for (i = 0; i < nb_ignore_symbols; i++)
+        ignore_symbols[i] = xstrdup( default_ignored_symbols[i] );
+}
+
+/* add a symbol to the ignored symbol list */
+/* if the name starts with '-' the symbol is removed instead */
+void add_ignore_symbol( const char *name )
+{
+    int i;
+
+    if (!ignore_symbols) init_ignored_symbols();  /* first time around, fill list with defaults */
+
+    if (name[0] == '-')  /* remove it */
+    {
+        if (!name[1])  /* remove everything */
+        {
+            for (i = 0; i < nb_ignore_symbols; i++) free( ignore_symbols[i] );
+            nb_ignore_symbols = 0;
+        }
+        else
+        {
+            for (i = 0; i < nb_ignore_symbols; i++)
+            {
+                if (!strcmp( ignore_symbols[i], name+1 ))
+                {
+                    free( ignore_symbols[i] );
+                    memmove( &ignore_symbols[i], &ignore_symbols[i+1], nb_ignore_symbols - i - 1 );
+                    nb_ignore_symbols--;
+                }
+            }
+        }
+    }
+    else
+    {
+        if (nb_ignore_symbols == ignore_size)
+        {
+            ignore_size += 32;
+            ignore_symbols = xrealloc( ignore_symbols, ignore_size * sizeof(*ignore_symbols) );
+        }
+        ignore_symbols[nb_ignore_symbols++] = xstrdup( name );
+    }
+}
+
+/* add a function to the list of imports from a given dll */
+static void add_import_func( struct import *imp, ORDDEF *func )
+{
+    imp->imports = xrealloc( imp->imports, (imp->nb_imports+1) * sizeof(*imp->imports) );
+    imp->imports[imp->nb_imports++] = func;
+    total_imports++;
+    if (imp->delay) total_delayed++;
+}
+
+/* add a symbol to the undef list */
+inline static void add_undef_symbol( const char *name )
+{
+    if (nb_undef_symbols == undef_size)
+    {
+        undef_size += 128;
+        undef_symbols = xrealloc( undef_symbols, undef_size * sizeof(*undef_symbols) );
+    }
+    undef_symbols[nb_undef_symbols++] = xstrdup( name );
+}
+
+/* remove all the holes in the undefined symbol list; return the number of removed symbols */
+static int remove_symbol_holes(void)
+{
+    int i, off;
+    for (i = off = 0; i < nb_undef_symbols; i++)
+    {
+        if (!undef_symbols[i]) off++;
+        else undef_symbols[i - off] = undef_symbols[i];
+    }
+    nb_undef_symbols -= off;
+    return off;
+}
+
+/* add a symbol to the extra list, but only if needed */
+static int add_extra_symbol( const char **extras, int *count, const char *name, const DLLSPEC *spec )
+{
+    int i;
+
+    if (!find_symbol( name, undef_symbols, nb_undef_symbols ))
+    {
+        /* check if the symbol is being exported by this dll */
+        for (i = 0; i < spec->nb_entry_points; i++)
+        {
+            ORDDEF *odp = &spec->entry_points[i];
+            if (odp->type == TYPE_STDCALL ||
+                odp->type == TYPE_CDECL ||
+                odp->type == TYPE_VARARGS ||
+                odp->type == TYPE_EXTERN)
+            {
+                if (odp->name && !strcmp( odp->name, name )) return 0;
+            }
+        }
+        extras[*count] = name;
+        (*count)++;
+    }
+    return 1;
+}
+
+/* add the extra undefined symbols that will be contained in the generated spec file itself */
+static void add_extra_undef_symbols( const DLLSPEC *spec )
+{
+    const char *extras[10];
+    int i, count = 0, nb_stubs = 0, nb_regs = 0;
+    int kernel_imports = 0, ntdll_imports = 0;
+
+    sort_symbols( undef_symbols, nb_undef_symbols );
+
+    for (i = 0; i < spec->nb_entry_points; i++)
+    {
+        ORDDEF *odp = &spec->entry_points[i];
+        if (odp->type == TYPE_STUB) nb_stubs++;
+        if (odp->flags & FLAG_REGISTER) nb_regs++;
+    }
+
+    /* add symbols that will be contained in the spec file itself */
+    if (!(spec->characteristics & IMAGE_FILE_DLL))
+    {
+        switch (spec->subsystem)
+        {
+        case IMAGE_SUBSYSTEM_WINDOWS_GUI:
+        case IMAGE_SUBSYSTEM_WINDOWS_CUI:
+            kernel_imports += add_extra_symbol( extras, &count, "GetCommandLineA", spec );
+            kernel_imports += add_extra_symbol( extras, &count, "GetStartupInfoA", spec );
+            kernel_imports += add_extra_symbol( extras, &count, "GetModuleHandleA", spec );
+            kernel_imports += add_extra_symbol( extras, &count, "ExitProcess", spec );
+            break;
+        }
+    }
+    if (nb_delayed)
+    {
+        kernel_imports += add_extra_symbol( extras, &count, "LoadLibraryA", spec );
+        kernel_imports += add_extra_symbol( extras, &count, "GetProcAddress", spec );
+    }
+    if (nb_regs)
+        ntdll_imports += add_extra_symbol( extras, &count, "__wine_call_from_32_regs", spec );
+    if (nb_delayed || nb_stubs)
+        ntdll_imports += add_extra_symbol( extras, &count, "RtlRaiseException", spec );
+
+    /* make sure we import the dlls that contain these functions */
+    if (kernel_imports) add_import_dll( "kernel32", 0 );
+    if (ntdll_imports) add_import_dll( "ntdll", 0 );
+
+    if (count)
+    {
+        for (i = 0; i < count; i++) add_undef_symbol( extras[i] );
+        sort_symbols( undef_symbols, nb_undef_symbols );
+    }
+}
+
+/* check if a given imported dll is not needed, taking forwards into account */
+static int check_unused( const struct import* imp, const DLLSPEC *spec )
+{
+    int i;
+    const char *file_name = imp->spec->file_name;
+    size_t len = strlen( file_name );
+    const char *p = strchr( file_name, '.' );
+    if (p && !strcasecmp( p, ".dll" )) len = p - file_name;
+
+    for (i = spec->base; i <= spec->limit; i++)
+    {
+        ORDDEF *odp = spec->ordinals[i];
+        if (!odp || !(odp->flags & FLAG_FORWARD)) continue;
+        if (!strncasecmp( odp->link_name, file_name, len ) &&
+            odp->link_name[len] == '.')
+            return 0;  /* found a forward, it is used */
+    }
+    return 1;
+}
+
+/* combine a list of object files with ld into a single object file */
+/* returns the name of the combined file */
+static const char *ldcombine_files( char **argv )
+{
+    int i, len = 0;
+    char *cmd;
+    int fd, err;
+
+    if (output_file_name && output_file_name[0])
+    {
+        ld_tmp_file = xmalloc( strlen(output_file_name) + 10 );
+        strcpy( ld_tmp_file, output_file_name );
+        strcat( ld_tmp_file, ".XXXXXX.o" );
+    }
+    else ld_tmp_file = xstrdup( "/tmp/winebuild.tmp.XXXXXX.o" );
+
+    if ((fd = mkstemps( ld_tmp_file, 2 ) == -1)) fatal_error( "could not generate a temp file\n" );
+    close( fd );
+    atexit( remove_ld_tmp_file );
+
+    for (i = 0; argv[i]; i++) len += strlen(argv[i]) + 1;
+    cmd = xmalloc( len + strlen(ld_tmp_file) + 8 + strlen(ld_command)  );
+    sprintf( cmd, "%s -r -o %s", ld_command, ld_tmp_file );
+    for (i = 0; argv[i]; i++) sprintf( cmd + strlen(cmd), " %s", argv[i] );
+    err = system( cmd );
+    if (err) fatal_error( "%s -r failed with status %d\n", ld_command, err );
+    free( cmd );
+    return ld_tmp_file;
+}
+
+/* read in the list of undefined symbols */
+void read_undef_symbols( char **argv )
+{
+    static const char name_prefix[] = __ASM_NAME("");
+    static const int prefix_len = sizeof(name_prefix) - 1;
+    FILE *f;
+    char *cmd, buffer[1024];
+    int err;
+    const char *name;
+
+    if (!argv[0]) return;
+
+    undef_size = nb_undef_symbols = 0;
+
+    /* if we have multiple object files, link them together */
+    if (argv[1]) name = ldcombine_files( argv );
+    else name = argv[0];
+
+    cmd = xmalloc( strlen(nm_command) + strlen(name) + 5 );
+    sprintf( cmd, "%s -u %s", nm_command, name );
+    if (!(f = popen( cmd, "r" )))
+        fatal_error( "Cannot execute '%s'\n", cmd );
+
+    while (fgets( buffer, sizeof(buffer), f ))
+    {
+        char *p = buffer + strlen(buffer) - 1;
+        if (p < buffer) continue;
+        if (*p == '\n') *p-- = 0;
+        p = buffer;
+        while (*p == ' ') p++;
+        if (p[0] == 'U' && p[1] == ' ' && p[2]) p += 2;
+        if (prefix_len && !strncmp( p, name_prefix, prefix_len )) p += prefix_len;
+        add_undef_symbol( p );
+    }
+    if ((err = pclose( f ))) warning( "%s failed with status %d\n", cmd, err );
+    free( cmd );
+}
+
+static void remove_ignored_symbols(void)
+{
+    int i;
+
+    if (!ignore_symbols) init_ignored_symbols();
+    sort_symbols( ignore_symbols, nb_ignore_symbols );
+    for (i = 0; i < nb_undef_symbols; i++)
+    {
+        if (find_symbol( undef_symbols[i], ignore_symbols, nb_ignore_symbols ))
+        {
+            free( undef_symbols[i] );
+            undef_symbols[i] = NULL;
+        }
+    }
+    remove_symbol_holes();
+}
+
+/* resolve the imports for a Win32 module */
+int resolve_imports( DLLSPEC *spec )
+{
+    int i, j;
+
+    if (nb_undef_symbols == -1) return 0; /* no symbol file specified */
+
+    add_extra_undef_symbols( spec );
+    remove_ignored_symbols();
+
+    for (i = 0; i < nb_imports; i++)
+    {
+        struct import *imp = dll_imports[i];
+
+        for (j = 0; j < nb_undef_symbols; j++)
+        {
+            ORDDEF *odp = find_export( undef_symbols[j], imp->exports, imp->nb_exports );
+            if (odp)
+            {
+                add_import_func( imp, odp );
+                free( undef_symbols[j] );
+                undef_symbols[j] = NULL;
+            }
+        }
+        /* remove all the holes in the undef symbols list */
+        if (!remove_symbol_holes() && check_unused( imp, spec ))
+        {
+            /* the dll is not used, get rid of it */
+            warning( "%s imported but no symbols used\n", imp->spec->file_name );
+            remove_import_dll( i );
+            i--;
+        }
+    }
+    return 1;
+}
+
+/* output the import table of a Win32 module */
+static int output_immediate_imports( FILE *outfile )
+{
+    int i, j, pos;
+    int nb_imm = nb_imports - nb_delayed;
+    static const char import_thunks[] = "__wine_spec_import_thunks";
+
+    if (!nb_imm) goto done;
+
+    /* main import header */
+
+    fprintf( outfile, "\nstatic struct {\n" );
+    fprintf( outfile, "  struct {\n" );
+    fprintf( outfile, "    void        *OriginalFirstThunk;\n" );
+    fprintf( outfile, "    unsigned int TimeDateStamp;\n" );
+    fprintf( outfile, "    unsigned int ForwarderChain;\n" );
+    fprintf( outfile, "    const char  *Name;\n" );
+    fprintf( outfile, "    void        *FirstThunk;\n" );
+    fprintf( outfile, "  } imp[%d];\n", nb_imm+1 );
+    fprintf( outfile, "  const char *data[%d];\n",
+             total_imports - total_delayed + nb_imm );
+    fprintf( outfile, "} imports = {\n  {\n" );
+
+    /* list of dlls */
+
+    for (i = j = 0; i < nb_imports; i++)
+    {
+        if (dll_imports[i]->delay) continue;
+        fprintf( outfile, "    { 0, 0, 0, \"%s\", &imports.data[%d] },\n",
+                 dll_imports[i]->spec->file_name, j );
+        j += dll_imports[i]->nb_imports + 1;
+    }
+
+    fprintf( outfile, "    { 0, 0, 0, 0, 0 },\n" );
+    fprintf( outfile, "  },\n  {\n" );
+
+    /* list of imported functions */
+
+    for (i = 0; i < nb_imports; i++)
+    {
+        if (dll_imports[i]->delay) continue;
+        fprintf( outfile, "    /* %s */\n", dll_imports[i]->spec->file_name );
+        for (j = 0; j < dll_imports[i]->nb_imports; j++)
+        {
+            ORDDEF *odp = dll_imports[i]->imports[j];
+            if (!(odp->flags & FLAG_NONAME))
+            {
+                unsigned short ord = odp->ordinal;
+                fprintf( outfile, "    \"\\%03o\\%03o%s\",\n",
+                         *(unsigned char *)&ord, *((unsigned char *)&ord + 1), odp->name );
+            }
+            else
[truncated at 1000 lines; 6763 more skipped]