1132718Skan/* Helper routines for cygwin-specific command-line parsing.
2132718Skan   Contributed by Christopher Faylor (cgf@redhat.com)
3132718Skan   Copyright 2003 Free Software Foundation, Inc.
4132718Skan
5132718SkanThis file is part of GCC.
6132718Skan
7132718SkanGCC is free software; you can redistribute it and/or modify
8132718Skanit under the terms of the GNU General Public License as published by
9132718Skanthe Free Software Foundation; either version 2, or (at your option)
10132718Skanany later version.
11132718Skan
12132718SkanGCC is distributed in the hope that it will be useful,
13132718Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of
14132718SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15132718SkanGNU General Public License for more details.
16132718Skan
17132718SkanYou should have received a copy of the GNU General Public License
18132718Skanalong with GCC; see the file COPYING.  If not, write to
19169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
20169689SkanBoston, MA 02110-1301, USA.  */
21132718Skan
22132718Skan#include "config.h"
23132718Skan#include "system.h"
24132718Skan#include "coretypes.h"
25132718Skan#include "tm.h"
26132718Skan
27132718Skan#include "safe-ctype.h"
28132718Skan#include <string.h>
29132718Skan
30132718Skan/*
31132718Skanstatic void remove_w32api (void);
32132718Skan*/
33132718Skanstatic void add_mingw (void);
34132718Skanstatic void set_mingw (void) __attribute__ ((constructor));
35132718Skan
36132718Skanstatic void
37132718Skanadd_mingw (void)
38132718Skan{
39132718Skan  char **av;
40132718Skan  char *p;
41132718Skan  for (av = cvt_to_mingw; *av; av++)
42132718Skan    {
43132718Skan      int sawcygwin = 0;
44132718Skan      while ((p = strstr (*av, "-cygwin")))
45132718Skan	{
46132718Skan	  char *over = p + sizeof ("-cygwin") - 1;
47132718Skan	  memmove (over + 1, over, strlen (over));
48132718Skan	  memcpy (p, "-mingw32", sizeof("-mingw32") - 1);
49132718Skan	  p = ++over;
50132718Skan	  while (ISALNUM (*p))
51132718Skan	    p++;
52132718Skan	  strcpy (over, p);
53132718Skan	  sawcygwin = 1;
54132718Skan	}
55132718Skan      if (!sawcygwin && !strstr (*av, "mingw"))
56132718Skan	strcat (*av, CYGWIN_MINGW_SUBDIR);
57132718Skan    }
58132718Skan}
59132718Skan
60132718Skan
61132718Skanstatic void
62132718Skanset_mingw (void)
63132718Skan{
64132718Skan  char *env = getenv ("GCC_CYGWIN_MINGW");
65132718Skan  if (env && *env == '1')
66132718Skan    add_mingw ();
67132718Skan}
68