Commit b4c7e6c7 authored by Alexandre Julliard's avatar Alexandre Julliard

Added --ld-cmd and --nm-cmd options in winebuild, and make winegcc

pass the proper ld command.
parent 2eafc7ff
......@@ -206,4 +206,7 @@ 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 */
......@@ -512,7 +512,7 @@ static int check_unused( const struct import* imp, const DLLSPEC *spec )
static const char *ldcombine_files( char **argv )
{
int i, len = 0;
char *cmd, *ldcmd;
char *cmd;
int fd, err;
if (output_file_name && output_file_name[0])
......@@ -527,14 +527,12 @@ static const char *ldcombine_files( char **argv )
close( fd );
atexit( remove_ld_tmp_file );
ldcmd = getenv("LD");
if (!ldcmd) ldcmd = "ld";
for (i = 0; argv[i]; i++) len += strlen(argv[i]) + 1;
cmd = xmalloc( len + strlen(ld_tmp_file) + 8 + strlen(ldcmd) );
sprintf( cmd, "%s -r -o %s", ldcmd, ld_tmp_file );
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( "ld -r failed with status %d\n", err );
if (err) fatal_error( "%s -r failed with status %d\n", ld_command, err );
free( cmd );
return ld_tmp_file;
}
......@@ -545,7 +543,7 @@ 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 buffer[1024];
char *cmd, buffer[1024];
int err;
const char *name;
......@@ -557,9 +555,10 @@ void read_undef_symbols( char **argv )
if (argv[1]) name = ldcombine_files( argv );
else name = argv[0];
sprintf( buffer, "nm -u %s", name );
if (!(f = popen( buffer, "r" )))
fatal_error( "Cannot execute '%s'\n", buffer );
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 ))
{
......@@ -572,7 +571,8 @@ void read_undef_symbols( char **argv )
if (prefix_len && !strncmp( p, name_prefix, prefix_len )) p += prefix_len;
add_undef_symbol( p );
}
if ((err = pclose( f ))) warning( "nm -u %s error %d\n", name, err );
if ((err = pclose( f ))) warning( "%s failed with status %d\n", cmd, err );
free( cmd );
}
static void remove_ignored_symbols(void)
......
......@@ -59,6 +59,9 @@ char **lib_path = NULL;
char *input_file_name = NULL;
const char *output_file_name = NULL;
char *ld_command = "ld";
char *nm_command = "nm";
static FILE *output_file;
static const char *current_src_dir;
static int nb_res_files;
......@@ -144,9 +147,11 @@ static const char usage_str[] =
" -I DIR Ignored for C flags compatibility\n"
" -k --kill-at Kill stdcall decorations in generated .def files\n"
" -K FLAGS Compiler flags (only -KPIC is supported)\n"
" --ld-cmd=LD Command to use for linking (default: ld)\n"
" -l --library=LIB Import the specified library\n"
" -L --library-path=DIR Look for imports libraries in DIR\n"
" -M --main-module=MODULE Set the name of the main module for a Win16 dll\n"
" --nm-cmd=NM Command to use to get undefined symbols (default: nm)\n"
" -N --dll-name=DLLNAME Set the DLL name (default: from input file name)\n"
" -o --output=NAME Set the output file name (default: stdout)\n"
" -r --res=RSRC.RES Load resources from RSRC.RES\n"
......@@ -168,6 +173,8 @@ enum long_options_values
LONG_OPT_DEF,
LONG_OPT_EXE,
LONG_OPT_DEBUG,
LONG_OPT_LDCMD,
LONG_OPT_NMCMD,
LONG_OPT_RELAY16,
LONG_OPT_RELAY32,
LONG_OPT_SUBSYSTEM,
......@@ -182,6 +189,8 @@ static const struct option long_options[] =
{ "def", 1, 0, LONG_OPT_DEF },
{ "exe", 1, 0, LONG_OPT_EXE },
{ "debug", 0, 0, LONG_OPT_DEBUG },
{ "ld-cmd", 1, 0, LONG_OPT_LDCMD },
{ "nm-cmd", 1, 0, LONG_OPT_NMCMD },
{ "relay16", 0, 0, LONG_OPT_RELAY16 },
{ "relay32", 0, 0, LONG_OPT_RELAY32 },
{ "subsystem",1, 0, LONG_OPT_SUBSYSTEM },
......@@ -329,6 +338,12 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
case LONG_OPT_DEBUG:
set_exec_mode( MODE_DEBUG );
break;
case LONG_OPT_LDCMD:
ld_command = xstrdup( optarg );
break;
case LONG_OPT_NMCMD:
nm_command = xstrdup( optarg );
break;
case LONG_OPT_RELAY16:
set_exec_mode( MODE_RELAY16 );
break;
......
......@@ -115,6 +115,14 @@ generated .def file. Only meaningful in \fB--def\fR mode.
.BI \-K\ flags
Ignored for compatibility with the C compiler.
.TP
.BI \--ld-cmd= ld-command
Specify the command to use to link the object files; the default is
\fBld\fR.
.TP
.BI \--nm-cmd= nm-command
Specify the command to use to get the list of undefined symbols; the
default is \fBnm\fR.
.TP
.BI \-L,\ --library-path= directory
Append the specified directory to the list of directories that are
searched for import libraries.
......
......@@ -6,7 +6,8 @@ DEFS = \
-DLDDLLFLAGS="\"@LDDLLFLAGS@\"" \
-DCC="\"$(CC)\"" \
-DCPP="\"@CPPBIN@\"" \
-DCXX="\"$(CXX)\""
-DCXX="\"$(CXX)\"" \
-DLD="\"$(LD)\""
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
......
......@@ -491,6 +491,8 @@ static void build(struct options* opts)
spec_args = strarray_alloc();
spec_c_name = get_temp_file(output_name, ".spec.c");
strarray_add(spec_args, winebuild);
strarray_add(spec_args, "--ld-cmd");
strarray_add(spec_args, LD);
strarray_add(spec_args, "-o");
strarray_add(spec_args, spec_c_name);
if (opts->shared)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment