~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/tools/winebuild/main.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.