OSDN Git Service

Two little fixes I commited to classpath but not to libgcj first
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / cygwin2.c
1 /* Helper routines for cygwin-specific command-line parsing.
2    Contributed by Christopher Faylor (cgf@redhat.com)
3    Copyright 2003 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26
27 #include "safe-ctype.h"
28 #include <string.h>
29
30 /*
31 static void remove_w32api PARAMS ((void));
32 */
33 static void add_mingw PARAMS ((void));
34 static void set_mingw PARAMS((void)) __attribute__ ((constructor));
35
36 static void
37 add_mingw ()
38 {
39   char **av;
40   char *p;
41   for (av = cvt_to_mingw; *av; av++)
42     {
43       int sawcygwin = 0;
44       while ((p = strstr (*av, "-cygwin")))
45         {
46           char *over = p + sizeof ("-cygwin") - 1;
47           memmove (over + 1, over, strlen (over));
48           memcpy (p, "-mingw32", sizeof("-mingw32") - 1);
49           p = ++over;
50           while (ISALNUM (*p))
51             p++;
52           strcpy (over, p);
53           sawcygwin = 1;
54         }
55       if (!sawcygwin && !strstr (*av, "mingw"))
56         strcat (*av, CYGWIN_MINGW_SUBDIR);
57     }
58 }
59
60
61 static void
62 set_mingw ()
63 {
64   char *env = getenv ("GCC_CYGWIN_MINGW");
65   if (env && *env == '1')
66     add_mingw ();
67 }