* Bring back rbuild build to be used until bug 6372 is fixed.
[reactos.git] / tools / winebuild / main.c
1 /*
2 * Main function
3 *
4 * Copyright 1993 Robert J. Amstadt
5 * Copyright 1995 Martin von Loewis
6 * Copyright 1995, 1996, 1997 Alexandre Julliard
7 * Copyright 1997 Eric Youngdale
8 * Copyright 1999 Ulrich Weigand
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25 #include "config.h"
26 #include "wine/port.h"
27
28 #include <assert.h>
29 #include <stdio.h>
30 #include <signal.h>
31 #include <errno.h>
32 #include <string.h>
33 #include <stdarg.h>
34 #include <ctype.h>
35 #ifdef HAVE_GETOPT_H
36 # include <getopt.h>
37 #endif
38
39 #include "build.h"
40
41 int UsePIC = 0;
42 int nb_lib_paths = 0;
43 int nb_errors = 0;
44 int display_warnings = 0;
45 int kill_at = 0;
46 int verbose = 0;
47 int save_temps = 0;
48 int link_ext_symbols = 0;
49 int force_pointer_size = 0;
50
51 #if defined(TARGET_i386)
52 enum target_cpu target_cpu = CPU_x86;
53 #elif defined(TARGET_amd64)
54 enum target_cpu target_cpu = CPU_x86_64;
55 #elif defined(__sparc__)
56 enum target_cpu target_cpu = CPU_SPARC;
57 #elif defined(__ALPHA__)
58 enum target_cpu target_cpu = CPU_ALPHA;
59 #elif defined(__powerpc__)
60 enum target_cpu target_cpu = CPU_POWERPC;
61 #elif defined(TARGET_arm)
62 enum target_cpu target_cpu = CPU_ARM;
63 #else
64 #error Unsupported CPU
65 #endif
66
67 #ifdef __APPLE__
68 enum target_platform target_platform = PLATFORM_APPLE;
69 #elif defined(__FreeBSD__)
70 enum target_platform target_platform = PLATFORM_FREEBSD;
71 #elif defined(__sun)
72 enum target_platform target_platform = PLATFORM_SOLARIS;
73 #elif defined(_WIN32)
74 enum target_platform target_platform = PLATFORM_WINDOWS;
75 #else
76 enum target_platform target_platform = PLATFORM_UNSPECIFIED;
77 #endif
78
79 char *target_alias = NULL;
80 char **lib_path = NULL;
81
82 char *input_file_name = NULL;
83 char *spec_file_name = NULL;
84 FILE *output_file = NULL;
85 const char *output_file_name = NULL;
86 static const char *output_file_source_name;
87 static int fake_module;
88
89 char *as_command = NULL;
90 char *ld_command = NULL;
91 char *nm_command = NULL;
92
93 static int nb_res_files;
94 static char **res_files;
95
96 /* execution mode */
97 enum exec_mode_values
98 {
99 MODE_NONE,
100 MODE_DLL,
101 MODE_EXE,
102 MODE_DEF,
103 MODE_RELAY16,
104 MODE_RELAY32,
105 MODE_RESOURCES,
106 MODE_PEDLL
107 };
108
109 static enum exec_mode_values exec_mode = MODE_NONE;
110
111 static const struct
112 {
113 const char *name;
114 enum target_platform platform;
115 } platform_names[] =
116 {
117 { "macos", PLATFORM_APPLE },
118 { "darwin", PLATFORM_APPLE },
119 { "freebsd", PLATFORM_FREEBSD },
120 { "solaris", PLATFORM_SOLARIS },
121 { "windows", PLATFORM_WINDOWS },
122 { "winnt", PLATFORM_WINDOWS }
123 };
124
125 /* set the dll file name from the input file name */
126 static void set_dll_file_name( const char *name, DLLSPEC *spec )
127 {
128 char *p;
129
130 if (spec->file_name) return;
131
132 if ((p = strrchr( name, '\\' ))) name = p + 1;
133 if ((p = strrchr( name, '/' ))) name = p + 1;
134 spec->file_name = xmalloc( strlen(name) + 5 );
135 strcpy( spec->file_name, name );
136 if ((p = strrchr( spec->file_name, '.' )))
137 {
138 if (!strcmp( p, ".spec" ) || !strcmp( p, ".def" )) *p = 0;
139 }
140 }
141
142 /* set the dll subsystem */
143 static void set_subsystem( const char *subsystem, DLLSPEC *spec )
144 {
145 char *major, *minor, *str = xstrdup( subsystem );
146
147 if ((major = strchr( str, ':' ))) *major++ = 0;
148 if (!strcmp( str, "native" )) spec->subsystem = IMAGE_SUBSYSTEM_NATIVE;
149 else if (!strcmp( str, "windows" )) spec->subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
150 else if (!strcmp( str, "console" )) spec->subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
151 else if (!strcmp( str, "win16" )) spec->type = SPEC_WIN16;
152 else fatal_error( "Invalid subsystem name '%s'\n", subsystem );
153 if (major)
154 {
155 if ((minor = strchr( major, '.' )))
156 {
157 *minor++ = 0;
158 spec->subsystem_minor = atoi( minor );
159 }
160 spec->subsystem_major = atoi( major );
161 }
162 free( str );
163 }
164
165 /* set the target CPU and platform */
166 static void set_target( const char *target )
167 {
168 unsigned int i;
169 char *p, *platform, *spec = xstrdup( target );
170
171 /* target specification is in the form CPU-MANUFACTURER-OS or CPU-MANUFACTURER-KERNEL-OS */
172
173 target_alias = xstrdup( target );
174
175 /* get the CPU part */
176
177 if (!(p = strchr( spec, '-' ))) fatal_error( "Invalid target specification '%s'\n", target );
178 *p++ = 0;
179 if ((target_cpu = get_cpu_from_name( spec )) == -1)
180 fatal_error( "Unrecognized CPU '%s'\n", spec );
181 platform = p;
182 if ((p = strrchr( p, '-' ))) platform = p + 1;
183
184 /* get the OS part */
185
186 target_platform = PLATFORM_UNSPECIFIED; /* default value */
187 for (i = 0; i < sizeof(platform_names)/sizeof(platform_names[0]); i++)
188 {
189 if (!strncmp( platform_names[i].name, platform, strlen(platform_names[i].name) ))
190 {
191 target_platform = platform_names[i].platform;
192 break;
193 }
194 }
195
196 free( spec );
197 }
198
199 /* cleanup on program exit */
200 static void cleanup(void)
201 {
202 if (output_file_name) unlink( output_file_name );
203 }
204
205 /* clean things up when aborting on a signal */
206 static void exit_on_signal( int sig )
207 {
208 exit(1); /* this will call atexit functions */
209 }
210
211 /*******************************************************************
212 * command-line option handling
213 */
214 static const char usage_str[] =
215 "Usage: winebuild [OPTIONS] [FILES]\n\n"
216 "Options:\n"
217 " --as-cmd=AS Command to use for assembling (default: as)\n"
218 " -b, --target=TARGET Specify target CPU and platform for cross-compiling\n"
219 " -d, --delay-lib=LIB Import the specified library in delayed mode\n"
220 " -D SYM Ignored for C flags compatibility\n"
221 " -e, --entry=FUNC Set the DLL entry point function (default: DllMain)\n"
222 " -E, --export=FILE Export the symbols defined in the .spec or .def file\n"
223 " --external-symbols Allow linking to external symbols\n"
224 " -f FLAGS Compiler flags (only -fPIC is supported)\n"
225 " -F, --filename=DLLFILE Set the DLL filename (default: from input file name)\n"
226 " --fake-module Create a fake binary module\n"
227 " -h, --help Display this help message\n"
228 " -H, --heap=SIZE Set the heap size for a Win16 dll\n"
229 " -i, --ignore=SYM[,SYM] Ignore specified symbols when resolving imports\n"
230 " -I DIR Ignored for C flags compatibility\n"
231 " -k, --kill-at Kill stdcall decorations in generated .def files\n"
232 " -K, FLAGS Compiler flags (only -KPIC is supported)\n"
233 " --large-address-aware Support an address space larger than 2Gb\n"
234 " --ld-cmd=LD Command to use for linking (default: ld)\n"
235 " -l, --library=LIB Import the specified library\n"
236 " -L, --library-path=DIR Look for imports libraries in DIR\n"
237 " -m32, -m64 Force building 32-bit resp. 64-bit code\n"
238 " -M, --main-module=MODULE Set the name of the main module for a Win16 dll\n"
239 " --nm-cmd=NM Command to use to get undefined symbols (default: nm)\n"
240 " --nxcompat=y|n Set the NX compatibility flag (default: yes)\n"
241 " -N, --dll-name=DLLNAME Set the DLL name (default: from input file name)\n"
242 " -o, --output=NAME Set the output file name (default: stdout)\n"
243 " -r, --res=RSRC.RES Load resources from RSRC.RES\n"
244 " --save-temps Do not delete the generated intermediate files\n"
245 " --subsystem=SUBSYS Set the subsystem (one of native, windows, console)\n"
246 " -u, --undefined=SYMBOL Add an undefined reference to SYMBOL when linking\n"
247 " -v, --verbose Display the programs invoked\n"
248 " --version Print the version and exit\n"
249 " -w, --warnings Turn on warnings\n"
250 "\nMode options:\n"
251 " --dll Build a .c file from a .spec or .def file\n"
252 " --def Build a .def file from a .spec file\n"
253 " --exe Build a .c file for an executable\n"
254 " --relay16 Build the 16-bit relay assembly routines\n"
255 " --relay32 Build the 32-bit relay assembly routines\n"
256 " --resources Build a .o file for the resource files\n\n"
257 " --pedll Build a .c file for PE dll\n\n"
258 "The mode options are mutually exclusive; you must specify one and only one.\n\n";
259
260 enum long_options_values
261 {
262 LONG_OPT_DLL = 1,
263 LONG_OPT_DEF,
264 LONG_OPT_EXE,
265 LONG_OPT_ASCMD,
266 LONG_OPT_EXTERNAL_SYMS,
267 LONG_OPT_FAKE_MODULE,
268 LONG_OPT_LARGE_ADDRESS_AWARE,
269 LONG_OPT_LDCMD,
270 LONG_OPT_NMCMD,
271 LONG_OPT_NXCOMPAT,
272 LONG_OPT_RELAY16,
273 LONG_OPT_RELAY32,
274 LONG_OPT_RESOURCES,
275 LONG_OPT_SAVE_TEMPS,
276 LONG_OPT_SUBSYSTEM,
277 LONG_OPT_VERSION,
278 LONG_OPT_PEDLL
279 };
280
281 static const char short_options[] = "C:D:E:F:H:I:K:L:M:N:b:d:e:f:hi:kl:m:o:r:u:vw";
282
283 static const struct option long_options[] =
284 {
285 { "dll", 0, 0, LONG_OPT_DLL },
286 { "def", 0, 0, LONG_OPT_DEF },
287 { "exe", 0, 0, LONG_OPT_EXE },
288 { "as-cmd", 1, 0, LONG_OPT_ASCMD },
289 { "external-symbols", 0, 0, LONG_OPT_EXTERNAL_SYMS },
290 { "fake-module", 0, 0, LONG_OPT_FAKE_MODULE },
291 { "large-address-aware", 0, 0, LONG_OPT_LARGE_ADDRESS_AWARE },
292 { "ld-cmd", 1, 0, LONG_OPT_LDCMD },
293 { "nm-cmd", 1, 0, LONG_OPT_NMCMD },
294 { "nxcompat", 1, 0, LONG_OPT_NXCOMPAT },
295 { "relay16", 0, 0, LONG_OPT_RELAY16 },
296 { "relay32", 0, 0, LONG_OPT_RELAY32 },
297 { "resources", 0, 0, LONG_OPT_RESOURCES },
298 { "save-temps", 0, 0, LONG_OPT_SAVE_TEMPS },
299 { "subsystem", 1, 0, LONG_OPT_SUBSYSTEM },
300 { "version", 0, 0, LONG_OPT_VERSION },
301 { "pedll", 1, 0, LONG_OPT_PEDLL },
302 /* aliases for short options */
303 { "target", 1, 0, 'b' },
304 { "delay-lib", 1, 0, 'd' },
305 { "export", 1, 0, 'E' },
306 { "entry", 1, 0, 'e' },
307 { "filename", 1, 0, 'F' },
308 { "help", 0, 0, 'h' },
309 { "heap", 1, 0, 'H' },
310 { "ignore", 1, 0, 'i' },
311 { "kill-at", 0, 0, 'k' },
312 { "library", 1, 0, 'l' },
313 { "library-path", 1, 0, 'L' },
314 { "main-module", 1, 0, 'M' },
315 { "dll-name", 1, 0, 'N' },
316 { "output", 1, 0, 'o' },
317 { "res", 1, 0, 'r' },
318 { "undefined", 1, 0, 'u' },
319 { "verbose", 0, 0, 'v' },
320 { "warnings", 0, 0, 'w' },
321 { NULL, 0, 0, 0 }
322 };
323
324 static void usage( int exit_code )
325 {
326 fprintf( stderr, "%s", usage_str );
327 exit( exit_code );
328 }
329
330 static void set_exec_mode( enum exec_mode_values mode )
331 {
332 if (exec_mode != MODE_NONE) usage(1);
333 exec_mode = mode;
334 }
335
336 /* parse options from the argv array and remove all the recognized ones */
337 static char **parse_options( int argc, char **argv, DLLSPEC *spec )
338 {
339 char *p;
340 int optc;
341
342 while ((optc = getopt_long( argc, argv, short_options, long_options, NULL )) != -1)
343 {
344 switch(optc)
345 {
346 case 'D':
347 /* ignored */
348 break;
349 case 'E':
350 spec_file_name = xstrdup( optarg );
351 set_dll_file_name( optarg, spec );
352 break;
353 case 'F':
354 spec->file_name = xstrdup( optarg );
355 break;
356 case 'H':
357 if (!isdigit(optarg[0]))
358 fatal_error( "Expected number argument with -H option instead of '%s'\n", optarg );
359 spec->heap_size = atoi(optarg);
360 if (spec->heap_size > 65535)
361 fatal_error( "Invalid heap size %d, maximum is 65535\n", spec->heap_size );
362 break;
363 case 'I':
364 /* ignored */
365 break;
366 case 'K':
367 /* ignored, because cc generates correct code. */
368 break;
369 case 'L':
370 lib_path = xrealloc( lib_path, (nb_lib_paths+1) * sizeof(*lib_path) );
371 lib_path[nb_lib_paths++] = xstrdup( optarg );
372 break;
373 case 'm':
374 if (strcmp( optarg, "32" ) && strcmp( optarg, "64" ))
375 fatal_error( "Invalid -m option '%s', expected -m32 or -m64\n", optarg );
376 if (!strcmp( optarg, "32" )) force_pointer_size = 4;
377 else force_pointer_size = 8;
378 break;
379 case 'M':
380 spec->main_module = xstrdup( optarg );
381 break;
382 case 'N':
383 spec->dll_name = xstrdup( optarg );
384 break;
385 case 'b':
386 set_target( optarg );
387 break;
388 case 'd':
389 add_delayed_import( optarg );
390 break;
391 case 'e':
392 spec->init_func = xstrdup( optarg );
393 if ((p = strchr( spec->init_func, '@' ))) *p = 0; /* kill stdcall decoration */
394 break;
395 case 'f':
396 if (!strcmp( optarg, "PIC") || !strcmp( optarg, "pic")) UsePIC = 1;
397 /* ignore all other flags */
398 break;
399 case 'h':
400 usage(0);
401 break;
402 case 'i':
403 {
404 char *str = xstrdup( optarg );
405 char *token = strtok( str, "," );
406 while (token)
407 {
408 add_ignore_symbol( token );
409 token = strtok( NULL, "," );
410 }
411 free( str );
412 }
413 break;
414 case 'k':
415 kill_at = 1;
416 break;
417 case 'l':
418 add_import_dll( optarg, NULL );
419 break;
420 case 'o':
421 {
422 char *ext = strrchr( optarg, '.' );
423
424 if (unlink( optarg ) == -1 && errno != ENOENT)
425 fatal_error( "Unable to create output file '%s'\n", optarg );
426 if (ext && !strcmp( ext, ".o" ))
427 {
428 output_file_source_name = get_temp_file_name( optarg, ".s" );
429 if (!(output_file = fopen( output_file_source_name, "w" )))
430 fatal_error( "Unable to create output file '%s'\n", optarg );
431 }
432 else
433 {
434 if (!(output_file = fopen( optarg, "w" )))
435 fatal_error( "Unable to create output file '%s'\n", optarg );
436 }
437 output_file_name = xstrdup(optarg);
438 atexit( cleanup ); /* make sure we remove the output file on exit */
439 }
440 break;
441 case 'r':
442 res_files = xrealloc( res_files, (nb_res_files+1) * sizeof(*res_files) );
443 res_files[nb_res_files++] = xstrdup( optarg );
444 break;
445 case 'u':
446 add_extra_ld_symbol( optarg );
447 break;
448 case 'v':
449 verbose++;
450 break;
451 case 'w':
452 display_warnings = 1;
453 break;
454 case LONG_OPT_DLL:
455 set_exec_mode( MODE_DLL );
456 break;
457 case LONG_OPT_DEF:
458 set_exec_mode( MODE_DEF );
459 break;
460 case LONG_OPT_EXE:
461 set_exec_mode( MODE_EXE );
462 if (!spec->subsystem) spec->subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
463 break;
464 case LONG_OPT_ASCMD:
465 as_command = xstrdup( optarg );
466 break;
467 case LONG_OPT_FAKE_MODULE:
468 fake_module = 1;
469 break;
470 case LONG_OPT_EXTERNAL_SYMS:
471 link_ext_symbols = 1;
472 break;
473 case LONG_OPT_LARGE_ADDRESS_AWARE:
474 spec->characteristics |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
475 break;
476 case LONG_OPT_LDCMD:
477 ld_command = xstrdup( optarg );
478 break;
479 case LONG_OPT_NMCMD:
480 nm_command = xstrdup( optarg );
481 break;
482 case LONG_OPT_NXCOMPAT:
483 if (optarg[0] == 'n' || optarg[0] == 'N')
484 spec->dll_characteristics &= ~IMAGE_DLLCHARACTERISTICS_NX_COMPAT;
485 break;
486 case LONG_OPT_RELAY16:
487 set_exec_mode( MODE_RELAY16 );
488 break;
489 case LONG_OPT_RELAY32:
490 set_exec_mode( MODE_RELAY32 );
491 break;
492 case LONG_OPT_RESOURCES:
493 set_exec_mode( MODE_RESOURCES );
494 break;
495 case LONG_OPT_SAVE_TEMPS:
496 save_temps = 1;
497 break;
498 case LONG_OPT_SUBSYSTEM:
499 set_subsystem( optarg, spec );
500 break;
501 case LONG_OPT_VERSION:
502 printf( "winebuild version " PACKAGE_VERSION "\n" );
503 exit(0);
504 case LONG_OPT_PEDLL:
505 set_exec_mode( MODE_PEDLL );
506 spec_file_name = xstrdup( optarg );
507 set_dll_file_name( optarg, spec );
508 break;
509 case '?':
510 usage(1);
511 break;
512 }
513 }
514
515 if (spec->file_name && !strchr( spec->file_name, '.' ))
516 strcat( spec->file_name, exec_mode == MODE_EXE ? ".exe" : ".dll" );
517
518 switch (target_cpu)
519 {
520 case CPU_x86:
521 if (force_pointer_size == 8) target_cpu = CPU_x86_64;
522 break;
523 case CPU_x86_64:
524 if (force_pointer_size == 4) target_cpu = CPU_x86;
525 break;
526 default:
527 if (force_pointer_size == 8)
528 fatal_error( "Cannot build 64-bit code for this CPU\n" );
529 break;
530 }
531
532 return &argv[optind];
533 }
534
535
536 /* load all specified resource files */
537 static void load_resources( char *argv[], DLLSPEC *spec )
538 {
539 int i;
540 char **ptr, **last;
541
542 switch (spec->type)
543 {
544 case SPEC_WIN16:
545 for (i = 0; i < nb_res_files; i++) load_res16_file( res_files[i], spec );
546 break;
547
548 case SPEC_WIN32:
549 for (i = 0; i < nb_res_files; i++)
550 {
551 if (!load_res32_file( res_files[i], spec ))
552 fatal_error( "%s is not a valid Win32 resource file\n", res_files[i] );
553 }
554
555 /* load any resource file found in the remaining arguments */
556 for (ptr = last = argv; *ptr; ptr++)
557 {
558 if (!load_res32_file( *ptr, spec ))
559 *last++ = *ptr; /* not a resource file, keep it in the list */
560 }
561 *last = NULL;
562 break;
563 }
564 }
565
566 /* add input files that look like import libs to the import list */
567 static void load_import_libs( char *argv[] )
568 {
569 char **ptr, **last;
570
571 for (ptr = last = argv; *ptr; ptr++)
572 {
573 if (strendswith( *ptr, ".def" ))
574 add_import_dll( NULL, *ptr );
575 else
576 *last++ = *ptr; /* not an import dll, keep it in the list */
577 }
578 *last = NULL;
579 }
580
581 static int parse_input_file( DLLSPEC *spec )
582 {
583 FILE *input_file = open_input_file( NULL, spec_file_name );
584 char *extension = strrchr( spec_file_name, '.' );
585 int result;
586
587 spec->src_name = xstrdup( input_file_name );
588 if (extension && !strcmp( extension, ".def" ))
589 result = parse_def_file( input_file, spec );
590 else
591 result = parse_spec_file( input_file, spec );
592 close_input_file( input_file );
593 return result;
594 }
595
596
597 /*******************************************************************
598 * main
599 */
600 int main(int argc, char **argv)
601 {
602 DLLSPEC *spec = alloc_dll_spec();
603
604 #ifdef SIGHUP
605 signal( SIGHUP, exit_on_signal );
606 #endif
607 signal( SIGTERM, exit_on_signal );
608 signal( SIGINT, exit_on_signal );
609
610 output_file = stdout;
611 argv = parse_options( argc, argv, spec );
612
613 switch(exec_mode)
614 {
615 case MODE_DLL:
616 if (spec->subsystem != IMAGE_SUBSYSTEM_NATIVE)
617 spec->characteristics |= IMAGE_FILE_DLL;
618 if (!spec_file_name) fatal_error( "missing .spec file\n" );
619 if (spec->type == SPEC_WIN32 && spec->main_module) /* embedded 16-bit module */
620 {
621 spec->type = SPEC_WIN16;
622 load_resources( argv, spec );
623 if (parse_input_file( spec )) BuildSpec16File( spec );
624 break;
625 }
626 /* fall through */
627 case MODE_EXE:
628 load_resources( argv, spec );
629 load_import_libs( argv );
630 if (spec_file_name && !parse_input_file( spec )) break;
631 if (fake_module)
632 {
633 if (spec->type == SPEC_WIN16) output_fake_module16( spec );
634 else output_fake_module( spec );
635 break;
636 }
637 read_undef_symbols( spec, argv );
638 switch (spec->type)
639 {
640 case SPEC_WIN16:
641 output_spec16_file( spec );
642 break;
643 case SPEC_WIN32:
644 BuildSpec32File( spec );
645 break;
646 default: assert(0);
647 }
648 break;
649 case MODE_DEF:
650 if (argv[0]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[0] );
651 if (spec->type == SPEC_WIN16) fatal_error( "Cannot yet build .def file for 16-bit dlls\n" );
652 if (!spec_file_name) fatal_error( "missing .spec file\n" );
653 if (!parse_input_file( spec )) break;
654 BuildDef32File( spec );
655 break;
656 case MODE_RELAY16:
657 if (argv[0]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[0] );
658 BuildRelays16();
659 break;
660 case MODE_RELAY32:
661 if (argv[0]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[0] );
662 BuildRelays32();
663 break;
664 case MODE_PEDLL:
665 if (argv[0]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[0] );
666 if (!parse_input_file( spec )) break;
667 BuildPedllFile( spec );
668 break;
669 case MODE_RESOURCES:
670 load_resources( argv, spec );
671 output_res_o_file( spec );
672 break;
673 default:
674 usage(1);
675 break;
676 }
677 if (nb_errors) exit(1);
678 if (output_file_name)
679 {
680 if (fclose( output_file ) < 0) fatal_perror( "fclose" );
681 if (output_file_source_name) assemble_file( output_file_source_name, output_file_name );
682 output_file_name = NULL;
683 }
684 return 0;
685 }