This patch (sanity check please) fixes some portability issues when trying to build wine on cygwin. This by no means implies that wine builds on cygwin now, but this should get us a bit closer. Issues that would need to be taken care of are proper support in dlls/ntdll/signal_i386.c, accessor methods for wine_ldt_copy and such at least for win32, otherwise dllwrap complains about --enable-auto-import failing when trying to link ntdll.dll, a workaround for lack of the FIONREAD ioctl, and probably a million other things... Still, it's pretty cool that so much stuff compiles cleanly :) configure.ac: added some tests for header files defining symbols, specifically include/wine/port.h doesn't expect there to be definitions for getnetbyname()/getnetbyaddr() and the struct netent if those functions don't actually exist in the library. include/wine/port.h: check if getnetbyname()/getnetbyaddr() and struct netent are defined in <netdb.h> dlls/kernel/sync.c: check for FIONREAD existance include/msvcrt/sys/stat.h: include/msvcrt/sys/types.h: dlls/msvcrt/file.c: wrapped the _fstat and _stat function names and the _off_t typedef in the MSVCRT() prefix macro, because for whatever reason they get defined in the CYGWIN headers and there's no way to undefine them, does this make sense? dlls/ntdll/signal_i386.c: copied over the SIGCONTEXT struct from the linux section to a __CYGWIN__ section just to convince it to compile dlls/wineps/builtin.c: changed the inline round(float) function to Round(float) because it was conflicting with round() in math.h in CYGWIN library/Makefile.in: -lmsvcrt should only be used when building for mingw but not for cygwin so added a check tsx11/Makefile.in: call to dllwrap needs the X libraries to link properly License: X11, LGPL Changelog: misc fixes for building on CYGWIN
Index: configure.ac =================================================================== RCS file: /home/wine/wine/configure.ac,v retrieving revision 1.65 diff -u -w -r1.65 configure.ac --- configure.ac 30 Jul 2002 02:44:19 -0000 1.65 +++ configure.ac 30 Jul 2002 03:12:17 -0000 @@ -1084,6 +1084,113 @@ AC_DEFINE(HAVE_LINUX_22_JOYSTICK_API, 1, [Define if <linux/joystick.h> defines the Linux 2.2 joystick API]) fi +fi + +dnl **** check if various headers define various things **** + +if test "$ac_cv_header_netdb_h" = "yes" +then + AC_CACHE_CHECK([whether netdb.h defines struct netent], + wine_cv_netdb_h_defines_struct_netent, + AC_TRY_COMPILE([ + #include <netdb.h> + ], [ + struct netent foo; + ], + wine_cv_netdb_h_defines_struct_netent=yes, + wine_cv_netdb_h_defines_struct_netent=no + ) + ) + if test "$wine_cv_netdb_h_defines_struct_netent" = "yes" + then + AC_DEFINE(NETDB_H_DEFINES_STRUCT_NETENT, 1, + [Define if <netdb.h> defines struct netent]) + fi + + AC_CACHE_CHECK([whether netdb.h defines getnetbyaddr], + wine_cv_netdb_defines_getnetbyaddr, + AC_TRY_COMPILE([ + #include <netdb.h> + ], [ + getnetbyaddr(0,0); + ], + wine_cv_netdb_h_defines_getnetbyaddr=yes, + wine_cv_netdb_h_defines_getnetbyaddr=no + ) + ) + if test "$wine_cv_netdb_h_defines_getnetbyaddr" = "yes" + then + AC_DEFINE(NETDB_H_DEFINES_GETNETBYADDR, 1, + [Define if <netdb.h> defines getnetbyaddr()]) + fi + + AC_CACHE_CHECK([whether netdb.h defines getnetbyname], + wine_cv_netdb_h_defines_getnetbyname, + AC_TRY_COMPILE([ + #include <netdb.h> + ], [ + getnetbyname(""); + ], + wine_cv_netdb_h_defines_getnetbyname=yes, + wine_cv_netdb_h_defines_getnetbyname=no + ) + ) + if test "$wine_cv_netdb_h_defines_getnetbyname" = "yes" + then + AC_DEFINE(NETDB_H_DEFINES_GETNETBYNAME, 1, + [Define if <netdb.h> defines getnetbyname()]) + fi +fi + +AC_CACHE_CHECK([whether sys/types.h defines _off_t], + wine_cv_sys_types_h_defines__off_t, + AC_TRY_COMPILE([ + #include <sys/types.h> + ], [ + _off_t o; + ], + wine_cv_sys_types_h_defines__off_t=yes, + wine_cv_sys_types_h_defines__off_t=no + ) + ) +if test "$wine_cv_sys_types_h_defines__off_t" = "yes" +then +AC_DEFINE(SYS_TYPES_H_DEFINES__OFF_T, 1, + [Define if <sys/types.h> defines _off_t]) +fi + +AC_CACHE_CHECK([whether sys/stat.h defines _fstat], + wine_cv_sys_stat_h_defines__fstat, + AC_TRY_COMPILE([ + #include <sys/stat.h> + ], [ + _fstat s; + ], + wine_cv_sys_stat_h_defines__fstat=yes, + wine_cv_sys_stat_h_defines__fstat=no + ) + ) +if test "$wine_cv_sys_stat_h_defines__fstat" = "yes" +then +AC_DEFINE(SYS_STAT_H_DEFINES__FSTAT, 1, + [Define if <sys/stat.h> defines _fstat]) +fi + +AC_CACHE_CHECK([whether sys/stat.h defines _stat], + wine_cv_sys_stat_h_defines__stat, + AC_TRY_COMPILE([ + #include <sys/stat.h> + ], [ + _stat s; + ], + wine_cv_sys_stat_h_defines__stat=yes, + wine_cv_sys_stat_h_defines__stat=no + ) + ) +if test "$wine_cv_sys_stat_h_defines__stat" = "yes" +then +AC_DEFINE(SYS_STAT_H_DEFINES__STAT, 1, + [Define if <sys/stat.h> defines _stat]) fi dnl **** statfs checks **** Index: dlls/kernel/sync.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/sync.c,v retrieving revision 1.21 diff -u -w -r1.21 sync.c --- dlls/kernel/sync.c 25 Jul 2002 00:22:03 -0000 1.21 +++ dlls/kernel/sync.c 30 Jul 2002 03:12:19 -0000 @@ -536,6 +536,7 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer, LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage ) { +#ifdef FIONREAD int avail=0,fd; fd = FILE_GetUnixHandle(hPipe, GENERIC_READ); @@ -555,6 +556,7 @@ *lpcbAvail= avail; return TRUE; } +#endif /* defined(FIONREAD) */ SetLastError(ERROR_CALL_NOT_IMPLEMENTED); FIXME("function not implemented\n"); Index: dlls/msvcrt/file.c =================================================================== RCS file: /home/wine/wine/dlls/msvcrt/file.c,v retrieving revision 1.32 diff -u -w -r1.32 file.c --- dlls/msvcrt/file.c 19 Jul 2002 03:24:50 -0000 1.32 +++ dlls/msvcrt/file.c 30 Jul 2002 03:12:21 -0000 @@ -670,7 +670,7 @@ /********************************************************************* * _fstat (MSVCRT.@) */ -int _fstat(int fd, struct _stat* buf) +int MSVCRT(_fstat)(int fd, struct _stat* buf) { DWORD dw; BY_HANDLE_FILE_INFORMATION hfi; @@ -1135,7 +1135,7 @@ /********************************************************************* * _stat (MSVCRT.@) */ -int _stat(const char* path, struct _stat * buf) +int MSVCRT(_stat)(const char* path, struct _stat * buf) { DWORD dw; WIN32_FILE_ATTRIBUTE_DATA hfi; Index: dlls/ntdll/signal_i386.c =================================================================== RCS file: /home/wine/wine/dlls/ntdll/signal_i386.c,v retrieving revision 1.40 diff -u -w -r1.40 signal_i386.c --- dlls/ntdll/signal_i386.c 22 Jul 2002 20:47:11 -0000 1.40 +++ dlls/ntdll/signal_i386.c 30 Jul 2002 03:12:22 -0000 @@ -249,8 +249,44 @@ #endif /* __EMX__ */ +#ifdef __CYGWIN__ -#if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMX__) +/* FIXME: This section is just here so it can compile, it's most likely + * completely wrong. */ + +typedef struct +{ + unsigned short sc_gs, __gsh; + unsigned short sc_fs, __fsh; + unsigned short sc_es, __esh; + unsigned short sc_ds, __dsh; + unsigned long sc_edi; + unsigned long sc_esi; + unsigned long sc_ebp; + unsigned long sc_esp; + unsigned long sc_ebx; + unsigned long sc_edx; + unsigned long sc_ecx; + unsigned long sc_eax; + unsigned long sc_trapno; + unsigned long sc_err; + unsigned long sc_eip; + unsigned short sc_cs, __csh; + unsigned long sc_eflags; + unsigned long esp_at_signal; + unsigned short sc_ss, __ssh; + unsigned long i387; + unsigned long oldmask; + unsigned long cr2; +} SIGCONTEXT; + +#define HANDLER_DEF(name) void name( int __signal, SIGCONTEXT __context ) +#define HANDLER_CONTEXT (&__context) + +#endif /* __CYGWIN__ */ + +#if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) ||\ + defined(__OpenBSD__) || defined(__EMX__) || defined(__CYGWIN__) #define EAX_sig(context) ((context)->sc_eax) #define EBX_sig(context) ((context)->sc_ebx) Index: dlls/wineps/builtin.c =================================================================== RCS file: /home/wine/wine/dlls/wineps/builtin.c,v retrieving revision 1.1 diff -u -w -r1.1 builtin.c --- dlls/wineps/builtin.c 24 Jun 2002 23:44:18 -0000 1.1 +++ dlls/wineps/builtin.c 30 Jul 2002 03:12:23 -0000 @@ -49,7 +49,7 @@ * Scale builtin font to requested lfHeight * */ -inline static float round(float f) +inline static float Round(float f) { return (f > 0) ? (f + 0.5) : (f - 0.5); } @@ -73,15 +73,15 @@ (float)(wm->usWinAscent + wm->usWinDescent); } - font->size = (INT)round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm); + font->size = (INT)Round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm); - usUnitsPerEm = (USHORT)round((float)(wm->usUnitsPerEm) * font->fontinfo.Builtin.scale); - sAscender = (SHORT)round((float)(wm->sAscender) * font->fontinfo.Builtin.scale); - sDescender = (SHORT)round((float)(wm->sDescender) * font->fontinfo.Builtin.scale); - sLineGap = (SHORT)round((float)(wm->sLineGap) * font->fontinfo.Builtin.scale); - usWinAscent = (USHORT)round((float)(wm->usWinAscent) * font->fontinfo.Builtin.scale); - usWinDescent = (USHORT)round((float)(wm->usWinDescent) * font->fontinfo.Builtin.scale); - sAvgCharWidth = (SHORT)round((float)(wm->sAvgCharWidth) * font->fontinfo.Builtin.scale); + usUnitsPerEm = (USHORT)Round((float)(wm->usUnitsPerEm) * font->fontinfo.Builtin.scale); + sAscender = (SHORT)Round((float)(wm->sAscender) * font->fontinfo.Builtin.scale); + sDescender = (SHORT)Round((float)(wm->sDescender) * font->fontinfo.Builtin.scale); + sLineGap = (SHORT)Round((float)(wm->sLineGap) * font->fontinfo.Builtin.scale); + usWinAscent = (USHORT)Round((float)(wm->usWinAscent) * font->fontinfo.Builtin.scale); + usWinDescent = (USHORT)Round((float)(wm->usWinDescent) * font->fontinfo.Builtin.scale); + sAvgCharWidth = (SHORT)Round((float)(wm->sAvgCharWidth) * font->fontinfo.Builtin.scale); tm->tmAscent = (LONG)usWinAscent; tm->tmDescent = (LONG)usWinDescent; @@ -125,7 +125,7 @@ font->fontinfo.Builtin.scale *= (float)wm->usUnitsPerEm / 1000.0; - tm->tmMaxCharWidth = (LONG)round( + tm->tmMaxCharWidth = (LONG)Round( (afm->FontBBox.urx - afm->FontBBox.llx) * font->fontinfo.Builtin.scale); font->underlinePosition = afm->UnderlinePosition * font->fontinfo.Builtin.scale; Index: include/config.h.in =================================================================== RCS file: /home/wine/wine/include/config.h.in,v retrieving revision 1.125 diff -u -w -r1.125 config.h.in --- include/config.h.in 30 Jul 2002 02:44:20 -0000 1.125 +++ include/config.h.in 30 Jul 2002 03:12:24 -0000 @@ -635,6 +635,15 @@ /* Define if stdcall symbols need to be decorated */ #undef NEED_STDCALL_DECORATION +/* Define if <netdb.h> defines getnetbyaddr() */ +#undef NETDB_H_DEFINES_GETNETBYADDR + +/* Define if <netdb.h> defines getnetbyname() */ +#undef NETDB_H_DEFINES_GETNETBYNAME + +/* Define if <netdb.h> defines struct netent */ +#undef NETDB_H_DEFINES_STRUCT_NETENT + /* Define to disable all debug messages. */ #undef NO_DEBUG_MSGS @@ -699,6 +708,15 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS + +/* Define if <sys/stat.h> defines _fstat */ +#undef SYS_STAT_H_DEFINES__FSTAT + +/* Define if <sys/stat.h> defines _stat */ +#undef SYS_STAT_H_DEFINES__STAT + +/* Define if <sys/types.h> defines _off_t */ +#undef SYS_TYPES_H_DEFINES__OFF_T /* Define to 1 if the X Window System is missing or not being used. */ #undef X_DISPLAY_MISSING Index: include/msvcrt/sys/stat.h =================================================================== RCS file: /home/wine/wine/include/msvcrt/sys/stat.h,v retrieving revision 1.4 diff -u -w -r1.4 stat.h --- include/msvcrt/sys/stat.h 27 Apr 2002 21:14:50 -0000 1.4 +++ include/msvcrt/sys/stat.h 30 Jul 2002 03:12:24 -0000 @@ -34,7 +34,7 @@ short st_uid; short st_gid; _dev_t st_rdev; - _off_t st_size; + MSVCRT(_off_t) st_size; MSVCRT(time_t) st_atime; MSVCRT(time_t) st_mtime; MSVCRT(time_t) st_ctime; @@ -59,9 +59,9 @@ extern "C" { #endif -int _fstat(int,struct _stat*); +int MSVCRT(_fstat)(int,struct _stat*); int _fstati64(int,struct _stati64*); -int _stat(const char*,struct _stat*); +int MSVCRT(_stat)(const char*,struct _stat*); int _stati64(const char*,struct _stati64*); int _wstat(const WCHAR*,struct _stat*); @@ -81,8 +81,8 @@ #define S_IWRITE _S_IWRITE #define S_IEXEC _S_IEXEC -#define fstat _fstat -#define stat _stat +#define fstat MSVCRT(_fstat) +#define stat MSVCRT(_stat) #endif /* USE_MSVCRT_PREFIX */ #endif /* __WINE_SYS_STAT_H */ Index: include/msvcrt/sys/types.h =================================================================== RCS file: /home/wine/wine/include/msvcrt/sys/types.h,v retrieving revision 1.4 diff -u -w -r1.4 types.h --- include/msvcrt/sys/types.h 10 Mar 2002 00:02:38 -0000 1.4 +++ include/msvcrt/sys/types.h 30 Jul 2002 03:12:24 -0000 @@ -31,7 +31,7 @@ typedef unsigned int _dev_t; typedef unsigned short _ino_t; -typedef int _off_t; +typedef int MSVCRT(_off_t); typedef long MSVCRT(time_t); Index: include/wine/port.h =================================================================== RCS file: /home/wine/wine/include/wine/port.h,v retrieving revision 1.28 diff -u -w -r1.28 port.h --- include/wine/port.h 29 Jul 2002 23:55:40 -0000 1.28 +++ include/wine/port.h 30 Jul 2002 03:12:25 -0000 @@ -61,14 +61,16 @@ typedef int ssize_t; #endif -#if !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) +#if !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) &&\ + !defined(NETDB_H_DEFINES_STRUCT_NETENT) struct netent { char *n_name; char **n_aliases; int n_addrtype; unsigned long n_net; }; -#endif /* !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) */ +#endif /* !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) && + !defined(NETDB_H_DEFINES_STRUCT_NETENT) */ #if !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER) struct protoent { @@ -186,13 +188,13 @@ int clone(int (*fn)(void *arg), void *stack, int flags, void *arg); #endif /* !defined(HAVE_CLONE) && defined(linux) */ -#ifndef HAVE_GETNETBYADDR +#if !defined(HAVE_GETNETBYADDR) && !defined(NETDB_H_DEFINES_GETNETBYADDR) struct netent *getnetbyaddr(unsigned long net, int type); -#endif /* defined(HAVE_GETNETBYNAME) */ +#endif /* !defined(HAVE_GETNETBYNAME) && !defined(NETDB_H_DEFINES_GETNETBYADDR) */ -#ifndef HAVE_GETNETBYNAME +#if !defined(HAVE_GETNETBYNAME) && !defined(NETDB_H_DEFINES_GETNETBYNAME) struct netent *getnetbyname(const char *name); -#endif /* defined(HAVE_GETNETBYNAME) */ +#endif /* !defined(HAVE_GETNETBYNAME) && !defined(NETDB_H_DEFINES_GETNETBYNAME) */ #ifndef HAVE_GETPAGESIZE size_t getpagesize(void); Index: library/Makefile.in =================================================================== RCS file: /home/wine/wine/library/Makefile.in,v retrieving revision 1.15 diff -u -w -r1.15 Makefile.in --- library/Makefile.in 20 Jun 2002 23:21:27 -0000 1.15 +++ library/Makefile.in 30 Jul 2002 03:12:25 -0000 @@ -33,7 +33,11 @@ $(RANLIB) $@ libwine.dll: $(OBJS) - $(DLLWRAP) $(DLLWRAPFLAGS) --export-all --implib libwine.a -o libwine.dll $(OBJS) -lmsvcrt + if echo $(CFLAGS) | grep -i mingw > /dev/null 2>&1; then \ + $(DLLWRAP) $(DLLWRAPFLAGS) --export-all --implib libwine.a -o libwine.dll $(OBJS) -lmsvcrt; \ + else \ + $(DLLWRAP) $(DLLWRAPFLAGS) --export-all --implib libwine.a -o libwine.dll $(OBJS); \ + fi .PHONY: install_so install_a install_dll Index: tsx11/Makefile.in =================================================================== RCS file: /home/wine/wine/tsx11/Makefile.in,v retrieving revision 1.14 diff -u -w -r1.14 Makefile.in --- tsx11/Makefile.in 14 Jun 2002 23:48:28 -0000 1.14 +++ tsx11/Makefile.in 30 Jul 2002 03:12:26 -0000 @@ -37,7 +37,7 @@ $(RANLIB) $@ libwine_tsx11.dll: $(OBJS) - $(DLLWRAP) $(DLLWRAPFLAGS) --export-all --implib libwine_tsx11.a -o libwine_tsx11.dll $(OBJS) + $(DLLWRAP) $(DLLWRAPFLAGS) --export-all --implib libwine_tsx11.a -o libwine_tsx11.dll $(OBJS) $(EXTRALIBS) .PHONY: install_so install_a