summaryrefslogtreecommitdiffstats
path: root/gcc/config/winnt
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1994-09-30 21:33:35 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1994-09-30 21:33:35 +0000
commit6b0455ec100ff7c2dbdd43a44f715dd26ec62538 (patch)
tree56c233ddb4048473b4fc4ba92a58f279436dbb6c /gcc/config/winnt
parent9c4dcbc6a3c5bb3bd112b2109f71761718a4cf6f (diff)
downloadppe42-gcc-6b0455ec100ff7c2dbdd43a44f715dd26ec62538.tar.gz
ppe42-gcc-6b0455ec100ff7c2dbdd43a44f715dd26ec62538.zip
Initial revision
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@8187 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/winnt')
-rw-r--r--gcc/config/winnt/ld.c259
-rw-r--r--gcc/config/winnt/win-nt.h66
-rw-r--r--gcc/config/winnt/xm-winnt.h59
3 files changed, 384 insertions, 0 deletions
diff --git a/gcc/config/winnt/ld.c b/gcc/config/winnt/ld.c
new file mode 100644
index 00000000000..91dabce7424
--- /dev/null
+++ b/gcc/config/winnt/ld.c
@@ -0,0 +1,259 @@
+/* Call Windows NT 3.x linker.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Douglas B. Rupp (drupp@cs.washington.edu).
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "config.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+/* These can be set by command line arguments */
+char *linker_path = 0;
+int verbose = 0;
+
+int link_arg_max = -1;
+char **link_args = (char **) 0;
+int link_arg_index = -1;
+
+char *search_dirs = ".";
+
+static int is_regular_file (char *name);
+
+static void
+addarg (str)
+ char *str;
+{
+ int i;
+
+ if (++link_arg_index >= link_arg_max)
+ {
+ char **new_link_args
+ = (char **) calloc (link_arg_max + 1000, sizeof (char *));
+
+ for (i = 0; i <= link_arg_max; i++)
+ new_link_args [i] = link_args [i];
+
+ if (link_args)
+ free (link_args);
+
+ link_arg_max += 1000;
+ link_args = new_link_args;
+ }
+
+ link_args [link_arg_index] = str;
+}
+
+static char *
+locate_file (file_name, path_val)
+ char *file_name;
+ char *path_val;
+{
+ char buf [1000];
+ int file_len = strlen (file_name);
+ char *end_path = path_val + strlen (path_val);
+ char *ptr;
+
+ /* Handle absolute pathnames */
+ if (file_name [0] == '/' || file_name [0] == DIR_SEPARATOR
+ || isalpha (file_name [0]) && file_name [1] == ':')
+ {
+ strncpy (buf, file_name, sizeof buf);
+ buf[sizeof buf - 1] = '\0';
+ if (is_regular_file (buf))
+ return strdup (buf);
+ else
+ return 0;
+ }
+
+ if (! path_val)
+ return 0;
+
+ for (;;)
+ {
+ for (; *path_val == PATH_SEPARATOR ; path_val++)
+ ;
+ if (! *path_val)
+ return 0;
+
+ for (ptr = buf; *path_val && *path_val != PATH_SEPARATOR; )
+ *ptr++ = *path_val++;
+
+ ptr--;
+ if (*ptr != '/' && *ptr != DIR_SEPARATOR)
+ *++ptr = DIR_SEPARATOR;
+
+ strcpy (++ptr, file_name);
+
+ if (is_regular_file (buf))
+ return strdup (buf);
+ }
+
+ return 0;
+}
+
+static char *
+expand_lib (name)
+ char *name;
+{
+ char *lib, *lib_path;
+
+ lib = malloc (strlen (name) + 5);
+ strcpy (lib, "lib");
+ strcat (lib, name);
+ strcat (lib, ".a");
+ lib_path = locate_file (lib, search_dirs);
+ if (!lib_path)
+ {
+ fprintf (stderr, "Couldn't locate library: %s\n", lib);
+ exit (1);
+ }
+
+ return lib_path;
+}
+
+static int
+is_regular_file (name)
+ char *name;
+{
+ int ret;
+ struct stat statbuf;
+
+ ret = stat(name, &statbuf);
+ return !ret && S_ISREG (statbuf.st_mode);
+}
+
+static void
+process_args (p_argc, argv)
+ int *p_argc;
+ char *argv[];
+{
+ int i, j;
+
+ for (i = 1; i < *p_argc; i++)
+ {
+ /* -v turns on verbose option here and is passed on to gcc */
+ if (! strcmp (argv [i], "-v"))
+ verbose = 1;
+ }
+}
+
+main (argc, argv)
+ int argc;
+ char *argv[];
+{
+ int i;
+ int done_an_ali = 0;
+ int file_name_index;
+ char *pathval = getenv ("PATH");
+ char *spawn_args [5];
+ char *tmppathval = malloc (strlen (pathval) + 3);
+
+ strcpy (tmppathval, ".;");
+ pathval = strcat (tmppathval, pathval);
+
+ process_args (&argc , argv);
+
+ linker_path = locate_file ("link32.exe", pathval);
+ if (!linker_path)
+ {
+ linker_path = locate_file ("link.exe", pathval);
+ if (!linker_path)
+ {
+ fprintf (stderr, "Couldn't locate link32 or link\n");
+ exit (1);
+ }
+ }
+
+ addarg (linker_path);
+
+ for (i = 1; i < argc; i++)
+ {
+ int arg_len = strlen (argv [i]);
+
+ if (!strcmp (argv [i], "-o"))
+ {
+ char *buff, *ptr;
+ int out_len;
+
+ i++;
+ out_len = strlen (argv[i]) + 9;
+ buff = malloc (out_len);
+ strcpy (buff, "-out:");
+ strcat (buff, argv[i]);
+ ptr = strstr (buff, ".exe");
+ if (ptr == NULL || strlen (ptr) != 4)
+ strcat (buff, ".exe");
+ addarg (buff);
+ }
+ else if (arg_len > 2 && !strncmp (argv [i], "-L", 2))
+ {
+ char *nbuff, *sdbuff;
+ int j, new_len, search_dirs_len;
+
+ new_len = strlen (&argv[i][2]);
+ search_dirs_len = strlen (search_dirs);
+
+ nbuff = malloc (new_len);
+ strcpy (nbuff, &argv[i][2]);
+
+ for (j = 0; j < new_len; j++)
+ if (nbuff[j] == '/') nbuff[j] = DIR_SEPARATOR;
+
+ sdbuff = malloc (search_dirs_len + new_len + 1);
+ strcpy (sdbuff, search_dirs);
+ sdbuff[search_dirs_len] = PATH_SEPARATOR;
+ sdbuff[search_dirs_len+1] = 0;
+ strcat (sdbuff, nbuff);
+
+ if (search_dirs)
+ free (search_dirs);
+
+ search_dirs = sdbuff;
+ }
+
+ else if (arg_len > 2 && !strncmp (argv [i], "-l", 2))
+ addarg (expand_lib (&argv[i][2]));
+ else if (!strcmp (argv [i], "-v"))
+ ;
+ else
+ addarg (argv [i]);
+ }
+
+ addarg (NULL);
+
+ if (verbose)
+ {
+ int i;
+
+ for (i = 0; i < link_arg_index; i++)
+ printf ("%s ", link_args [i]);
+ putchar ('\n');
+ }
+
+ if (spawnvp (P_WAIT, linker_path, (const char * const *)link_args) != 0)
+ {
+ fprintf (stderr, "Error executing %s\n", link_args[0]);
+ exit (1);
+ }
+
+ exit (0);
+}
diff --git a/gcc/config/winnt/win-nt.h b/gcc/config/winnt/win-nt.h
new file mode 100644
index 00000000000..3d4c1ee5284
--- /dev/null
+++ b/gcc/config/winnt/win-nt.h
@@ -0,0 +1,66 @@
+/* winnt.h -- operating system specific defines to be used when
+ targeting GCC for Windows NT 3.x.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Douglas B. Rupp (drupp@cs.washington.edu).
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ To use this file, put in your tm.h file something like:
+
+ #include "?????.h"
+ #include "svr4.h"
+
+ followed by any really system-specific defines (or overrides of
+ defines) which you find that you need. For example, CPP_PREDEFINES
+ is defined here with only the defined -Dunix and -DSVR4. You should
+ probably override that in your target-specific ?????svr4.h file
+ with a set of defines that includes these, but also contains an
+ appropriate define for the type of hardware that you are targeting. */
+
+#undef LIB_SPEC
+#define LIB_SPEC "libc.lib kernel32.lib"
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC ""
+
+#undef LINK_SPEC
+#define LINK_SPEC "-align:0x1000 -subsystem:console -entry:mainCRTStartup \
+ -stack:1000000,1000000"
+
+#undef STANDARD_EXEC_PREFIX
+#define STANDARD_EXEC_PREFIX ""
+
+#undef STANDARD_STARTFILE_PREFIX
+#define STANDARD_STARTFILE_PREFIX ""
+
+#undef TOOLDIR_BASE_PREFIX
+#define TOOLDIR_BASE_PREFIX ""
+
+#ifdef STANDARD_INCLUDE_DIR
+#undef STANDARD_INCLUDE_DIR
+#endif
+#define STANDARD_INCLUDE_DIR ""
+
+#undef LOCAL_INCLUDE_DIR
+#define LOCAL_INCLUDE_DIR ""
+
+#undef INCLUDE_DEFAULTS
+#define INCLUDE_DEFAULTS \
+ { \
+ { 0, 0, 0 } \
+ }
+
diff --git a/gcc/config/winnt/xm-winnt.h b/gcc/config/winnt/xm-winnt.h
new file mode 100644
index 00000000000..3a303990d71
--- /dev/null
+++ b/gcc/config/winnt/xm-winnt.h
@@ -0,0 +1,59 @@
+/* Configuration for GNU compiler
+ for processor running Windows NT 3.x.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Douglas B. Rupp (drupp@cs.washington.edu)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <stdlib.h>
+#define USG
+#define ONLY_INT_FIELDS
+#define USE_PROTOTYPES 1
+#define bcmp(a,b,c) memcmp (a,b,c)
+#define bcopy(a,b,c) memcpy (b,a,c)
+#define bzero(a,b) memset (a,0,b)
+#define index strchr
+#define rindex strrchr
+#define kill(a,b) raise(b)
+
+#define EXECUTABLE_SUFFIX ".exe"
+#define PATH_SEPARATOR ';'
+#define DIR_SEPARATOR '\\'
+#define HAVE_PUTENV 1
+
+#define S_IRUSR 0000400
+#define S_IWUSR 0000200
+#define S_IXUSR 0000100
+#define S_IRGRP 0000040
+#define S_IWGRP 0000020
+#define S_IXGRP 0000010
+#define S_IROTH 0000004
+#define S_IWOTH 0000002
+#define S_IXOTH 0000001
+#define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR
+#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
+#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
+
+#define access _access
+#define close _close
+#define dup _dup
+#define mktemp _mktemp
+#define open _open
+#define read _read
+#define write _write
+#define chmod _chmod
+#define setjmp _setjmp
OpenPOWER on IntegriCloud