2000-06-23 20:15:35 +00:00
|
|
|
/*
|
|
|
|
* Main function
|
|
|
|
*
|
|
|
|
* Copyright 1993 Robert J. Amstadt
|
|
|
|
* Copyright 1995 Martin von Loewis
|
|
|
|
* Copyright 1995, 1996, 1997 Alexandre Julliard
|
|
|
|
* Copyright 1997 Eric Youngdale
|
|
|
|
* Copyright 1999 Ulrich Weigand
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* 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
|
2000-06-23 20:15:35 +00:00
|
|
|
*/
|
|
|
|
|
2001-10-14 16:18:52 +00:00
|
|
|
#include "config.h"
|
2002-04-25 21:40:56 +00:00
|
|
|
#include "wine/port.h"
|
2001-10-14 16:18:52 +00:00
|
|
|
|
2000-06-23 20:15:35 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
2000-07-15 15:13:09 +00:00
|
|
|
#include <errno.h>
|
2001-01-22 02:17:29 +00:00
|
|
|
#include <string.h>
|
2000-06-23 20:15:35 +00:00
|
|
|
|
|
|
|
#include "build.h"
|
|
|
|
|
2000-12-15 23:04:40 +00:00
|
|
|
ORDDEF *EntryPoints[MAX_ORDINALS];
|
2000-06-23 20:15:35 +00:00
|
|
|
ORDDEF *Ordinals[MAX_ORDINALS];
|
|
|
|
ORDDEF *Names[MAX_ORDINALS];
|
|
|
|
|
|
|
|
SPEC_MODE SpecMode = SPEC_MODE_DLL;
|
|
|
|
int Base = MAX_ORDINALS;
|
|
|
|
int Limit = 0;
|
|
|
|
int DLLHeapSize = 0;
|
|
|
|
int UsePIC = 0;
|
2001-06-07 22:29:03 +00:00
|
|
|
int stack_size = 0;
|
2000-06-23 20:15:35 +00:00
|
|
|
int nb_entry_points = 0;
|
|
|
|
int nb_names = 0;
|
2000-11-05 04:49:13 +00:00
|
|
|
int nb_debug_channels = 0;
|
2000-11-09 20:31:18 +00:00
|
|
|
int nb_lib_paths = 0;
|
2002-03-21 01:38:53 +00:00
|
|
|
int display_warnings = 0;
|
2000-06-23 20:15:35 +00:00
|
|
|
|
2000-11-27 23:48:08 +00:00
|
|
|
/* we only support relay debugging on i386 */
|
|
|
|
#if defined(__i386__) && !defined(NO_TRACE_MSGS)
|
|
|
|
int debugging = 1;
|
|
|
|
#else
|
|
|
|
int debugging = 0;
|
|
|
|
#endif
|
|
|
|
|
2000-06-23 20:15:35 +00:00
|
|
|
char DLLName[80];
|
|
|
|
char DLLFileName[80];
|
2000-07-28 00:07:18 +00:00
|
|
|
char owner_name[80];
|
2000-12-15 23:04:40 +00:00
|
|
|
char *init_func = NULL;
|
2000-11-09 20:31:18 +00:00
|
|
|
char **debug_channels = NULL;
|
|
|
|
char **lib_path = NULL;
|
2000-06-23 20:15:35 +00:00
|
|
|
|
2002-08-01 18:34:12 +00:00
|
|
|
char *input_file_name = NULL;
|
|
|
|
const char *output_file_name = NULL;
|
2000-06-23 20:15:35 +00:00
|
|
|
|
|
|
|
static FILE *input_file;
|
|
|
|
static FILE *output_file;
|
2002-05-14 20:54:58 +00:00
|
|
|
static const char *current_src_dir;
|
2000-06-23 20:15:35 +00:00
|
|
|
|
|
|
|
/* execution mode */
|
2002-02-04 18:48:18 +00:00
|
|
|
static enum
|
|
|
|
{
|
|
|
|
MODE_NONE,
|
|
|
|
MODE_SPEC,
|
2002-05-11 23:06:32 +00:00
|
|
|
MODE_EXE,
|
2002-02-04 18:48:18 +00:00
|
|
|
MODE_GLUE,
|
|
|
|
MODE_DEF,
|
2002-05-14 20:54:58 +00:00
|
|
|
MODE_DEBUG,
|
2002-02-04 18:48:18 +00:00
|
|
|
MODE_RELAY16,
|
|
|
|
MODE_RELAY32
|
|
|
|
} exec_mode = MODE_NONE;
|
2000-06-23 20:15:35 +00:00
|
|
|
|
2002-07-28 17:52:01 +00:00
|
|
|
/* set the dll file name from the input file name */
|
|
|
|
static void set_dll_file_name( const char *name )
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
2002-08-31 19:04:14 +00:00
|
|
|
if ((p = strrchr( name, '\\' ))) name = p + 1;
|
2002-07-28 17:52:01 +00:00
|
|
|
if ((p = strrchr( name, '/' ))) name = p + 1;
|
|
|
|
strcpy( DLLFileName, name );
|
|
|
|
if ((p = strrchr( DLLFileName, '.' )) && !strcmp( p, ".spec" )) *p = 0;
|
|
|
|
if (!strchr( DLLFileName, '.' )) strcat( DLLFileName, ".dll" );
|
|
|
|
}
|
|
|
|
|
2000-06-23 20:15:35 +00:00
|
|
|
/* cleanup on program exit */
|
|
|
|
static void cleanup(void)
|
|
|
|
{
|
|
|
|
if (output_file_name) unlink( output_file_name );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* command-line option handling
|
|
|
|
*/
|
|
|
|
|
2001-01-11 22:31:04 +00:00
|
|
|
struct option_descr
|
2000-06-23 20:15:35 +00:00
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int has_arg;
|
|
|
|
void (*func)();
|
|
|
|
const char *usage;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void do_output( const char *arg );
|
|
|
|
static void do_usage(void);
|
2002-03-21 01:38:53 +00:00
|
|
|
static void do_warnings(void);
|
2002-05-14 20:54:58 +00:00
|
|
|
static void do_f_flags( const char *arg );
|
|
|
|
static void do_define( const char *arg );
|
|
|
|
static void do_include( const char *arg );
|
2002-07-05 00:20:42 +00:00
|
|
|
static void do_k_flags( const char *arg );
|
2002-05-11 23:06:32 +00:00
|
|
|
static void do_exe_mode( const char *arg );
|
2002-06-21 19:15:45 +00:00
|
|
|
static void do_module( const char *arg );
|
2002-09-12 22:51:20 +00:00
|
|
|
static void do_heap( const char *arg );
|
2002-09-12 17:23:25 +00:00
|
|
|
static void do_name( const char *arg );
|
2000-06-23 20:15:35 +00:00
|
|
|
static void do_spec( const char *arg );
|
2002-02-04 18:48:18 +00:00
|
|
|
static void do_def( const char *arg );
|
2002-05-11 23:06:32 +00:00
|
|
|
static void do_exe( const char *arg );
|
2002-08-01 18:34:12 +00:00
|
|
|
static void do_glue(void);
|
2001-12-11 00:50:33 +00:00
|
|
|
static void do_relay16(void);
|
|
|
|
static void do_relay32(void);
|
2002-05-14 20:54:58 +00:00
|
|
|
static void do_debug(void);
|
2002-08-01 18:34:12 +00:00
|
|
|
static void do_sym(void);
|
2002-05-14 20:54:58 +00:00
|
|
|
static void do_chdir( const char *arg );
|
2000-11-09 20:31:18 +00:00
|
|
|
static void do_lib( const char *arg );
|
2002-05-09 00:05:48 +00:00
|
|
|
static void do_import( const char *arg );
|
|
|
|
static void do_dimport( const char *arg );
|
2002-05-11 23:06:32 +00:00
|
|
|
static void do_rsrc( const char *arg );
|
2000-06-23 20:15:35 +00:00
|
|
|
|
2001-01-11 22:31:04 +00:00
|
|
|
static const struct option_descr option_table[] =
|
2000-06-23 20:15:35 +00:00
|
|
|
{
|
2001-12-11 00:50:33 +00:00
|
|
|
{ "-h", 0, do_usage, "-h Display this help message" },
|
2002-03-21 01:38:53 +00:00
|
|
|
{ "-w", 0, do_warnings,"-w Turn on warnings" },
|
2002-05-14 20:54:58 +00:00
|
|
|
{ "-C", 1, do_chdir, "-C dir Change directory to <dir> before opening source files" },
|
|
|
|
{ "-f", 1, do_f_flags, "-f flags Compiler flags (only -fPIC is supported)" },
|
|
|
|
{ "-D", 1, do_define, "-D sym Ignored for C flags compatibility" },
|
|
|
|
{ "-I", 1, do_include, "-I dir Ignored for C flags compatibility" },
|
2002-07-05 00:20:42 +00:00
|
|
|
{ "-K", 1, do_k_flags, "-K flags Compiler flags (only -KPIC is supported)" },
|
2002-05-11 23:06:32 +00:00
|
|
|
{ "-m", 1, do_exe_mode,"-m mode Set the executable mode (cui|gui|cuiw|guiw)" },
|
2002-06-21 19:15:45 +00:00
|
|
|
{ "-M", 1, do_module, "-M module Set the name of the main (Win32) module for a Win16 dll" },
|
2001-12-11 00:50:33 +00:00
|
|
|
{ "-L", 1, do_lib, "-L directory Look for imports libraries in 'directory'" },
|
2002-05-09 00:05:48 +00:00
|
|
|
{ "-l", 1, do_import, "-l lib.dll Import the specified library" },
|
|
|
|
{ "-dl", 1, do_dimport, "-dl lib.dll Delay-import the specified library" },
|
2002-09-12 22:51:20 +00:00
|
|
|
{ "-H", 1, do_heap, "-H size Set the heap size for a Win16 dll" },
|
2002-09-12 17:23:25 +00:00
|
|
|
{ "-N", 1, do_name, "-N dllname Set the DLL name (default: set from input file name)" },
|
2002-05-11 23:06:32 +00:00
|
|
|
{ "-res", 1, do_rsrc, "-res rsrc.res Load resources from rsrc.res" },
|
2002-08-01 18:34:12 +00:00
|
|
|
{ "-o", 1, do_output, "-o name Set the output file name (default: stdout)\n" },
|
|
|
|
{ "-sym", 0, do_sym, NULL }, /* ignored for backwards compatibility */
|
2001-12-11 00:50:33 +00:00
|
|
|
{ "-spec", 1, do_spec, "-spec file.spec Build a .c file from a spec file" },
|
2002-02-04 18:48:18 +00:00
|
|
|
{ "-def", 1, do_def, "-def file.spec Build a .def file from a spec file" },
|
2002-05-11 23:06:32 +00:00
|
|
|
{ "-exe", 1, do_exe, "-exe name Build a .c file from the named executable" },
|
2002-05-14 20:54:58 +00:00
|
|
|
{ "-debug", 0, do_debug, "-debug [files] Build a .c file containing debug channels declarations" },
|
2002-08-01 18:34:12 +00:00
|
|
|
{ "-glue", 0, do_glue, "-glue [files] Build the 16-bit glue for the source files" },
|
2001-12-11 00:50:33 +00:00
|
|
|
{ "-relay16", 0, do_relay16, "-relay16 Build the 16-bit relay assembly routines" },
|
|
|
|
{ "-relay32", 0, do_relay32, "-relay32 Build the 32-bit relay assembly routines" },
|
|
|
|
{ NULL, 0, NULL, NULL }
|
2000-06-23 20:15:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void do_output( const char *arg )
|
|
|
|
{
|
2002-05-31 23:06:46 +00:00
|
|
|
if ( ( unlink ( arg ) ) == -1 && ( errno != ENOENT ) )
|
2000-07-15 15:13:09 +00:00
|
|
|
{
|
|
|
|
fprintf ( stderr, "Unable to create output file '%s'\n", arg );
|
|
|
|
exit (1);
|
|
|
|
}
|
2000-06-23 20:15:35 +00:00
|
|
|
if (!(output_file = fopen( arg, "w" )))
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Unable to create output file '%s'\n", arg );
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
output_file_name = arg;
|
|
|
|
atexit( cleanup ); /* make sure we remove the output file on exit */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_usage(void)
|
|
|
|
{
|
2001-01-11 22:31:04 +00:00
|
|
|
const struct option_descr *opt;
|
2000-06-23 20:15:35 +00:00
|
|
|
fprintf( stderr, "Usage: winebuild [options]\n\n" );
|
|
|
|
fprintf( stderr, "Options:\n" );
|
2002-08-01 18:34:12 +00:00
|
|
|
for (opt = option_table; opt->name; opt++)
|
|
|
|
if (opt->usage) fprintf( stderr, " %s\n", opt->usage );
|
|
|
|
|
2002-05-14 20:54:58 +00:00
|
|
|
fprintf( stderr, "\nExactly one of -spec, -def, -exe, -debug, -glue, -relay16 or -relay32 must be specified.\n\n" );
|
2000-06-23 20:15:35 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2002-03-21 01:38:53 +00:00
|
|
|
static void do_warnings(void)
|
|
|
|
{
|
|
|
|
display_warnings = 1;
|
|
|
|
}
|
|
|
|
|
2002-05-14 20:54:58 +00:00
|
|
|
static void do_f_flags( const char *arg )
|
|
|
|
{
|
|
|
|
if (!strcmp( arg, "PIC" )) UsePIC = 1;
|
|
|
|
/* ignore all other flags */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_define( const char *arg )
|
|
|
|
{
|
|
|
|
/* nothing */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_include( const char *arg )
|
|
|
|
{
|
|
|
|
/* nothing */
|
|
|
|
}
|
|
|
|
|
2002-07-05 00:20:42 +00:00
|
|
|
static void do_k_flags( const char *arg )
|
|
|
|
{
|
|
|
|
/* Ignored, because cc generates correct code. */
|
|
|
|
/* if (!strcmp( arg, "PIC" )) UsePIC = 1; */
|
|
|
|
/* ignore all other flags */
|
|
|
|
}
|
|
|
|
|
2002-09-12 22:51:20 +00:00
|
|
|
static void do_heap( const char *arg )
|
|
|
|
{
|
|
|
|
if (!isdigit(arg[0]))
|
|
|
|
fatal_error( "Expected number argument with -H option instead of '%s'\n", arg );
|
|
|
|
DLLHeapSize = atoi(arg);
|
|
|
|
if (DLLHeapSize > 65535) fatal_error( "Invalid heap size %d, maximum is 65535\n", DLLHeapSize );
|
|
|
|
}
|
|
|
|
|
2002-09-12 17:23:25 +00:00
|
|
|
static void do_name( const char *arg )
|
|
|
|
{
|
|
|
|
strncpy( DLLName, arg, sizeof(DLLName) );
|
|
|
|
DLLName[sizeof(DLLName) - 1] = 0;
|
|
|
|
}
|
|
|
|
|
2000-06-23 20:15:35 +00:00
|
|
|
static void do_spec( const char *arg )
|
|
|
|
{
|
|
|
|
if (exec_mode != MODE_NONE || !arg[0]) do_usage();
|
|
|
|
exec_mode = MODE_SPEC;
|
2002-08-01 18:34:12 +00:00
|
|
|
input_file = open_input_file( NULL, arg );
|
2002-07-28 17:52:01 +00:00
|
|
|
set_dll_file_name( arg );
|
2000-06-23 20:15:35 +00:00
|
|
|
}
|
|
|
|
|
2002-02-04 18:48:18 +00:00
|
|
|
static void do_def( const char *arg )
|
|
|
|
{
|
|
|
|
if (exec_mode != MODE_NONE || !arg[0]) do_usage();
|
|
|
|
exec_mode = MODE_DEF;
|
2002-08-01 18:34:12 +00:00
|
|
|
input_file = open_input_file( NULL, arg );
|
2002-07-28 17:52:01 +00:00
|
|
|
set_dll_file_name( arg );
|
2002-02-04 18:48:18 +00:00
|
|
|
}
|
|
|
|
|
2002-05-11 23:06:32 +00:00
|
|
|
static void do_exe( const char *arg )
|
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
if (exec_mode != MODE_NONE || !arg[0]) do_usage();
|
|
|
|
exec_mode = MODE_EXE;
|
|
|
|
if ((p = strrchr( arg, '/' ))) p++;
|
|
|
|
else p = arg;
|
|
|
|
strcpy( DLLFileName, p );
|
|
|
|
if (!strchr( DLLFileName, '.' )) strcat( DLLFileName, ".exe" );
|
|
|
|
if (SpecMode == SPEC_MODE_DLL) SpecMode = SPEC_MODE_GUIEXE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_exe_mode( const char *arg )
|
|
|
|
{
|
|
|
|
if (!strcmp( arg, "gui" )) SpecMode = SPEC_MODE_GUIEXE;
|
|
|
|
else if (!strcmp( arg, "cui" )) SpecMode = SPEC_MODE_CUIEXE;
|
|
|
|
else if (!strcmp( arg, "guiw" )) SpecMode = SPEC_MODE_GUIEXE_UNICODE;
|
|
|
|
else if (!strcmp( arg, "cuiw" )) SpecMode = SPEC_MODE_CUIEXE_UNICODE;
|
|
|
|
else do_usage();
|
|
|
|
}
|
|
|
|
|
2002-06-21 19:15:45 +00:00
|
|
|
static void do_module( const char *arg )
|
|
|
|
{
|
|
|
|
strcpy( owner_name, arg );
|
|
|
|
}
|
|
|
|
|
2002-08-01 18:34:12 +00:00
|
|
|
static void do_glue(void)
|
2000-06-23 20:15:35 +00:00
|
|
|
{
|
2002-08-01 18:34:12 +00:00
|
|
|
if (exec_mode != MODE_NONE) do_usage();
|
2000-06-23 20:15:35 +00:00
|
|
|
exec_mode = MODE_GLUE;
|
|
|
|
}
|
|
|
|
|
2002-05-14 20:54:58 +00:00
|
|
|
static void do_debug(void)
|
|
|
|
{
|
|
|
|
if (exec_mode != MODE_NONE) do_usage();
|
|
|
|
exec_mode = MODE_DEBUG;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_chdir( const char *arg )
|
|
|
|
{
|
|
|
|
current_src_dir = arg;
|
|
|
|
}
|
|
|
|
|
2001-12-11 00:50:33 +00:00
|
|
|
static void do_relay16(void)
|
2000-06-23 20:15:35 +00:00
|
|
|
{
|
|
|
|
if (exec_mode != MODE_NONE) do_usage();
|
2001-12-11 00:50:33 +00:00
|
|
|
exec_mode = MODE_RELAY16;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_relay32(void)
|
|
|
|
{
|
|
|
|
if (exec_mode != MODE_NONE) do_usage();
|
|
|
|
exec_mode = MODE_RELAY32;
|
2000-06-23 20:15:35 +00:00
|
|
|
}
|
|
|
|
|
2002-08-01 18:34:12 +00:00
|
|
|
static void do_sym(void)
|
2000-11-09 20:31:18 +00:00
|
|
|
{
|
2002-08-01 18:34:12 +00:00
|
|
|
/* nothing */
|
2000-11-09 20:31:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_lib( const char *arg )
|
|
|
|
{
|
|
|
|
lib_path = xrealloc( lib_path, (nb_lib_paths+1) * sizeof(*lib_path) );
|
|
|
|
lib_path[nb_lib_paths++] = xstrdup( arg );
|
|
|
|
}
|
2000-06-23 20:15:35 +00:00
|
|
|
|
2002-05-09 00:05:48 +00:00
|
|
|
static void do_import( const char *arg )
|
|
|
|
{
|
|
|
|
add_import_dll( arg, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_dimport( const char *arg )
|
|
|
|
{
|
|
|
|
add_import_dll( arg, 1 );
|
|
|
|
}
|
|
|
|
|
2002-05-11 23:06:32 +00:00
|
|
|
static void do_rsrc( const char *arg )
|
|
|
|
{
|
|
|
|
load_res32_file( arg );
|
|
|
|
}
|
|
|
|
|
2000-06-23 20:15:35 +00:00
|
|
|
/* parse options from the argv array and remove all the recognized ones */
|
|
|
|
static void parse_options( char *argv[] )
|
|
|
|
{
|
2001-01-11 22:31:04 +00:00
|
|
|
const struct option_descr *opt;
|
2002-08-01 18:34:12 +00:00
|
|
|
char **ptr, **last;
|
2000-11-15 23:12:06 +00:00
|
|
|
const char* arg=NULL;
|
2000-06-23 20:15:35 +00:00
|
|
|
|
2002-08-01 18:34:12 +00:00
|
|
|
for (ptr = last = argv + 1; *ptr; ptr++)
|
2000-06-23 20:15:35 +00:00
|
|
|
{
|
|
|
|
for (opt = option_table; opt->name; opt++)
|
2000-11-15 23:12:06 +00:00
|
|
|
{
|
|
|
|
if (opt->has_arg && !strncmp( *ptr, opt->name, strlen(opt->name) ))
|
|
|
|
{
|
|
|
|
arg=*ptr+strlen(opt->name);
|
|
|
|
if (*arg=='\0')
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
arg=*ptr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!strcmp( *ptr, opt->name ))
|
|
|
|
{
|
|
|
|
arg=NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-06-23 20:15:35 +00:00
|
|
|
|
2002-08-01 18:34:12 +00:00
|
|
|
if (opt->name)
|
2000-06-23 20:15:35 +00:00
|
|
|
{
|
2002-08-01 18:34:12 +00:00
|
|
|
if (opt->has_arg && arg != NULL) opt->func( arg );
|
|
|
|
else opt->func( "" );
|
|
|
|
}
|
|
|
|
else /* keep this argument */
|
|
|
|
{
|
|
|
|
if (last != ptr) *last = *ptr;
|
|
|
|
last++;
|
2000-06-23 20:15:35 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-01 18:34:12 +00:00
|
|
|
*last = NULL;
|
2000-06-23 20:15:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
* main
|
|
|
|
*/
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
output_file = stdout;
|
|
|
|
parse_options( argv );
|
|
|
|
|
|
|
|
switch(exec_mode)
|
|
|
|
{
|
|
|
|
case MODE_SPEC:
|
2002-03-26 01:55:25 +00:00
|
|
|
switch (ParseTopLevel( input_file, 0 ))
|
2000-06-23 20:15:35 +00:00
|
|
|
{
|
|
|
|
case SPEC_WIN16:
|
2002-08-01 18:34:12 +00:00
|
|
|
if (argv[1])
|
|
|
|
fatal_error( "file argument '%s' not allowed in this mode\n", argv[1] );
|
2000-06-23 20:15:35 +00:00
|
|
|
BuildSpec16File( output_file );
|
|
|
|
break;
|
|
|
|
case SPEC_WIN32:
|
2002-08-01 18:34:12 +00:00
|
|
|
read_undef_symbols( argv + 1 );
|
2000-11-13 04:46:34 +00:00
|
|
|
BuildSpec32File( output_file );
|
2000-06-23 20:15:35 +00:00
|
|
|
break;
|
|
|
|
default: assert(0);
|
|
|
|
}
|
|
|
|
break;
|
2002-05-11 23:06:32 +00:00
|
|
|
case MODE_EXE:
|
2002-08-01 18:34:12 +00:00
|
|
|
read_undef_symbols( argv + 1 );
|
2002-05-11 23:06:32 +00:00
|
|
|
BuildSpec32File( output_file );
|
|
|
|
break;
|
2002-02-04 18:48:18 +00:00
|
|
|
case MODE_DEF:
|
2002-08-01 18:34:12 +00:00
|
|
|
if (argv[1]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[1] );
|
2002-03-26 01:55:25 +00:00
|
|
|
switch (ParseTopLevel( input_file, 1 ))
|
2002-02-04 18:48:18 +00:00
|
|
|
{
|
|
|
|
case SPEC_WIN16:
|
|
|
|
fatal_error( "Cannot yet build .def file for 16-bit dlls\n" );
|
|
|
|
break;
|
|
|
|
case SPEC_WIN32:
|
|
|
|
BuildDef32File( output_file );
|
|
|
|
break;
|
|
|
|
default: assert(0);
|
|
|
|
}
|
|
|
|
break;
|
2002-05-14 20:54:58 +00:00
|
|
|
case MODE_DEBUG:
|
2002-08-01 18:34:12 +00:00
|
|
|
BuildDebugFile( output_file, current_src_dir, argv + 1 );
|
2002-05-14 20:54:58 +00:00
|
|
|
break;
|
2000-06-23 20:15:35 +00:00
|
|
|
case MODE_GLUE:
|
2002-08-01 18:34:12 +00:00
|
|
|
BuildGlue( output_file, current_src_dir, argv + 1 );
|
2000-06-23 20:15:35 +00:00
|
|
|
break;
|
2001-12-11 00:50:33 +00:00
|
|
|
case MODE_RELAY16:
|
2002-08-01 18:34:12 +00:00
|
|
|
if (argv[1]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[1] );
|
2001-12-11 00:50:33 +00:00
|
|
|
BuildRelays16( output_file );
|
|
|
|
break;
|
|
|
|
case MODE_RELAY32:
|
2002-08-01 18:34:12 +00:00
|
|
|
if (argv[1]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[1] );
|
2001-12-11 00:50:33 +00:00
|
|
|
BuildRelays32( output_file );
|
2000-06-23 20:15:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
do_usage();
|
|
|
|
break;
|
|
|
|
}
|
2001-05-22 19:55:51 +00:00
|
|
|
if (output_file_name)
|
|
|
|
{
|
|
|
|
fclose( output_file );
|
|
|
|
output_file_name = NULL;
|
|
|
|
}
|
2000-06-23 20:15:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|