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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
23 | */
|
---|
24 |
|
---|
25 | #include "config.h"
|
---|
26 | #include "port.h"
|
---|
27 |
|
---|
28 | #include <assert.h>
|
---|
29 | #include <stdio.h>
|
---|
30 | #include <errno.h>
|
---|
31 | #include <string.h>
|
---|
32 | #include <ctype.h>
|
---|
33 | #ifdef HAVE_GETOPT_H
|
---|
34 | # include <getopt.h>
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #include "build.h"
|
---|
38 |
|
---|
39 | ORDDEF *EntryPoints[MAX_ORDINALS];
|
---|
40 | ORDDEF *Ordinals[MAX_ORDINALS];
|
---|
41 | ORDDEF *Names[MAX_ORDINALS];
|
---|
42 |
|
---|
43 | SPEC_MODE SpecMode = SPEC_MODE_DLL;
|
---|
44 | SPEC_TYPE SpecType = SPEC_WIN32;
|
---|
45 |
|
---|
46 | int Base = MAX_ORDINALS;
|
---|
47 | int Limit = 0;
|
---|
48 | int DLLHeapSize = 0;
|
---|
49 | int UsePIC = 0;
|
---|
50 | int stack_size = 0;
|
---|
51 | int nb_entry_points = 0;
|
---|
52 | int nb_names = 0;
|
---|
53 | int nb_debug_channels = 0;
|
---|
54 | int nb_lib_paths = 0;
|
---|
55 | int nb_errors = 0;
|
---|
56 | int display_warnings = 0;
|
---|
57 | int kill_at = 0;
|
---|
58 |
|
---|
59 | /* we only support relay debugging on i386 */
|
---|
60 | #if defined(__i386__) && !defined(NO_TRACE_MSGS)
|
---|
61 | int debugging = 1;
|
---|
62 | #else
|
---|
63 | int debugging = 0;
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | char *owner_name = NULL;
|
---|
67 | char *dll_name = NULL;
|
---|
68 | char *dll_file_name = NULL;
|
---|
69 | char *init_func = NULL;
|
---|
70 | char **debug_channels = NULL;
|
---|
71 | char **lib_path = NULL;
|
---|
72 |
|
---|
73 | char *input_file_name = NULL;
|
---|
74 | const char *output_file_name = NULL;
|
---|
75 |
|
---|
76 | static FILE *input_file;
|
---|
77 | static FILE *output_file;
|
---|
78 | static const char *current_src_dir;
|
---|
79 | static int nb_res_files;
|
---|
80 | static char **res_files;
|
---|
81 |
|
---|
82 | /* set the dll file name from the input file name */
|
---|
83 | static void set_dll_file_name( const char *name )
|
---|
84 | {
|
---|
85 | char *p;
|
---|
86 |
|
---|
87 | if (dll_file_name) return;
|
---|
88 |
|
---|
89 | if ((p = strrchr( name, '\\' ))) name = p + 1;
|
---|
90 | if ((p = strrchr( name, '/' ))) name = p + 1;
|
---|
91 | dll_file_name = xmalloc( strlen(name) + 5 );
|
---|
92 | strcpy( dll_file_name, name );
|
---|
93 | if ((p = strrchr( dll_file_name, '.' )) && !strcmp( p, ".def" )) *p = 0;
|
---|
94 | if (!strchr( dll_file_name, '.' )) strcat( dll_file_name, ".dll" );
|
---|
95 |
|
---|
96 | dll_name = strdup(dll_file_name);
|
---|
97 | p = strrchr(dll_name, '.');
|
---|
98 | if(p) *p = 0;
|
---|
99 | }
|
---|
100 |
|
---|
101 |
|
---|
102 | /*******************************************************************
|
---|
103 | * command-line option handling
|
---|
104 | */
|
---|
105 | static const char usage_str[] =
|
---|
106 | "Usage: pebuild dllname dllname.def\n\n";
|
---|
107 |
|
---|
108 |
|
---|
109 | /*******************************************************************
|
---|
110 | * main
|
---|
111 | */
|
---|
112 | int main(int argc, char **argv)
|
---|
113 | {
|
---|
114 | if(argc != 3) {
|
---|
115 | printf(usage_str);
|
---|
116 | return -1;
|
---|
117 | }
|
---|
118 |
|
---|
119 | set_dll_file_name(argv[1]);
|
---|
120 | input_file = open_input_file( NULL, argv[2] );
|
---|
121 |
|
---|
122 | ParseTopLevel(input_file);
|
---|
123 | BuildSpec32File( stdout );
|
---|
124 |
|
---|
125 | return 0;
|
---|
126 | }
|
---|