2002-12-05 19:12:13 +00:00
|
|
|
/*
|
|
|
|
* MinGW wrapper: makes gcc behave like MinGW.
|
|
|
|
*
|
2002-12-15 01:17:10 +00:00
|
|
|
* Copyright 2000 Manuel Novoa III
|
2002-12-05 19:12:13 +00:00
|
|
|
* Copyright 2002 Dimitrie O. Paun
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2002-12-12 02:17:56 +00:00
|
|
|
#include <stdlib.h>
|
2002-12-15 01:17:10 +00:00
|
|
|
#include <stdarg.h>
|
2002-12-05 19:12:13 +00:00
|
|
|
#include <string.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2002-12-15 01:17:10 +00:00
|
|
|
void error(const char *s, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, s);
|
|
|
|
fprintf(stderr, "Error: ");
|
|
|
|
vfprintf(stderr, s, ap);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
va_end(ap);
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2002-12-05 19:12:13 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
char **gcc_argv;
|
|
|
|
int i, j;
|
2003-01-02 23:07:52 +00:00
|
|
|
int linking = 1, verbose = 0, cpp = 0, use_static_linking = 0;
|
2002-12-15 01:17:10 +00:00
|
|
|
int use_stdinc = 1, use_stdlib = 1, use_msvcrt = 0, gui_app = 0;
|
|
|
|
|
|
|
|
for ( i = 1 ; i < argc ; i++ )
|
|
|
|
{
|
|
|
|
if (argv[i][0] == '-') /* option */
|
|
|
|
{
|
|
|
|
switch (argv[i][1])
|
|
|
|
{
|
|
|
|
case 'c': /* compile or assemble */
|
|
|
|
case 'S': /* generate assembler code */
|
|
|
|
case 'E': /* preprocess only */
|
|
|
|
case 'M': /* map file generation */
|
|
|
|
if (argv[i][2] == 0) linking = 0;
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
if (strcmp("-mno-cygwin", argv[i]) == 0)
|
|
|
|
use_msvcrt = 1;
|
|
|
|
else if (strcmp("-mwindows", argv[i]) == 0)
|
|
|
|
gui_app = 1;
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
if (strcmp("-nostdinc", argv[i]) == 0)
|
|
|
|
use_stdinc = 0;
|
|
|
|
else if (strcmp("-nodefaultlibs", argv[i]) == 0)
|
|
|
|
use_stdlib = 0;
|
|
|
|
else if (strcmp("-nostdlib", argv[i]) == 0)
|
|
|
|
use_stdlib = 0;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
if (strcmp("-static", argv[i]) == 0) use_static_linking = 1;
|
|
|
|
break;
|
2003-01-02 23:07:52 +00:00
|
|
|
case 'v': /* verbose */
|
|
|
|
if (argv[i][2] == 0) verbose = 1;
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
printf("winegcc v0.3\n");
|
|
|
|
exit(0);
|
|
|
|
break;
|
2002-12-15 01:17:10 +00:00
|
|
|
case 'W':
|
|
|
|
if (strncmp("-Wl,", argv[i], 4) == 0)
|
|
|
|
{
|
|
|
|
if (strstr(argv[i], "-static"))
|
|
|
|
use_static_linking = 1;
|
|
|
|
}
|
|
|
|
break;
|
2003-01-02 23:07:52 +00:00
|
|
|
case 'x':
|
|
|
|
if (strcmp("-xc++", argv[i]) == 0) cpp = 1;
|
|
|
|
break;
|
2002-12-15 01:17:10 +00:00
|
|
|
case '-':
|
|
|
|
if (strcmp("-static", argv[i]+1) == 0)
|
|
|
|
use_static_linking = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_static_linking) error("Static linking is not supported.");
|
2002-12-05 19:12:13 +00:00
|
|
|
|
|
|
|
gcc_argv = malloc(sizeof(char*) * (argc + 20));
|
|
|
|
|
|
|
|
i = 0;
|
2002-12-15 01:17:10 +00:00
|
|
|
if (linking)
|
|
|
|
{
|
|
|
|
gcc_argv[i++] = BINDIR "/winewrap";
|
2002-12-17 04:15:42 +00:00
|
|
|
if (gui_app) gcc_argv[i++] = "-mgui";
|
2003-01-02 23:07:52 +00:00
|
|
|
if (cpp) gcc_argv[i++] = "-C";
|
2002-12-15 01:17:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-01-02 23:07:52 +00:00
|
|
|
gcc_argv[i++] = cpp ? "g++" : "gcc";
|
2002-12-15 01:17:10 +00:00
|
|
|
|
|
|
|
gcc_argv[i++] = "-fshort-wchar";
|
|
|
|
gcc_argv[i++] = "-fPIC";
|
|
|
|
if (use_stdinc)
|
|
|
|
{
|
|
|
|
if (use_msvcrt) gcc_argv[i++] = "-I" INCLUDEDIR "/msvcrt";
|
|
|
|
gcc_argv[i++] = "-I" INCLUDEDIR "/windows";
|
|
|
|
}
|
2003-01-02 19:23:48 +00:00
|
|
|
gcc_argv[i++] = "-DWINE_UNICODE_NATIVE";
|
2002-12-15 01:17:10 +00:00
|
|
|
gcc_argv[i++] = "-D__int8=char";
|
|
|
|
gcc_argv[i++] = "-D__int16=short";
|
|
|
|
gcc_argv[i++] = "-D__int32=int";
|
|
|
|
gcc_argv[i++] = "-D__int64=long long";
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( j = 1 ; j < argc ; j++ )
|
|
|
|
{
|
|
|
|
if (strcmp("-mno-cygwin", argv[j]) == 0)
|
|
|
|
; /* ignore this option */
|
|
|
|
else if (strcmp("-mwindows", argv[j]) == 0)
|
|
|
|
; /* ignore this option */
|
|
|
|
else if (strcmp("-s", argv[j]) == 0)
|
|
|
|
; /* ignore this option */
|
|
|
|
else
|
2002-12-05 19:12:13 +00:00
|
|
|
gcc_argv[i++] = argv[j];
|
2002-12-15 01:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (linking)
|
|
|
|
{
|
2003-01-02 19:23:48 +00:00
|
|
|
if (use_stdlib && use_msvcrt) gcc_argv[i++] = "-lmsvcrt";
|
2002-12-05 19:12:13 +00:00
|
|
|
}
|
|
|
|
gcc_argv[i] = NULL;
|
|
|
|
|
2002-12-15 01:17:10 +00:00
|
|
|
if (verbose)
|
|
|
|
{
|
|
|
|
for (i = 0; gcc_argv[i]; i++) printf("%s ", gcc_argv[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
execvp(gcc_argv[0], gcc_argv);
|
|
|
|
|
|
|
|
return 1;
|
2002-12-05 19:12:13 +00:00
|
|
|
}
|