cygwin2.c revision 169689
1238730Sdelphij/* Helper routines for cygwin-specific command-line parsing.
2293190Sdelphij   Contributed by Christopher Faylor (cgf@redhat.com)
3238730Sdelphij   Copyright 2003 Free Software Foundation, Inc.
4238730Sdelphij
5238730SdelphijThis file is part of GCC.
6238730Sdelphij
7238730SdelphijGCC is free software; you can redistribute it and/or modify
8238730Sdelphijit under the terms of the GNU General Public License as published by
960786Spsthe Free Software Foundation; either version 2, or (at your option)
1063120Spsany later version.
1160786Sps
1260786SpsGCC is distributed in the hope that it will be useful,
1360786Spsbut WITHOUT ANY WARRANTY; without even the implied warranty of
1460786SpsMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1560786SpsGNU General Public License for more details.
1660786Sps
1760786SpsYou should have received a copy of the GNU General Public License
1860786Spsalong with GCC; see the file COPYING.  If not, write to
1960786Spsthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
2060786SpsBoston, MA 02110-1301, USA.  */
2160786Sps
2260786Sps#include "config.h"
2360786Sps#include "system.h"
2460786Sps#include "coretypes.h"
2560786Sps#include "tm.h"
2660786Sps
2760786Sps#include "safe-ctype.h"
2860786Sps#include <string.h>
2960786Sps
3060786Sps/*
3160786Spsstatic void remove_w32api (void);
3260786Sps*/
3360786Spsstatic void add_mingw (void);
3460786Spsstatic void set_mingw (void) __attribute__ ((constructor));
3560786Sps
36161478Sdelphijstatic void
37170259Sdelphijadd_mingw (void)
38170259Sdelphij{
3960786Sps  char **av;
4060786Sps  char *p;
4160786Sps  for (av = cvt_to_mingw; *av; av++)
4260786Sps    {
4360786Sps      int sawcygwin = 0;
4460786Sps      while ((p = strstr (*av, "-cygwin")))
4560786Sps	{
4660786Sps	  char *over = p + sizeof ("-cygwin") - 1;
4760786Sps	  memmove (over + 1, over, strlen (over));
48191930Sdelphij	  memcpy (p, "-mingw32", sizeof("-mingw32") - 1);
4960786Sps	  p = ++over;
5060786Sps	  while (ISALNUM (*p))
5160786Sps	    p++;
5260786Sps	  strcpy (over, p);
5360786Sps	  sawcygwin = 1;
5460786Sps	}
5560786Sps      if (!sawcygwin && !strstr (*av, "mingw"))
5660786Sps	strcat (*av, CYGWIN_MINGW_SUBDIR);
5760786Sps    }
5860786Sps}
5960786Sps
6060786Sps
6160786Spsstatic void
6260786Spsset_mingw (void)
63170259Sdelphij{
6463120Sps  char *env = getenv ("GCC_CYGWIN_MINGW");
6560786Sps  if (env && *env == '1')
66191930Sdelphij    add_mingw ();
6760786Sps}
6860786Sps