Commit f41c2b21 authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Instrument winegcc to use the compilers and options detected at

configure time. Add support for parsing/formatting a string array from/to a char string. Add option to disable short wchar support in winegcc.
parent 4d16fe39
...@@ -35,7 +35,6 @@ LIBEXT = @LIBEXT@ ...@@ -35,7 +35,6 @@ LIBEXT = @LIBEXT@
DLLEXT = @DLLEXT@ DLLEXT = @DLLEXT@
IMPLIBEXT = @IMPLIBEXT@ IMPLIBEXT = @IMPLIBEXT@
LDSHARED = @LDSHARED@ LDSHARED = @LDSHARED@
LDDLL = @LDDLL@
DLLTOOL = @DLLTOOL@ DLLTOOL = @DLLTOOL@
DLLWRAP = @DLLWRAP@ DLLWRAP = @DLLWRAP@
AR = @AR@ rc AR = @AR@ rc
...@@ -53,6 +52,8 @@ RM = rm -f ...@@ -53,6 +52,8 @@ RM = rm -f
MV = mv MV = mv
LINT = @LINT@ LINT = @LINT@
LINTFLAGS = @LINTFLAGS@ LINTFLAGS = @LINTFLAGS@
LDDLLFLAGS = @LDDLLFLAGS@
LDDLL = $(CC) $(LDDLLFLAGS)
INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL) INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
EXTRACFLAGS = @EXTRACFLAGS@ EXTRACFLAGS = @EXTRACFLAGS@
ALLCFLAGS = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) ALLCFLAGS = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS)
......
...@@ -41,7 +41,9 @@ dnl **** Check for some programs **** ...@@ -41,7 +41,9 @@ dnl **** Check for some programs ****
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_PROG_CC AC_PROG_CC
AC_PROG_CPP AC_PROG_CXX
dnl We can't use AC_PROG_CPP, it uses by default $(CC) -E
AC_CHECK_PROG(CPP, "cpp", "cpp")
AC_CACHE_CHECK([for the directory containing the Wine tools], wine_cv_toolsdir, AC_CACHE_CHECK([for the directory containing the Wine tools], wine_cv_toolsdir,
[if test -z "$with_wine_tools"; then [if test -z "$with_wine_tools"; then
...@@ -716,6 +718,15 @@ int main(void) { ...@@ -716,6 +718,15 @@ int main(void) {
EXTRACFLAGS="$EXTRACFLAGS -fno-strength-reduce" EXTRACFLAGS="$EXTRACFLAGS -fno-strength-reduce"
fi fi
dnl Check for -fshort-wchar
AC_CACHE_CHECK([for gcc -fshort-wchar support], ac_cv_c_gcc_fshort_wchar,
[WINE_TRY_CFLAGS([-fshort-wchar],
ac_cv_c_gcc_fshort_wchar="yes",ac_cv_c_gcc_fshort_wchar="no")])
if test "$ac_cv_c_gcc_fshort_wchar" = "yes"
then
AC_DEFINE(CC_FLAG_SHORT_WCHAR, "-fshort-wchar", [Specifies the compiler flag that forces a short wchar_t])
fi
dnl Check for -mpreferred-stack-boundary dnl Check for -mpreferred-stack-boundary
AC_CACHE_CHECK([for gcc -mpreferred-stack-boundary=2 support], ac_cv_c_gcc_stack_boundary, AC_CACHE_CHECK([for gcc -mpreferred-stack-boundary=2 support], ac_cv_c_gcc_stack_boundary,
[WINE_TRY_CFLAGS([-mpreferred-stack-boundary=2], [WINE_TRY_CFLAGS([-mpreferred-stack-boundary=2],
...@@ -822,7 +833,7 @@ AC_SUBST(DLLEXT,"") ...@@ -822,7 +833,7 @@ AC_SUBST(DLLEXT,"")
AC_SUBST(DLLFLAGS,"-D_REENTRANT") AC_SUBST(DLLFLAGS,"-D_REENTRANT")
AC_SUBST(DLLIBS,"") AC_SUBST(DLLIBS,"")
AC_SUBST(LDSHARED,"") AC_SUBST(LDSHARED,"")
AC_SUBST(LDDLL,"") AC_SUBST(LDDLLFLAGS,"")
AC_SUBST(LIBEXT,"so") AC_SUBST(LIBEXT,"so")
AC_SUBST(IMPLIBEXT,"def") AC_SUBST(IMPLIBEXT,"def")
...@@ -857,13 +868,13 @@ case $host_os in ...@@ -857,13 +868,13 @@ case $host_os in
if test "$ac_cv_c_dll_gnuelf" = "yes" if test "$ac_cv_c_dll_gnuelf" = "yes"
then then
LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%)" LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%)"
LDDLL="\$(CC) -shared -Wl,-Bsymbolic" LDDLLFLAGS="-shared -Wl,-Bsymbolic"
AC_CACHE_CHECK([whether the linker accepts -z defs], ac_cv_c_dll_zdefs, AC_CACHE_CHECK([whether the linker accepts -z defs], ac_cv_c_dll_zdefs,
[WINE_TRY_CFLAGS([-fPIC -shared -Wl,-Bsymbolic,-z,defs], [WINE_TRY_CFLAGS([-fPIC -shared -Wl,-Bsymbolic,-z,defs],
ac_cv_c_dll_zdefs="yes",ac_cv_c_dll_zdefs="no")]) ac_cv_c_dll_zdefs="yes",ac_cv_c_dll_zdefs="no")])
if test "$ac_cv_c_dll_zdefs" = "yes" if test "$ac_cv_c_dll_zdefs" = "yes"
then then
LDDLL="$LDDLL,-z,defs" LDDLLFLAGS="$LDDLLFLAGS,-z,defs"
fi fi
AC_CACHE_CHECK([whether the linker accepts -init and -fini], ac_cv_c_dll_init_fini, AC_CACHE_CHECK([whether the linker accepts -init and -fini], ac_cv_c_dll_init_fini,
...@@ -871,8 +882,7 @@ case $host_os in ...@@ -871,8 +882,7 @@ case $host_os in
ac_cv_c_dll_init_fini="yes",ac_cv_c_dll_init_fini="no")]) ac_cv_c_dll_init_fini="yes",ac_cv_c_dll_init_fini="no")])
if test "$ac_cv_c_dll_init_fini" = "yes" if test "$ac_cv_c_dll_init_fini" = "yes"
then then
AC_DEFINE(HAVE_LINKER_INIT_FINI,1,[Define if the linker supports renaming the init and fini functions]) LDDLLFLAGS="$LDDLLFLAGS,-init,__wine_spec_init,-fini,__wine_spec_fini"
LDDLL="$LDDLL,-init,__wine_spec_init,-fini,__wine_spec_fini"
fi fi
AC_CACHE_CHECK([whether the linker accepts version scripts], ac_cv_c_ld_version_scripts, AC_CACHE_CHECK([whether the linker accepts version scripts], ac_cv_c_ld_version_scripts,
...@@ -916,7 +926,7 @@ case $host_os in ...@@ -916,7 +926,7 @@ case $host_os in
if test "$ac_cv_c_dll_unixware" = "yes" if test "$ac_cv_c_dll_unixware" = "yes"
then then
LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,%)" LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,%)"
LDDLL="\$(CC) -Wl,-G,-B,symbolic" LDDLLFLAGS="-Wl,-G,-B,symbolic"
else else
AC_CACHE_CHECK(whether we can build a Mach-O (Mac OS X/Darwin) dll, ac_cv_c_dll_macho, AC_CACHE_CHECK(whether we can build a Mach-O (Mac OS X/Darwin) dll, ac_cv_c_dll_macho,
...@@ -924,7 +934,7 @@ case $host_os in ...@@ -924,7 +934,7 @@ case $host_os in
if test "$ac_cv_c_dll_macho" = "yes" if test "$ac_cv_c_dll_macho" = "yes"
then then
LIBEXT="dylib" LIBEXT="dylib"
LDDLL="\$(CC) -bundle -flat_namespace -undefined suppress" LDDLLFLAGS="-bundle -flat_namespace -undefined suppress"
LDSHARED="\$(CC) -dynamiclib" LDSHARED="\$(CC) -dynamiclib"
CFLAGS="$CFLAGS -ffixed-r13 -no-cpp-precomp" CFLAGS="$CFLAGS -ffixed-r13 -no-cpp-precomp"
fi fi
...@@ -1226,8 +1236,7 @@ dnl **** Check for types **** ...@@ -1226,8 +1236,7 @@ dnl **** Check for types ****
AC_C_CONST AC_C_CONST
AC_C_INLINE AC_C_INLINE
AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t]) AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t, long long])
AC_CHECK_SIZEOF(long long,0)
AC_CACHE_CHECK([whether linux/input.h is for real], AC_CACHE_CHECK([whether linux/input.h is for real],
wine_cv_linux_input_h, wine_cv_linux_input_h,
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
#define __WINE_CONFIG_H #define __WINE_CONFIG_H
/* Specifies the compiler flag that forces a short wchar_t */
#undef CC_FLAG_SHORT_WCHAR
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems. systems. This function is required for `alloca.c' support on those systems.
*/ */
...@@ -284,9 +287,6 @@ ...@@ -284,9 +287,6 @@
/* Define if you have the X Shm extension */ /* Define if you have the X Shm extension */
#undef HAVE_LIBXXSHM #undef HAVE_LIBXXSHM
/* Define if the linker supports renaming the init and fini functions */
#undef HAVE_LINKER_INIT_FINI
/* Define to 1 if you have the <link.h> header file. */ /* Define to 1 if you have the <link.h> header file. */
#undef HAVE_LINK_H #undef HAVE_LINK_H
...@@ -326,6 +326,9 @@ ...@@ -326,6 +326,9 @@
/* Define to 1 if you have the <linux/ucdrom.h> header file. */ /* Define to 1 if you have the <linux/ucdrom.h> header file. */
#undef HAVE_LINUX_UCDROM_H #undef HAVE_LINUX_UCDROM_H
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
/* Define to 1 if you have the `lseek64' function. */ /* Define to 1 if you have the `lseek64' function. */
#undef HAVE_LSEEK64 #undef HAVE_LSEEK64
...@@ -815,9 +818,6 @@ ...@@ -815,9 +818,6 @@
/* Define to the version of this package. */ /* Define to the version of this package. */
#undef PACKAGE_VERSION #undef PACKAGE_VERSION
/* The size of a `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG
/* Define to the soname of the libcrypto library. */ /* Define to the soname of the libcrypto library. */
#undef SONAME_LIBCRYPTO #undef SONAME_LIBCRYPTO
......
DEFS = -DINCLUDEDIR="\"$(includedir)\"" -DDLLDIR="\"$(dlldir)\"" -DLIBDIR="\"$(libdir)\"" DEFS = \
-DINCLUDEDIR="\"$(includedir)\"" \
-DDLLDIR="\"$(dlldir)\"" \
-DLIBDIR="\"$(libdir)\"" \
-DDLLFLAGS="\"@DLLFLAGS@\"" \
-DLDDLLFLAGS="\"$(LDDLLFLAGS)\"" \
-DCC="\"$(CC)\"" \
-DCPP="\"$(CPP)\"" \
-DCXX="\"$(CXX)\""
TOPSRCDIR = @top_srcdir@ TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../.. TOPOBJDIR = ../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
......
...@@ -118,6 +118,14 @@ void strarray_add(strarray* arr, const char* str) ...@@ -118,6 +118,14 @@ void strarray_add(strarray* arr, const char* str)
arr->base[arr->size++] = str; arr->base[arr->size++] = str;
} }
void strarray_addall(strarray* arr, const strarray* from)
{
int i;
for (i = 0; i < from->size; i++)
strarray_add(arr, from->base[i]);
}
strarray* strarray_dup(const strarray* arr) strarray* strarray_dup(const strarray* arr)
{ {
strarray* dup = strarray_alloc(); strarray* dup = strarray_alloc();
...@@ -129,6 +137,35 @@ strarray* strarray_dup(const strarray* arr) ...@@ -129,6 +137,35 @@ strarray* strarray_dup(const strarray* arr)
return dup; return dup;
} }
strarray* strarray_fromstring(const char* str, const char* delim)
{
strarray* arr = strarray_alloc();
char* buf = strdup(str);
const char* tok;
for(tok = strtok(buf, delim); tok; tok = strtok(0, delim))
strarray_add(arr, strdup(tok));
free(buf);
return arr;
}
char* strarray_tostring(const strarray* arr, const char* sep)
{
char *str, *newstr;
int i;
str = strmake("%s", arr->base[0]);
for (i = 1; i < arr->size; i++)
{
newstr = strmake("%s%s%s", str, sep, arr->base[i]);
free(str);
str = newstr;
}
return str;
}
char* get_basename(const char* file) char* get_basename(const char* file)
{ {
const char* name; const char* name;
......
...@@ -21,7 +21,17 @@ ...@@ -21,7 +21,17 @@
*/ */
void error(const char* s, ...); #ifndef DECLSPEC_NORETURN
# if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
# define DECLSPEC_NORETURN __declspec(noreturn)
# elif defined(__GNUC__)
# define DECLSPEC_NORETURN __attribute__((noreturn))
# else
# define DECLSPEC_NORETURN
# endif
#endif
void error(const char* s, ...) DECLSPEC_NORETURN;
void* xmalloc(size_t size); void* xmalloc(size_t size);
void* xrealloc(void* p, size_t size); void* xrealloc(void* p, size_t size);
...@@ -38,6 +48,9 @@ strarray* strarray_alloc(void); ...@@ -38,6 +48,9 @@ strarray* strarray_alloc(void);
strarray* strarray_dup(const strarray* arr); strarray* strarray_dup(const strarray* arr);
void strarray_free(strarray* arr); void strarray_free(strarray* arr);
void strarray_add(strarray* arr, const char* str); void strarray_add(strarray* arr, const char* str);
void strarray_addall(strarray* arr, const strarray* from);
strarray* strarray_fromstring(const char* str, const char* delim);
char* strarray_tostring(const strarray* arr, const char* sep);
typedef enum { typedef enum {
file_na, file_other, file_obj, file_res, file_na, file_other, file_obj, file_res,
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* all options for gcc start with '-' and are for the most part * all options for gcc start with '-' and are for the most part
* single options (no parameters as separate argument). * single options (no parameters as separate argument).
* There are of course exceptions to this rule, so here is an * There are of course exceptions to this rule, so here is an
* exaustive list of options that do take parameters (potentially) * exhaustive list of options that do take parameters (potentially)
* as a separate argument: * as a separate argument:
* *
* Compiler: * Compiler:
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
* *
* NOTES * NOTES
* There is -G option for compatibility with System V that * There is -G option for compatibility with System V that
* takes no paramters. This makes "-G num" parsing ambiguous. * takes no parameters. This makes "-G num" parsing ambiguous.
* This option is synonimous to -shared, and as such we will * This option is synonymous to -shared, and as such we will
* not support it for now. * not support it for now.
* *
* Special interest options * Special interest options
...@@ -80,8 +80,8 @@ ...@@ -80,8 +80,8 @@
* Target Options * Target Options
* -b machine -V version * -b machine -V version
* *
* Please note tehat the Target Options are relevant to everything: * Please note that the Target Options are relevant to everything:
* compiler, linker, asssembler, preprocessor. * compiler, linker, assembler, preprocessor.
* *
*/ */
...@@ -161,6 +161,7 @@ struct options ...@@ -161,6 +161,7 @@ struct options
int nostdinc; int nostdinc;
int nostdlib; int nostdlib;
int nodefaultlibs; int nodefaultlibs;
int noshortwchar;
int gui_app; int gui_app;
int compile_only; int compile_only;
const char* output_name; const char* output_name;
...@@ -199,32 +200,47 @@ char* get_temp_file(const char* prefix, const char* suffix) ...@@ -199,32 +200,47 @@ char* get_temp_file(const char* prefix, const char* suffix)
return tmp; return tmp;
} }
static const char* get_translator(struct options* args) static const char* get_translator(struct options* opts)
{ {
const char* cc = proc_cc; /* keep compiler happy */ switch(opts->processor)
switch(args->processor)
{ {
case proc_pp: cc = "cpp"; break; case proc_pp: return CPP;
case proc_cc: cc = "gcc"; break; case proc_cc: return CC;
case proc_cpp: cc = "g++"; break; case proc_cpp: return CXX;
default: error("Unknown processor");
} }
error("Unknown processor");
return cc;
} }
static void compile(struct options* opts) static void compile(struct options* opts)
{ {
strarray *comp_args = strarray_alloc(); strarray *comp_args = strarray_alloc();
int j; int j, gcc_defs = 0;
switch(opts->processor)
{
case proc_pp: gcc_defs = 1; break;
#ifdef __GNUC__
/* Note: if the C compiler is gcc we assume the C++ compiler is too */
/* mixing different C and C++ compilers isn't supported in configure anyway */
case proc_cc: gcc_defs = 1; break;
case proc_cpp: gcc_defs = 1; break;
#else
case proc_cc: gcc_defs = 0; break;
case proc_cpp: gcc_defs = 0; break;
#endif
}
strarray_add(comp_args, get_translator(opts)); strarray_add(comp_args, get_translator(opts));
if (opts->processor != proc_pp) if (opts->processor != proc_pp)
{ {
strarray_add(comp_args, "-fshort-wchar"); #ifdef CC_FLAG_SHORT_WCHAR
strarray_add(comp_args, "-fPIC"); if (!opts->noshortwchar)
{
strarray_add(comp_args, CC_FLAG_SHORT_WCHAR);
strarray_add(comp_args, "-DWINE_UNICODE_NATIVE");
}
#endif
strarray_addall(comp_args, strarray_fromstring(DLLFLAGS, " "));
} }
if (!opts->nostdinc) if (!opts->nostdinc)
{ {
...@@ -242,6 +258,8 @@ static void compile(struct options* opts) ...@@ -242,6 +258,8 @@ static void compile(struct options* opts)
strarray_add(comp_args, "-D__WINNT"); strarray_add(comp_args, "-D__WINNT");
strarray_add(comp_args, "-D__WINNT__"); strarray_add(comp_args, "-D__WINNT__");
if (gcc_defs)
{
strarray_add(comp_args, "-D__stdcall=__attribute__((__stdcall__))"); strarray_add(comp_args, "-D__stdcall=__attribute__((__stdcall__))");
strarray_add(comp_args, "-D__cdecl=__attribute__((__cdecl__))"); strarray_add(comp_args, "-D__cdecl=__attribute__((__cdecl__))");
strarray_add(comp_args, "-D__fastcall=__attribute__((__fastcall__))"); strarray_add(comp_args, "-D__fastcall=__attribute__((__fastcall__))");
...@@ -261,14 +279,17 @@ static void compile(struct options* opts) ...@@ -261,14 +279,17 @@ static void compile(struct options* opts)
strarray_add(comp_args, "-D__declspec_novtable=__attribute__(())"); /* ignore it */ strarray_add(comp_args, "-D__declspec_novtable=__attribute__(())"); /* ignore it */
strarray_add(comp_args, "-D__declspec_selectany=__attribute__((weak))"); strarray_add(comp_args, "-D__declspec_selectany=__attribute__((weak))");
strarray_add(comp_args, "-D__declspec_thread=__thread"); strarray_add(comp_args, "-D__declspec_thread=__thread");
}
/* Wine specific defines */ /* Wine specific defines */
strarray_add(comp_args, "-D__WINE__"); strarray_add(comp_args, "-D__WINE__");
strarray_add(comp_args, "-DWINE_UNICODE_NATIVE");
strarray_add(comp_args, "-D__int8=char"); strarray_add(comp_args, "-D__int8=char");
strarray_add(comp_args, "-D__int16=short"); strarray_add(comp_args, "-D__int16=short");
/* FIXME: what about 64-bit platforms? */
strarray_add(comp_args, "-D__int32=int"); strarray_add(comp_args, "-D__int32=int");
#ifdef HAVE_LONG_LONG
strarray_add(comp_args, "-D__int64=long long"); strarray_add(comp_args, "-D__int64=long long");
#endif
/* options we handle explicitly */ /* options we handle explicitly */
if (opts->compile_only) if (opts->compile_only)
...@@ -439,8 +460,8 @@ static void build(struct options* opts) ...@@ -439,8 +460,8 @@ static void build(struct options* opts)
/* compile the .spec.c file into a .spec.o file */ /* compile the .spec.c file into a .spec.o file */
comp_args = strarray_alloc(); comp_args = strarray_alloc();
spec_o_name = get_temp_file(base_name, ".spec.o"); spec_o_name = get_temp_file(base_name, ".spec.o");
strarray_add(comp_args, "gcc"); strarray_add(comp_args, CC);
strarray_add(comp_args, "-fPIC"); strarray_addall(comp_args, strarray_fromstring(DLLFLAGS, " "));
strarray_add(comp_args, "-o"); strarray_add(comp_args, "-o");
strarray_add(comp_args, spec_o_name); strarray_add(comp_args, spec_o_name);
strarray_add(comp_args, "-c"); strarray_add(comp_args, "-c");
...@@ -451,12 +472,7 @@ static void build(struct options* opts) ...@@ -451,12 +472,7 @@ static void build(struct options* opts)
/* link everything together now */ /* link everything together now */
link_args = strarray_alloc(); link_args = strarray_alloc();
strarray_add(link_args, get_translator(opts)); strarray_add(link_args, get_translator(opts));
strarray_add(link_args, "-shared"); strarray_addall(link_args, strarray_fromstring(LDDLLFLAGS, " "));
#ifdef HAVE_LINKER_INIT_FINI
strarray_add(link_args, "-Wl,-Bsymbolic,-z,defs,-init,__wine_spec_init,-fini,__wine_spec_fini");
#else
strarray_add(link_args, "-Wl,-Bsymbolic,-z,defs");
#endif
strarray_add(link_args, "-o"); strarray_add(link_args, "-o");
strarray_add(link_args, strmake("%s.exe.so", base_file)); strarray_add(link_args, strmake("%s.exe.so", base_file));
...@@ -679,6 +695,10 @@ int main(int argc, char **argv) ...@@ -679,6 +695,10 @@ int main(int argc, char **argv)
case 'E': /* preprocess only */ case 'E': /* preprocess only */
if (argv[i][2] == 0) linking = 0; if (argv[i][2] == 0) linking = 0;
break; break;
case 'f':
if (strcmp("-fno-short-wchar", argv[i]) == 0)
opts.noshortwchar = 1;
break;
case 'l': case 'l':
strarray_add(opts.lib_names, option_arg); strarray_add(opts.lib_names, option_arg);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment