cygwin2.c revision 302408
1183724Ssos/* Helper routines for cygwin-specific command-line parsing.
2230132Suqs   Contributed by Christopher Faylor (cgf@redhat.com)
3183724Ssos   Copyright 2003 Free Software Foundation, Inc.
4183724Ssos
5183724SsosThis file is part of GCC.
6183724Ssos
7183724SsosGCC is free software; you can redistribute it and/or modify
8183724Ssosit under the terms of the GNU General Public License as published by
9183724Ssosthe Free Software Foundation; either version 2, or (at your option)
10183724Ssosany later version.
11183724Ssos
12183724SsosGCC is distributed in the hope that it will be useful,
13183724Ssosbut WITHOUT ANY WARRANTY; without even the implied warranty of
14183724SsosMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15183724SsosGNU General Public License for more details.
16183724Ssos
17183724SsosYou should have received a copy of the GNU General Public License
18183724Ssosalong with GCC; see the file COPYING.  If not, write to
19183724Ssosthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
20183724SsosBoston, MA 02110-1301, USA.  */
21183724Ssos
22183724Ssos#include "config.h"
23183724Ssos#include "system.h"
24183724Ssos#include "coretypes.h"
25183724Ssos#include "tm.h"
26183724Ssos
27183724Ssos#include "safe-ctype.h"
28183724Ssos#include <string.h>
29183724Ssos
30183724Ssos/*
31183724Ssosstatic void remove_w32api (void);
32183724Ssos*/
33183724Ssosstatic void add_mingw (void);
34183724Ssosstatic void set_mingw (void) __attribute__ ((constructor));
35183724Ssos
36183724Ssosstatic void
37183724Ssosadd_mingw (void)
38183724Ssos{
39183724Ssos  char **av;
40183724Ssos  char *p;
41183724Ssos  for (av = cvt_to_mingw; *av; av++)
42183724Ssos    {
43183724Ssos      int sawcygwin = 0;
44183724Ssos      while ((p = strstr (*av, "-cygwin")))
45183724Ssos	{
46183724Ssos	  char *over = p + sizeof ("-cygwin") - 1;
47183724Ssos	  memmove (over + 1, over, strlen (over));
48183724Ssos	  memcpy (p, "-mingw32", sizeof("-mingw32") - 1);
49183724Ssos	  p = ++over;
50183724Ssos	  while (ISALNUM (*p))
51183724Ssos	    p++;
52183724Ssos	  strcpy (over, p);
53183724Ssos	  sawcygwin = 1;
54183724Ssos	}
55200544Smarius      if (!sawcygwin && !strstr (*av, "mingw"))
56183724Ssos	strcat (*av, CYGWIN_MINGW_SUBDIR);
57200171Smav    }
58183724Ssos}
59183724Ssos
60183724Ssos
61183724Ssosstatic void
62183724Ssosset_mingw (void)
63183724Ssos{
64200817Smav  char *env = getenv ("GCC_CYGWIN_MINGW");
65183724Ssos  if (env && *env == '1')
66183724Ssos    add_mingw ();
67183724Ssos}
68183724Ssos