2 * MinGW wrapper: makes gcc behave like MinGW.
4 * Copyright 2000 Manuel Novoa III
5 * Copyright 2002 Dimitrie O. Paun
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library 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 GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
33 void error(const char *s, ...)
38 fprintf(stderr, "Error: ");
39 vfprintf(stderr, s, ap);
40 fprintf(stderr, "\n");
45 int main(int argc, char **argv)
49 int linking = 1, verbose = 0, cpp = 0, use_static_linking = 0;
50 int use_stdinc = 1, use_stdlib = 1, use_msvcrt = 0, gui_app = 0;
52 for ( i = 1 ; i < argc ; i++ )
54 if (argv[i][0] == '-') /* option */
58 case 'c': /* compile or assemble */
59 case 'S': /* generate assembler code */
60 case 'E': /* preprocess only */
61 if (argv[i][2] == 0) linking = 0;
63 case 'M': /* map file generation */
67 if (strcmp("-mno-cygwin", argv[i]) == 0)
69 else if (strcmp("-mwindows", argv[i]) == 0)
73 if (strcmp("-nostdinc", argv[i]) == 0)
75 else if (strcmp("-nodefaultlibs", argv[i]) == 0)
77 else if (strcmp("-nostdlib", argv[i]) == 0)
81 if (strcmp("-static", argv[i]) == 0) use_static_linking = 1;
83 case 'v': /* verbose */
84 if (argv[i][2] == 0) verbose = 1;
87 printf("winegcc v0.3\n");
91 if (strncmp("-Wl,", argv[i], 4) == 0)
93 if (strstr(argv[i], "-static"))
94 use_static_linking = 1;
98 if (strcmp("-xc++", argv[i]) == 0) cpp = 1;
101 if (strcmp("-static", argv[i]+1) == 0)
102 use_static_linking = 1;
108 if (use_static_linking) error("Static linking is not supported.");
110 gcc_argv = malloc(sizeof(char*) * (argc + 20));
115 gcc_argv[i++] = BINDIR "/winewrap";
116 if (gui_app) gcc_argv[i++] = "-mgui";
118 if (cpp) gcc_argv[i++] = "-C";
119 for ( j = 1 ; j < argc ; j++ )
121 if ( argv[j][0] == '-' )
127 gcc_argv[i++] = argv[j];
130 gcc_argv[i++] = strcmp(argv[j], "-luuid") ? argv[j] : "-lwine_uuid";
133 ; /* ignore the rest */
137 gcc_argv[i++] = argv[j];
139 if (use_stdlib && use_msvcrt) gcc_argv[i++] = "-lmsvcrt";
143 gcc_argv[i++] = cpp ? "g++" : "gcc";
145 gcc_argv[i++] = "-fshort-wchar";
146 gcc_argv[i++] = "-fPIC";
149 if (use_msvcrt) gcc_argv[i++] = "-I" INCLUDEDIR "/msvcrt";
150 gcc_argv[i++] = "-I" INCLUDEDIR "/windows";
152 gcc_argv[i++] = "-D__WINE__";
153 gcc_argv[i++] = "-D__WIN32__";
154 gcc_argv[i++] = "-DWINE_UNICODE_NATIVE";
155 gcc_argv[i++] = "-D__int8=char";
156 gcc_argv[i++] = "-D__int16=short";
157 gcc_argv[i++] = "-D__int32=int";
158 gcc_argv[i++] = "-D__int64=long long";
160 for ( j = 1 ; j < argc ; j++ )
162 if (strcmp("-mno-cygwin", argv[j]) == 0)
163 ; /* ignore this option */
164 else if (strcmp("-mwindows", argv[j]) == 0)
165 ; /* ignore this option */
166 else if (strcmp("-s", argv[j]) == 0)
167 ; /* ignore this option */
169 gcc_argv[i++] = argv[j];
177 for (i = 0; gcc_argv[i]; i++) printf("%s ", gcc_argv[i]);
181 execvp(gcc_argv[0], gcc_argv);