OSDN Git Service

99d9d8f82439cbc999a4908a67747b9444de1a3d
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / cygwin1.c
1 /* Helper routines for cygwin-specific command-line parsing.
2    Contributed by Christopher Faylor (cgf@redhat.com)
3    Copyright 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC 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 3, or (at your option)
10 any later version.
11
12 GCC 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 GCC; see the file COPYING3.  If not see
19 <http://www.gnu.org/licenses/>.  */
20
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "opts.h"
26 #include <string.h>
27
28 void
29 mingw_scan (unsigned int decoded_options_count,
30             const struct cl_decoded_option *decoded_options,
31             const char **spec_machine)
32 {
33   unsigned int i;
34   putenv (xstrdup ("GCC_CYGWIN_MINGW=0"));
35  
36   for (i = 1; i < decoded_options_count; i++)
37     switch (decoded_options[i].opt_index)
38       {
39       case OPT_mwin32:
40         if (decoded_options[i].value == 0)
41           putenv (xstrdup ("GCC_CYGWIN_WIN32=0"));
42         else
43           putenv (xstrdup ("GCC_CYGWIN_WIN32=1"));
44         break;
45
46       case OPT_mcygwin:
47         if (decoded_options[i].value == 0)
48           {
49             char *p = strstr (*spec_machine, "-cygwin");
50             if (p)
51               {
52                 int len = p - *spec_machine;
53                 char *s = XNEWVEC (char, strlen (*spec_machine) + 3);
54                 memcpy (s, *spec_machine, len);
55                 strcpy (s + len, "-mingw32");
56                 *spec_machine = s;
57               }
58             putenv (xstrdup ("GCC_CYGWIN_MINGW=1"));
59           }
60         break;
61       }
62   return;
63 }