2 * MinGW wrapper: makes gcc behave like MinGW.
4 * Copyright 2000 Manuel Novoa III
5 * Copyright 2000 Francois Gouget
6 * Copyright 2002 Dimitrie O. Paun
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * all options for gcc start with '-' and are for the most part
25 * single options (no parameters as separate argument).
26 * There are of course exceptions to this rule, so here is an
27 * exhaustive list of options that do take parameters (potentially)
28 * as a separate argument:
47 * -iwithprefixbefore dir
59 * -G num (see NOTES below)
62 * There is -G option for compatibility with System V that
63 * takes no parameters. This makes "-G num" parsing ambiguous.
64 * This option is synonymous to -shared, and as such we will
65 * not support it for now.
67 * Special interest options
73 * object-file-name -llibrary -nostartfiles -nodefaultlibs
74 * -nostdlib -s -static -static-libgcc -shared -shared-libgcc
75 * -symbolic -Wl,option -Xlinker option -u symbol
78 * -Bprefix -Idir -I- -Ldir -specs=file
81 * -b machine -V version
83 * Please note that the Target Options are relevant to everything:
84 * compiler, linker, assembler, preprocessor.
89 #include "wine/port.h"
99 static const char* app_loader_template
=
103 "# determine the application directory\n"
107 " # $0 contains a path, use it\n"
108 " appdir=`dirname \"$0\"`\n"
111 " # no directory in $0, search in PATH\n"
117 " if [ -x \"$d/$appname\" ]; then appdir=\"$d\"; break; fi\n"
122 "# figure out the full app path\n"
123 "if [ -n \"$appdir\" ]; then\n"
124 " apppath=\"$appdir/$appname\"\n"
125 " WINEDLLPATH=\"$appdir:$WINEDLLPATH\"\n"
126 " export WINEDLLPATH\n"
128 " apppath=\"$appname\"\n"
131 "# determine the WINELOADER\n"
132 "if [ ! -x \"$WINELOADER\" ]; then WINELOADER=\"wine\"; fi\n"
134 "# and try to start the app\n"
135 "exec \"$WINELOADER\" \"$apppath\" \"$@\"\n"
138 static int keep_generated
= 0;
139 static strarray
* tmp_files
;
143 enum { proc_cc
= 0, proc_cxx
= 1, proc_cpp
= 2} processor
;
153 const char* output_name
;
156 strarray
* linker_args
;
157 strarray
* compiler_args
;
158 strarray
* winebuild_args
;
162 static void clean_temp_files()
166 if (keep_generated
) return;
168 for (i
= 0; i
< tmp_files
->size
; i
++)
169 unlink(tmp_files
->base
[i
]);
172 char* get_temp_file(const char* prefix
, const char* suffix
)
174 char* tmp
= strmake("%s-XXXXXX%s", prefix
, suffix
);
175 int fd
= mkstemps( tmp
, strlen(suffix
) );
178 /* could not create it in current directory, try in /tmp */
180 tmp
= strmake("/tmp/%s-XXXXXX%s", prefix
, suffix
);
181 fd
= mkstemps( tmp
, strlen(suffix
) );
182 if (fd
== -1) error( "could not create temp file" );
185 strarray_add(tmp_files
, tmp
);
190 static const strarray
* get_translator(struct options
* opts
)
192 static strarray
* cpp
= 0;
193 static strarray
* cc
= 0;
194 static strarray
* cxx
= 0;
196 switch(opts
->processor
)
199 if (!cpp
) cpp
= strarray_fromstring(CPP
, " ");
202 if (!cc
) cc
= strarray_fromstring(CC
, " ");
205 if (!cxx
) cxx
= strarray_fromstring(CXX
, " ");
208 error("Unknown processor");
211 static void compile(struct options
* opts
, const char* lang
)
213 strarray
* comp_args
= strarray_alloc();
216 switch(opts
->processor
)
218 case proc_cpp
: gcc_defs
= 1; break;
220 /* Note: if the C compiler is gcc we assume the C++ compiler is too */
221 /* mixing different C and C++ compilers isn't supported in configure anyway */
222 case proc_cc
: gcc_defs
= 1; break;
223 case proc_cxx
: gcc_defs
= 1; break;
225 case proc_cc
: gcc_defs
= 0; break;
226 case proc_cxx
: gcc_defs
= 0; break;
229 strarray_addall(comp_args
, get_translator(opts
));
231 if (opts
->processor
!= proc_cpp
)
233 #ifdef CC_FLAG_SHORT_WCHAR
234 if (!opts
->wine_mode
&& !opts
->noshortwchar
)
236 strarray_add(comp_args
, CC_FLAG_SHORT_WCHAR
);
237 strarray_add(comp_args
, "-DWINE_UNICODE_NATIVE");
240 strarray_addall(comp_args
, strarray_fromstring(DLLFLAGS
, " "));
242 if (!opts
->wine_mode
&& !opts
->nostdinc
)
244 if (opts
->use_msvcrt
)
246 strarray_add(comp_args
, "-I" INCLUDEDIR
"/msvcrt");
247 strarray_add(comp_args
, "-D__MSVCRT__");
249 strarray_add(comp_args
, "-I" INCLUDEDIR
"/windows");
251 strarray_add(comp_args
, "-DWIN32");
252 strarray_add(comp_args
, "-D_WIN32");
253 strarray_add(comp_args
, "-D__WIN32");
254 strarray_add(comp_args
, "-D__WIN32__");
255 strarray_add(comp_args
, "-D__WINNT");
256 strarray_add(comp_args
, "-D__WINNT__");
260 strarray_add(comp_args
, "-D__stdcall=__attribute__((__stdcall__))");
261 strarray_add(comp_args
, "-D__cdecl=__attribute__((__cdecl__))");
262 strarray_add(comp_args
, "-D__fastcall=__attribute__((__fastcall__))");
263 strarray_add(comp_args
, "-D_stdcall=__attribute__((__stdcall__))");
264 strarray_add(comp_args
, "-D_cdecl=__attribute__((__cdecl__))");
265 strarray_add(comp_args
, "-D_fastcall=__attribute__((__fastcall__))");
266 strarray_add(comp_args
, "-D__declspec(x)=__declspec_##x");
267 strarray_add(comp_args
, "-D__declspec_align(x)=__attribute__((aligned(x)))");
268 strarray_add(comp_args
, "-D__declspec_allocate(x)=__attribute__((section(x)))");
269 strarray_add(comp_args
, "-D__declspec_deprecated=__attribute__((deprecated))");
270 strarray_add(comp_args
, "-D__declspec_dllimport=__attribute__((dllimport))");
271 strarray_add(comp_args
, "-D__declspec_dllexport=__attribute__((dllexport))");
272 strarray_add(comp_args
, "-D__declspec_naked=__attribute__((naked))");
273 strarray_add(comp_args
, "-D__declspec_noinline=__attribute__((noinline))");
274 strarray_add(comp_args
, "-D__declspec_noreturn=__attribute__((noreturn))");
275 strarray_add(comp_args
, "-D__declspec_nothrow=__attribute__((nothrow))");
276 strarray_add(comp_args
, "-D__declspec_novtable=__attribute__(())"); /* ignore it */
277 strarray_add(comp_args
, "-D__declspec_selectany=__attribute__((weak))");
278 strarray_add(comp_args
, "-D__declspec_thread=__thread");
281 /* Wine specific defines */
282 strarray_add(comp_args
, "-D__WINE__");
283 strarray_add(comp_args
, "-D__int8=char");
284 strarray_add(comp_args
, "-D__int16=short");
285 /* FIXME: what about 64-bit platforms? */
286 strarray_add(comp_args
, "-D__int32=int");
287 #ifdef HAVE_LONG_LONG
288 strarray_add(comp_args
, "-D__int64=long long");
291 /* options we handle explicitly */
292 if (opts
->compile_only
)
293 strarray_add(comp_args
, "-c");
294 if (opts
->output_name
)
296 strarray_add(comp_args
, "-o");
297 strarray_add(comp_args
, opts
->output_name
);
300 /* the rest of the pass-through parameters */
301 for ( j
= 0 ; j
< opts
->compiler_args
->size
; j
++ )
302 strarray_add(comp_args
, opts
->compiler_args
->base
[j
]);
304 /* the language option, if any */
305 if (lang
&& strcmp(lang
, "-xnone"))
306 strarray_add(comp_args
, lang
);
308 /* last, but not least, the files */
309 for ( j
= 0; j
< opts
->files
->size
; j
++ )
311 if (opts
->files
->base
[j
][0] != '-')
312 strarray_add(comp_args
, opts
->files
->base
[j
]);
315 spawn(opts
->prefix
, comp_args
);
318 static const char* compile_to_object(struct options
* opts
, const char* file
, const char* lang
)
320 struct options copts
;
323 /* make a copy we so don't change any of the initial stuff */
324 /* a shallow copy is exactly what we want in this case */
325 base_name
= get_basename(file
);
327 copts
.output_name
= get_temp_file(base_name
, ".o");
328 copts
.compile_only
= 1;
329 copts
.files
= strarray_alloc();
330 strarray_add(copts
.files
, file
);
331 compile(&copts
, lang
);
332 strarray_free(copts
.files
);
335 return copts
.output_name
;
338 static void build(struct options
* opts
)
340 static const char *stdlibpath
[] = { DLLDIR
, LIBDIR
, "/usr/lib", "/usr/local/lib", "/lib" };
341 strarray
*lib_dirs
, *files
;
342 strarray
*spec_args
, *link_args
;
344 const char *spec_c_name
, *spec_o_name
;
345 const char *output_name
, *spec_file
, *lang
;
346 const char* winebuild
= getenv("WINEBUILD");
347 int generate_app_loader
= 1;
351 /* NOTE: for the files array we'll use the following convention:
352 * -axxx: xxx is an archive (.a)
353 * -dxxx: xxx is a DLL (.def)
354 * -lxxx: xxx is an unsorted library
355 * -oxxx: xxx is an object (.o)
356 * -rxxx: xxx is a resource (.res)
357 * -sxxx: xxx is a shared lib (.so)
358 * -xlll: lll is the language (c, c++, etc.)
361 if (!winebuild
) winebuild
= "winebuild";
363 output_file
= strdup( opts
->output_name
? opts
->output_name
: "a.out" );
365 /* 'winegcc -o app xxx.exe.so' only creates the load script */
366 if (opts
->files
->size
== 1 && strendswith(opts
->files
->base
[0], ".exe.so"))
368 create_file(output_file
, 0755, app_loader_template
, opts
->files
->base
[0]);
372 /* generate app loader only for .exe */
373 if (opts
->shared
|| strendswith(output_file
, ".exe.so"))
374 generate_app_loader
= 0;
376 /* normalize the filename a bit: strip .so, ensure it has proper ext */
377 if (strendswith(output_file
, ".so"))
378 output_file
[strlen(output_file
) - 3] = 0;
381 if ((output_name
= strrchr(output_file
, '/'))) output_name
++;
382 else output_name
= output_file
;
383 if (!strchr(output_name
, '.'))
384 output_file
= strmake("%s.dll", output_file
);
386 else if (!strendswith(output_file
, ".exe"))
387 output_file
= strmake("%s.exe", output_file
);
389 /* get the filename from the path */
390 if ((output_name
= strrchr(output_file
, '/'))) output_name
++;
391 else output_name
= output_file
;
393 /* prepare the linking path */
394 lib_dirs
= strarray_dup(opts
->lib_dirs
);
395 if (!opts
->wine_mode
)
397 for ( j
= 0; j
< sizeof(stdlibpath
)/sizeof(stdlibpath
[0]); j
++ )
398 strarray_add(lib_dirs
, stdlibpath
[j
]);
401 /* mark the files with their appropriate type */
402 spec_file
= lang
= 0;
403 files
= strarray_alloc();
404 for ( j
= 0; j
< opts
->files
->size
; j
++ )
406 const char* file
= opts
->files
->base
[j
];
409 switch(get_file_type(file
))
414 error("Spec file %s not supported in non-shared mode", file
);
416 error("Only one spec file can be specified in shared mode");
420 /* FIXME: invoke wrc to build it */
421 error("Can't compile .rc file at the moment: %s", file
);
424 strarray_add(files
, strmake("-r%s", file
));
427 strarray_add(files
, strmake("-o%s", file
));
430 strarray_add(files
, strmake("-a%s", file
));
433 strarray_add(files
, strmake("-s%s", file
));
436 error("File does not exist: %s", file
);
439 file
= compile_to_object(opts
, file
, lang
);
440 strarray_add(files
, strmake("-o%s", file
));
444 else if (file
[1] == 'l')
447 switch(get_lib_type(lib_dirs
, file
+ 2, &fullname
))
450 strarray_add(files
, strmake("-a%s", fullname
));
453 strarray_add(files
, strmake("-d%s", file
+ 2));
456 strarray_add(files
, strmake("-s%s", file
+ 2));
459 /* keep it anyway, the linker may know what to do with it */
460 strarray_add(files
, file
);
465 else if (file
[1] == 'x')
468 if (opts
->shared
&& !spec_file
)
469 error("A spec file is currently needed in shared mode");
471 /* add the default libraries, if needed */
474 if (opts
->use_msvcrt
) strarray_add(files
, "-dmsvcrt");
477 if (!opts
->wine_mode
&& !opts
->nodefaultlibs
)
481 strarray_add(files
, "-dshell32");
482 strarray_add(files
, "-dcomdlg32");
483 strarray_add(files
, "-dgdi32");
485 strarray_add(files
, "-dadvapi32");
486 strarray_add(files
, "-duser32");
487 strarray_add(files
, "-dkernel32");
490 /* run winebuild to generate the .spec.c file */
491 spec_args
= strarray_alloc();
492 spec_c_name
= get_temp_file(output_name
, ".spec.c");
493 strarray_add(spec_args
, winebuild
);
494 strarray_add(spec_args
, "--ld-cmd");
495 strarray_add(spec_args
, LD
);
496 strarray_add(spec_args
, "-o");
497 strarray_add(spec_args
, spec_c_name
);
500 strarray_add(spec_args
, "--dll");
501 strarray_add(spec_args
, spec_file
);
505 strarray_add(spec_args
, "--exe");
506 strarray_add(spec_args
, output_name
);
507 strarray_add(spec_args
, "--subsystem");
508 strarray_add(spec_args
, opts
->gui_app
? "windows" : "console");
511 for ( j
= 0; j
< lib_dirs
->size
; j
++ )
512 strarray_add(spec_args
, strmake("-L%s", lib_dirs
->base
[j
]));
514 for ( j
= 0 ; j
< opts
->winebuild_args
->size
; j
++ )
515 strarray_add(spec_args
, opts
->winebuild_args
->base
[j
]);
517 for ( j
= 0; j
< files
->size
; j
++ )
519 const char* name
= files
->base
[j
] + 2;
520 switch(files
->base
[j
][1])
523 strarray_add(spec_args
, strmake("-l%s", name
));
526 strarray_add(spec_args
, files
->base
[j
]);
530 strarray_add(spec_args
, name
);
535 spawn(opts
->prefix
, spec_args
);
537 /* compile the .spec.c file into a .spec.o file */
538 old_processor
= opts
->processor
;
539 /* Always compile spec.c as c, even if linking with g++ */
540 opts
->processor
= proc_cc
;
541 spec_o_name
= compile_to_object(opts
, spec_c_name
, 0);
542 opts
->processor
= old_processor
;
544 /* link everything together now */
545 link_args
= strarray_alloc();
546 strarray_addall(link_args
, get_translator(opts
));
547 strarray_addall(link_args
, strarray_fromstring(LDDLLFLAGS
, " "));
549 strarray_add(link_args
, "-o");
550 strarray_add(link_args
, strmake("%s.so", output_file
));
552 for ( j
= 0 ; j
< opts
->linker_args
->size
; j
++ )
553 strarray_add(link_args
, opts
->linker_args
->base
[j
]);
555 for ( j
= 0; j
< lib_dirs
->size
; j
++ )
556 strarray_add(link_args
, strmake("-L%s", lib_dirs
->base
[j
]));
558 strarray_add(link_args
, spec_o_name
);
560 for ( j
= 0; j
< files
->size
; j
++ )
562 const char* name
= files
->base
[j
] + 2;
563 switch(files
->base
[j
][1])
567 strarray_add(link_args
, strmake("-l%s", name
));
571 strarray_add(link_args
, name
);
578 strarray_add(link_args
, "-lwine");
579 strarray_add(link_args
, "-lm");
580 strarray_add(link_args
, "-lc");
583 spawn(opts
->prefix
, link_args
);
585 /* create the loader script */
586 if (generate_app_loader
)
588 if (strendswith(output_file
, ".exe")) output_file
[strlen(output_file
) - 4] = 0;
589 create_file(output_file
, 0755, app_loader_template
, strmake("%s.exe.so", output_name
));
594 static void forward(int argc
, char **argv
, struct options
* opts
)
596 strarray
* args
= strarray_alloc();
599 strarray_addall(args
, get_translator(opts
));
601 for( j
= 1; j
< argc
; j
++ )
602 strarray_add(args
, argv
[j
]);
604 spawn(opts
->prefix
, args
);
609 * object-file-name -llibrary -nostartfiles -nodefaultlibs
610 * -nostdlib -s -static -static-libgcc -shared -shared-libgcc
611 * -symbolic -Wl,option -Xlinker option -u symbol
614 static int is_linker_arg(const char* arg
)
616 static const char* link_switches
[] =
618 "-nostartfiles", "-nodefaultlibs", "-nostdlib", "-s",
619 "-static", "-static-libgcc", "-shared", "-shared-libgcc", "-symbolic",
630 if (strncmp("-Wl,", arg
, 4) == 0) return 1;
633 if (strcmp("-Xlinker", arg
) == 0) return 1;
637 for (j
= 0; j
< sizeof(link_switches
)/sizeof(link_switches
[0]); j
++)
638 if (strcmp(link_switches
[j
], arg
) == 0) return 1;
645 * -b machine -V version
647 static int is_target_arg(const char* arg
)
649 return arg
[1] == 'b' || arg
[2] == 'V';
655 * -Bprefix -Idir -I- -Ldir -specs=file
657 static int is_directory_arg(const char* arg
)
659 return arg
[1] == 'B' || arg
[1] == 'L' || arg
[1] == 'I' || strncmp("-specs=", arg
, 7) == 0;
664 * -mno-cygwin -mwindows -mconsole -mthreads
666 static int is_mingw_arg(const char* arg
)
668 static const char* mingw_switches
[] =
670 "-mno-cygwin", "-mwindows", "-mconsole", "-mthreads"
674 for (j
= 0; j
< sizeof(mingw_switches
)/sizeof(mingw_switches
[0]); j
++)
675 if (strcmp(mingw_switches
[j
], arg
) == 0) return 1;
680 int main(int argc
, char **argv
)
682 int i
, c
, next_is_arg
= 0, linking
= 1;
683 int raw_compiler_arg
, raw_linker_arg
;
684 const char* option_arg
;
689 /* setup tmp file removal at exit */
690 tmp_files
= strarray_alloc();
691 atexit(clean_temp_files
);
693 /* initialize options */
694 memset(&opts
, 0, sizeof(opts
));
695 opts
.lib_dirs
= strarray_alloc();
696 opts
.files
= strarray_alloc();
697 opts
.linker_args
= strarray_alloc();
698 opts
.compiler_args
= strarray_alloc();
699 opts
.winebuild_args
= strarray_alloc();
701 /* determine the processor type */
702 if (strendswith(argv
[0], "winecpp")) opts
.processor
= proc_cpp
;
703 else if (strendswith(argv
[0], "++")) opts
.processor
= proc_cxx
;
706 for ( i
= 1 ; i
< argc
; i
++ )
708 if (argv
[i
][0] == '-') /* option */
710 /* determine if tihs switch is followed by a separate argument */
715 case 'x': case 'o': case 'D': case 'U':
716 case 'I': case 'A': case 'l': case 'u':
717 case 'b': case 'V': case 'G': case 'L':
719 if (argv
[i
][2]) option_arg
= &argv
[i
][2];
720 else next_is_arg
= 1;
726 if (strcmp("-aux-info", argv
[i
]) == 0)
730 if (strcmp("-Xlinker", argv
[i
]) == 0)
735 if (c
== 'F' || c
== 'T' || c
== 'Q')
737 if (argv
[i
][3]) option_arg
= &argv
[i
][3];
738 else next_is_arg
= 1;
742 if (strcmp("-framework", argv
[i
]) == 0)
746 if (next_is_arg
) option_arg
= argv
[i
+1];
748 /* determine what options go 'as is' to the linker & the compiler */
749 raw_compiler_arg
= raw_linker_arg
= 0;
750 if (is_linker_arg(argv
[i
]))
756 if (is_directory_arg(argv
[i
]) || is_target_arg(argv
[i
]))
758 raw_compiler_arg
= !is_mingw_arg(argv
[i
]);
761 /* these things we handle explicitly so we don't pass them 'as is' */
762 if (argv
[i
][1] == 'l' || argv
[i
][1] == 'I' || argv
[i
][1] == 'L')
764 if (argv
[i
][1] == 'c' || argv
[i
][1] == 'L')
765 raw_compiler_arg
= 0;
766 if (argv
[i
][1] == 'o')
767 raw_compiler_arg
= raw_linker_arg
= 0;
769 /* do a bit of semantic analysis */
773 str
= strdup(option_arg
);
774 if (strendswith(str
, "/tools/winebuild"))
777 /* don't pass it to the compiler, this generates warnings */
778 raw_compiler_arg
= raw_linker_arg
= 0;
780 if (strendswith(str
, "/")) str
[strlen(str
) - 1] = 0;
781 if (!opts
.prefix
) opts
.prefix
= strarray_alloc();
782 strarray_add(opts
.prefix
, str
);
784 case 'c': /* compile or assemble */
785 if (argv
[i
][2] == 0) opts
.compile_only
= 1;
787 case 'S': /* generate assembler code */
788 case 'E': /* preprocess only */
789 if (argv
[i
][2] == 0) linking
= 0;
792 if (strcmp("-fno-short-wchar", argv
[i
]) == 0)
793 opts
.noshortwchar
= 1;
796 strarray_add(opts
.files
, strmake("-l%s", option_arg
));
799 strarray_add(opts
.lib_dirs
, option_arg
);
801 case 'M': /* map file generation */
805 if (strcmp("-mno-cygwin", argv
[i
]) == 0)
807 else if (strcmp("-mwindows", argv
[i
]) == 0)
809 else if (strcmp("-mconsole", argv
[i
]) == 0)
813 if (strcmp("-nostdinc", argv
[i
]) == 0)
815 else if (strcmp("-nodefaultlibs", argv
[i
]) == 0)
816 opts
.nodefaultlibs
= 1;
817 else if (strcmp("-nostdlib", argv
[i
]) == 0)
821 opts
.output_name
= option_arg
;
824 if (strcmp("-static", argv
[i
]) == 0)
826 else if(strcmp("-save-temps", argv
[i
]) == 0)
828 else if(strcmp("-shared", argv
[i
]) == 0)
831 raw_compiler_arg
= raw_linker_arg
= 0;
835 if (argv
[i
][2] == 0) verbose
++;
838 if (strncmp("-Wl,", argv
[i
], 4) == 0)
840 if (strstr(argv
[i
], "-static"))
843 else if (strncmp("-Wb,", argv
[i
], 4) == 0)
845 strarray
* Wb
= strarray_fromstring(argv
[i
] + 4, ",");
846 strarray_addall(opts
.winebuild_args
, Wb
);
848 /* don't pass it to the compiler, it generates errors */
849 raw_compiler_arg
= raw_linker_arg
= 0;
853 lang
= strmake("-x%s", option_arg
);
854 strarray_add(opts
.files
, lang
);
855 /* we'll pass these flags ourselves, explicitely */
856 raw_compiler_arg
= raw_linker_arg
= 0;
859 if (strcmp("-static", argv
[i
]+1) == 0)
864 /* put the arg into the appropriate bucket */
867 strarray_add(opts
.linker_args
, argv
[i
]);
868 if (next_is_arg
&& (i
+ 1 < argc
))
869 strarray_add(opts
.linker_args
, argv
[i
+ 1]);
871 if (raw_compiler_arg
)
873 strarray_add(opts
.compiler_args
, argv
[i
]);
874 if (next_is_arg
&& (i
+ 1 < argc
))
875 strarray_add(opts
.compiler_args
, argv
[i
+ 1]);
878 /* skip the next token if it's an argument */
879 if (next_is_arg
) i
++;
883 strarray_add(opts
.files
, argv
[i
]);
887 if (opts
.processor
== proc_cpp
) linking
= 0;
888 if (linking
== -1) error("Static linking is not supported.");
890 if (opts
.files
->size
== 0) forward(argc
, argv
, &opts
);
891 else if (linking
) build(&opts
);
892 else compile(&opts
, lang
);