/* Call Windows NT 3.x linker.
- Copyright (C) 1994 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995 Free Software Foundation, Inc.
Contributed by Douglas B. Rupp (drupp@cs.washington.edu).
This file is part of GNU CC.
/* These can be set by command line arguments */
char *linker_path = 0;
int verbose = 0;
+int subsystem = 0;
+int entry = 0;
int link_arg_max = -1;
char **link_args = (char **) 0;
static int is_regular_file (char *name);
+/* Add the argument contained in STR to the list of arguments to pass to the
+ linker */
+
static void
addarg (str)
char *str;
link_args [link_arg_index] = str;
}
+/* Locate the file named in FILE_NAME in the set of paths contained in
+ PATH_VAL */
+
static char *
locate_file (file_name, path_val)
char *file_name;
return 0;
}
+/* Given a library name in NAME, i.e. foo. Look first for libfoo.a and then
+ foo.lib in the set of directories we are allowed to search in */
+
static char *
expand_lib (name)
char *name;
lib_path = locate_file (lib, search_dirs);
if (!lib_path)
{
- fprintf (stderr, "Couldn't locate library: %s\n", lib);
- exit (1);
+ strcpy (lib, name);
+ strcat (lib, ".lib");
+ lib_path = locate_file (lib, search_dirs);
+ if (!lib_path)
+ {
+ fprintf (stderr,
+ "Couldn't locate library: lib%s.a or %s.lib\n", name, name);
+ exit (1);
+ }
}
return lib_path;
}
+/* Check to see if the file named in NAME is a regular file, i.e. not a
+ directory */
+
static int
is_regular_file (name)
char *name;
return !ret && S_ISREG (statbuf.st_mode);
}
+/* Process the number of args in P_ARGC and contained in ARGV. Look for
+ special flags, etc. that must be handled for the Microsoft linker */
+
static void
process_args (p_argc, argv)
int *p_argc;
/* -v turns on verbose option here and is passed on to gcc */
if (! strcmp (argv [i], "-v"))
verbose = 1;
+ else if (! strncmp (argv [i], "-subsystem", 10))
+ subsystem = 1;
+ else if (! strncmp (argv [i], "-entry", 6))
+ entry = 1;
}
}
+/* The main program. Spawn the Microsoft linker after fixing up the
+ Unix-like flags and args to be what the Microsoft linker wants */
+
main (argc, argv)
int argc;
char *argv[];
}
addarg (linker_path);
+ if (! subsystem) addarg ("-subsystem:console");
+ if (! entry) addarg ("-entry:mainCRTStartup");
for (i = 1; i < argc; i++)
{
if (ptr == NULL || strlen (ptr) != 4)
strcat (buff, ".exe");
addarg (buff);
- addarg ("-debug:full -debugtype:coff");
}
else if (arg_len > 2 && !strncmp (argv [i], "-L", 2))
{