widl: Add support for standard target options to allow building the right typelib kind when cross-compiling.
diff --git a/Make.rules.in b/Make.rules.in
index 5dc8884..254e8a2 100644
--- a/Make.rules.in
+++ b/Make.rules.in
@@ -183,7 +183,7 @@
$(WIDL) $(IDLFLAGS) -s -S $@ $<
.idl.tlb:
- $(WIDL) $(IDLFLAGS) -t -T $@ $<
+ $(WIDL) $(TARGETFLAGS) $(IDLFLAGS) -t -T $@ $<
.c.ln:
$(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 6ae8bae..98e7a51 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -53,33 +53,35 @@
static const char usage[] =
"Usage: widl [options...] infile.idl\n"
" or: widl [options...] --dlldata-only name1 [name2...]\n"
-" -c Generate client stub\n"
-" -C file Name of client stub file (default is infile_c.c)\n"
-" -d n Set debug level to 'n'\n"
-" -D id[=val] Define preprocessor identifier id=val\n"
-" --dlldata=file Name of the dlldata file (default is dlldata.c)\n"
-" -E Preprocess only\n"
-" -h Generate headers\n"
-" -H file Name of header file (default is infile.h)\n"
-" -I path Set include search dir to path (multiple -I allowed)\n"
-" --local-stubs=file Write empty stubs for call_as/local methods to file\n"
-" -N Do not preprocess input\n"
-" --oldnames Use old naming conventions\n"
-" -p Generate proxy\n"
-" -P file Name of proxy file (default is infile_p.c)\n"
-" --prefix-all=p Prefix names of client stubs / server functions with 'p'\n"
+" -b arch Set the target architecture\n"
+" -c Generate client stub\n"
+" -C file Name of client stub file (default is infile_c.c)\n"
+" -d n Set debug level to 'n'\n"
+" -D id[=val] Define preprocessor identifier id=val\n"
+" --dlldata=file Name of the dlldata file (default is dlldata.c)\n"
+" -E Preprocess only\n"
+" -h Generate headers\n"
+" -H file Name of header file (default is infile.h)\n"
+" -I path Set include search dir to path (multiple -I allowed)\n"
+" --local-stubs=file Write empty stubs for call_as/local methods to file\n"
+" -m32, -m64 Set the kind of typelib to build (Win32 or Win64)\n"
+" -N Do not preprocess input\n"
+" --oldnames Use old naming conventions\n"
+" -p Generate proxy\n"
+" -P file Name of proxy file (default is infile_p.c)\n"
+" --prefix-all=p Prefix names of client stubs / server functions with 'p'\n"
" --prefix-client=p Prefix names of client stubs with 'p'\n"
" --prefix-server=p Prefix names of server functions with 'p'\n"
-" -s Generate server stub\n"
-" -S file Name of server stub file (default is infile_s.c)\n"
-" -t Generate typelib\n"
-" -T file Name of typelib file (default is infile.tlb)\n"
-" -u Generate interface identifiers file\n"
-" -U file Name of interface identifiers file (default is infile_i.c)\n"
-" -V Print version and exit\n"
-" -W Enable pedantic warnings\n"
-" --win32 Only generate 32-bit code\n"
-" --win64 Only generate 64-bit code\n"
+" -s Generate server stub\n"
+" -S file Name of server stub file (default is infile_s.c)\n"
+" -t Generate typelib\n"
+" -T file Name of typelib file (default is infile.tlb)\n"
+" -u Generate interface identifiers file\n"
+" -U file Name of interface identifiers file (default is infile_i.c)\n"
+" -V Print version and exit\n"
+" -W Enable pedantic warnings\n"
+" --win32 Only generate 32-bit code\n"
+" --win64 Only generate 64-bit code\n"
"Debug level 'n' is a bitmask with following meaning:\n"
" * 0x01 Tell which resource is parsed (verbose mode)\n"
" * 0x02 Dump internal structures\n"
@@ -92,7 +94,6 @@
static const char version_string[] = "Wine IDL Compiler version " PACKAGE_VERSION "\n"
"Copyright 2002 Ove Kaaven\n";
-int win32 = 1;
int debuglevel = DEBUGLEVEL_NONE;
int parser_debug, yy_flex_debug;
@@ -152,7 +153,7 @@
};
static const char short_options[] =
- "cC:d:D:EhH:I:NpP:sS:tT:uU:VW";
+ "b:cC:d:D:EhH:I:m:NpP:sS:tT:uU:VW";
static const struct option long_options[] = {
{ "dlldata", 1, 0, DLLDATA_OPTION },
{ "dlldata-only", 0, 0, DLLDATA_ONLY_OPTION },
@@ -227,6 +228,45 @@
wpp_add_define("__WIDL__", NULL);
}
+/* set the target platform */
+static void set_target( const char *target )
+{
+ static const struct
+ {
+ const char *name;
+ syskind_t kind;
+ } cpu_names[] =
+ {
+ { "i386", SYS_WIN32 },
+ { "i486", SYS_WIN32 },
+ { "i586", SYS_WIN32 },
+ { "i686", SYS_WIN32 },
+ { "i786", SYS_WIN32 },
+ { "x86_64", SYS_WIN64 },
+ { "sparc", SYS_WIN32 },
+ { "alpha", SYS_WIN32 },
+ { "powerpc", SYS_WIN32 }
+ };
+
+ unsigned int i;
+ char *p, *spec = xstrdup( target );
+
+ /* target specification is in the form CPU-MANUFACTURER-OS or CPU-MANUFACTURER-KERNEL-OS */
+
+ if (!(p = strchr( spec, '-' ))) error( "Invalid target specification '%s'\n", target );
+ *p++ = 0;
+ for (i = 0; i < sizeof(cpu_names)/sizeof(cpu_names[0]); i++)
+ {
+ if (!strcmp( cpu_names[i].name, spec ))
+ {
+ typelib_kind = cpu_names[i].kind;
+ free( spec );
+ return;
+ }
+ }
+ error( "Unrecognized CPU '%s'\n", spec );
+}
+
/* clean things up when aborting on a signal */
static void exit_on_signal( int sig )
{
@@ -481,6 +521,9 @@
do_win32 = 0;
do_win64 = 1;
break;
+ case 'b':
+ set_target( optarg );
+ break;
case 'c':
do_everything = 0;
do_client = 1;
@@ -508,6 +551,11 @@
case 'I':
wpp_add_include_path(optarg);
break;
+ case 'm':
+ if (!strcmp( optarg, "32" )) typelib_kind = SYS_WIN32;
+ else if (!strcmp( optarg, "64" )) typelib_kind = SYS_WIN64;
+ else error( "Invalid -m argument '%s'\n", optarg );
+ break;
case 'N':
no_preprocess = 1;
break;
diff --git a/tools/widl/widl.h b/tools/widl/widl.h
index d8c945f..e34e64b 100644
--- a/tools/widl/widl.h
+++ b/tools/widl/widl.h
@@ -34,7 +34,6 @@
#define DEBUGLEVEL_PPLEX 0x0010
#define DEBUGLEVEL_PPTRACE 0x0020
-extern int win32;
extern int pedantic;
extern int do_everything;
extern int do_header;
diff --git a/tools/widl/widl.man.in b/tools/widl/widl.man.in
index e275292..2757cdf 100644
--- a/tools/widl/widl.man.in
+++ b/tools/widl/widl.man.in
@@ -31,6 +31,10 @@
.B General options:
.IP "\fB-V\fR"
Print version number and exit.
+.IP "\fB-b \fIcpu-manufacturer[-kernel]-os\fR"
+Set the target architecture when cross-compiling. The target
+specification is in the standard autoconf format as returned by
+config.sub.
.PP
.B Header options:
.IP "\fB-h\fR"
@@ -47,6 +51,8 @@
.IP "\fB-T \fIfile\fR"
Define the name of the type library to be generated.
The default filename is \fIinfile\fR.tlb.
+.IP "\fB-m32, -m64\fR"
+Generate a Win32, respectively Win64, type library.
.PP
.B UUID file options:
.IP "\fB-u\fR"