From ce37b73fc4f3fd2976b4a040e6429e8cae81f3bd Mon Sep 17 00:00:00 2001 From: Eric J Korpela Date: Fri, 20 Jun 2014 07:48:31 -0700 Subject: [PATCH] Fixed avx detection on GCC windows compiles More windows library detection added to configure.ac Additional cross compile fixes for libboinc and client. --- client/Makefile.am | 14 +- client/hostinfo_win.cpp | 121 +++++++++--- client/time_stats.cpp | 2 +- configure.ac | 253 ++++++++++++++++++++----- lib/app_ipc.cpp | 2 +- lib/boinc_win.h | 18 +- xcompile/xcompile.MinGW32_on_cygwin.sh | 92 ++++++--- 7 files changed, 391 insertions(+), 111 deletions(-) diff --git a/client/Makefile.am b/client/Makefile.am index 3b5e690c629..e86dc760a87 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -126,16 +126,16 @@ switcher_LDADD = $(LIBBOINC) ## since we are using libtool we need some magic to get boinc and boinc_client ## to both be installed properly. The next two rules do that... -all-local: boinc +all-local: boinc$(EXEEXT) -boinc: boinc_client - rm -f boinc .libs/boinc - $(LN) boinc_client boinc - if test -f .libs/boinc_client ; then $(LN) .libs/boinc_client .libs/boinc ; fi +boinc$(EXEEXT): boinc_client$(EXEEXT) + rm -f boinc$(EXEEXT) .libs/boinc$(EXEEXT) + $(LN) boinc_client$(EXEEXT) boinc$(EXEEXT) + if test -f .libs/boinc_client$(EXEEXT) ; then $(LN) .libs/boinc_client$(EXEEXT) .libs/boinc$(EXEEXT) ; fi install-exec-hook: - rm -f $(DESTDIR)$(exec_prefix)/bin/boinc - $(LN) $(DESTDIR)$(exec_prefix)/bin/boinc_client $(DESTDIR)$(exec_prefix)/bin/boinc + rm -f $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT) + $(LN) $(DESTDIR)$(exec_prefix)/bin/boinc_client$(EXEEXT) $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT) ## these source files need to be specified because no rule uses them. diff --git a/client/hostinfo_win.cpp b/client/hostinfo_win.cpp index 195e9634ee8..21579f8c091 100644 --- a/client/hostinfo_win.cpp +++ b/client/hostinfo_win.cpp @@ -23,7 +23,7 @@ #define snprintf _snprintf #endif -#ifndef __CYGWIN__ +#ifdef HAVE_INTRIN_H #include #endif @@ -140,17 +140,94 @@ #define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E #endif +/* HAVE_DECL__XGETBV should be set by autoconf or in boinc_win.h */ +#if !defined(HAVE_DECL__XGETBV) || !HAVE_DECL__XGETBV +#if HAVE_DECL_XGETBV +#define _xgetbv(x) xgetbv(x) +#elif HAVE_DECL___XGETBV +#define _xgetbv(x) __xgetbv(x) +#else +static unsigned long long _xgetbv(unsigned int index){ + unsigned int A=0, D=0; + +#ifdef __GNUC__ + #ifdef ASM_SUPPORTS_XGETBV + __asm__ __volatile__("xgetbv" : "=a"(A), "=d"(D) : "c"(index)); + #else + __asm__ __volatile__(".byte 0x0f, 0x01, 0xd0": "=a"(A), "=d"(D) : "c"(index)); + #endif +#elif defined(_MSC_VER) + #ifdef _M_IX86 + __asm { + mov ecx,index + __emit 00fh + __emit 001h + __emit 0d0h + mov D,edx + mov A,eax + } + #elif defined(_M_AMD64) + // damn Microsoft for not having inline assembler in 64-bit code + // so this is in an NASM compiled library + return asm_xgetbv(index); + #endif +#endif + return ((unsigned long long)D << 32) | A; +} +#endif +#endif + +/* HAVE_DECL___CPUID should be set by autoconf or in boinc_win.h */ +#if !defined(HAVE_DECL___CPUID) || !HAVE_DECL___CPUID +#if HAVE_DECL_CPUID +#define __cpuid(x,y) cpuid(x,y) +#elif HAVE_DECL__CPUID +#define __cpuid(x,y) _cpuid(x,y) +#else +static void __cpuid(unsigned int cpuinfo[4], unsigned int type) { +#ifdef __GNUC__ + #ifdef ASM_SUPPORTS_CPUID + __asm__ __volatile__("cpuid" + : "=a" (cpuinfo[0]), "=b" (cpuinfo[1]), + "=c" (cpuinfo[2]), "=d" (cpuinfo[3]) + : "a" (type)); + #else + __asm__ __volatile__(".byte 0x0f, 0xa2" + : "=a" (cpuinfo[0]), "=b" (cpuinfo[1]), + "=c" (cpuinfo[2]), "=d" (cpuinfo[3]) + : "a" (type)); + #endif +#elif defined(_MSC_VER) + #ifdef _M_IX86 + __asm { + mov eax,type + __emit 00fh + __emit 0a2h + mov cpuinfo[0],eax + mov cpuinfo[1],ebx + mov cpuinfo[2],ecx + mov cpuinfo[3],edx + } + #elif defined(_M_AMD64) + // damn Microsoft for not having inline assembler in 64-bit code + // so this is in an NASM compiled library + asm_cpuid(cpuinfo,type); + #endif +#endif +} +#endif +#endif // Returns the number of seconds difference from UTC // -int get_timezone(int& timezone) { +int get_timezone(int& tz) { TIME_ZONE_INFORMATION tzi; memset(&tzi, 0, sizeof(TIME_ZONE_INFORMATION)); DWORD result = GetTimeZoneInformation(&tzi); if (result == TIME_ZONE_ID_DAYLIGHT) { - timezone = -(tzi.Bias + tzi.DaylightBias) * 60; + tz = -(tzi.Bias + tzi.DaylightBias) * 60; } else { - timezone = -(tzi.Bias + tzi.StandardBias) * 60; + tz = -(tzi.Bias + tzi.StandardBias) * 60; } return 0; } @@ -648,13 +725,12 @@ int get_os_information( // int get_cpuid(unsigned int info_type, unsigned int& a, unsigned int& b, unsigned int& c, unsigned int& d) { -#ifdef _MSC_VER - // Microsoft compiler - use intrinsic int retval = 1; - int CPUInfo[4] = {0,0,0,0}; - + unsigned int CPUInfo[4] = {0,0,0,0}; +#ifdef _MSC_VER __try { +#endif __cpuid(CPUInfo, info_type); a = CPUInfo[0]; @@ -663,19 +739,11 @@ int get_cpuid(unsigned int info_type, unsigned int& a, unsigned int& b, unsigned d = CPUInfo[3]; retval = 0; +#ifdef _MSC_VER } __except (EXCEPTION_EXECUTE_HANDLER) {} - return retval; - -#elif defined(__GNUC__) - - // GCC compiler - __asm__ __volatile__ ("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (info_type)); - return 0; - -#else - return 1; #endif + return retval; } @@ -785,7 +853,9 @@ int get_processor_cache(int& cache) { return 0; } - +#ifndef _XCR_XFEATURE_ENABLED_MASK +#define _XCR_XFEATURE_ENABLED_MASK 0 +#endif // Returns true if the AVX instruction set is supported with the current // combination of OS and CPU. // see: http://insufficientlycomplicated.wordpress.com/2011/11/07/detecting-intel-advanced-vector-extensions-avx-in-visual-studio/ @@ -794,9 +864,7 @@ bool is_avx_supported() { bool supported = false; - // If Visual Studio 2010 SP1 or later -#if (_MSC_FULL_VER >= 160040219) - // Checking for AVX requires 3 things: + // Checking for AVX on Windows requires 3 things: // 1) CPUID indicates that the OS uses XSAVE and XRSTORE // instructions (allowing saving YMM registers on context // switch) @@ -806,11 +874,11 @@ bool is_avx_supported() { // // Note that XGETBV is only available on 686 or later CPUs, so // the instruction needs to be conditionally run. - int cpuInfo[4]; - __cpuid(cpuInfo, 1); + unsigned int a,b,c,d; + get_cpuid(1, a, b, c, d); - bool osUsesXSAVE_XRSTORE = cpuInfo[2] & (1 << 27) || false; - bool cpuAVXSuport = cpuInfo[2] & (1 << 28) || false; + bool osUsesXSAVE_XRSTORE = c & (1 << 27) || false; + bool cpuAVXSuport = c & (1 << 28) || false; if (osUsesXSAVE_XRSTORE && cpuAVXSuport) { @@ -818,7 +886,6 @@ bool is_avx_supported() { unsigned long long xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK); supported = (xcrFeatureMask & 0x6) || false; } -#endif return supported; } diff --git a/client/time_stats.cpp b/client/time_stats.cpp index 1bd2754c443..6e0c31b8791 100644 --- a/client/time_stats.cpp +++ b/client/time_stats.cpp @@ -52,7 +52,7 @@ #define CONNECTED_STATE_UNKNOWN 2 #ifndef SIM -#ifdef _WIN32 +#if defined(_WIN32) && ( !defined(__MINGW32__) || defined(HAVE_LIBSENSAPI) ) #include int get_connected_state() { diff --git a/configure.ac b/configure.ac index ef7e4a373da..1256c2e6a51 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,13 @@ fi AC_SUBST(REV) AC_SUBST(RDATE) +dnl Are we compiling for windows +if echo $host_os | egrep '^mingw|^winnt' > /dev/null ; then + isWIN32=yes +else + isWIN32=no +fi + dnl turn dependency tracking on by default if test x${enable_dependency_tracking} != xno ; then enable_dependency_tracking=yes @@ -112,7 +119,13 @@ AC_ARG_ENABLE(xss, AS_HELP_STRING([--disable-xss], [disable building the boinc client with the Xss library]), [enable_xss=${enableval}], - [enable_xss=yes]) + [ + if test $isWIN32 != "yes" ; then + enable_xss=yes + else + enable_xss=yes + fi + ]) AC_ARG_ENABLE(boinczip, AS_HELP_STRING([--enable-boinczip], @@ -479,16 +492,26 @@ SAH_CHECK_LIB([dl], [dlopen], [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) SAH_CHECK_LIB([nsl], [gethostbyname], [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) -#SAH_CHECK_LIB([wsock32], [fopen], -# [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) -#SAH_CHECK_LIB([wsock], [fopen], -# [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) +SAH_CHECK_LIB([freetype], [fopen], + [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) SAH_CHECK_LIB([socket], [bind], [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) SAH_CHECK_LIB([z], [gzopen], [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) SAH_CHECK_LIB([cups], [md5_finish], [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) +if test "${isWIN32}" = "yes" ; then + SAH_CHECK_LIB([wsock32], [fopen], + [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) + SAH_CHECK_LIB([wsock], [fopen], + [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) + SAH_CHECK_LIB([comctl32], [fopen], + [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) + SAH_CHECK_LIB([winmm], [fopen], + [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) + SAH_CHECK_LIB([msimg32], [fopen], + [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"]) +fi LIBS=${SAVELIBS_AAF} @@ -540,8 +563,10 @@ dnl check for glut and prerequesites to the glut-test: libXmu and libXi dnl or on windows libGDI32 and libWinMM AC_CHECK_LIB([Xmu], [fopen], [have_Xmu="yes"], [have_Xmu="no"]) AC_CHECK_LIB([Xi], [fopen], [have_Xi="yes"], [have_Xi="no"]) -AC_CHECK_LIB([gdi32], [fopen]) -AC_CHECK_LIB([winmm], [fopen]) +if test "${isWIN32}" = "yes" ; then + AC_CHECK_LIB([gdi32], [fopen]) + AC_CHECK_LIB([winmm], [fopen]) +fi AX_CHECK_GLUT if test "X${no_x}" != "Xyes" -a "$no_glut" = yes; then @@ -575,7 +600,7 @@ else echo "DEBUG: GLUT_CFLAGS = $GLUT_CFLAGS" >&5 echo "DEBUG: GLUT_LIBS = $GLUT_LIBS" >&5 - AC_CHECK_HEADERS([gl.h glu.h glut.h glaux.h GL/gl.h GL/glu.h GL/glut.h GL/glaux.h OpenGL/gl.h OpenGL/glu.h OpenGL/glut.h OpenGL/glaux.h GLUT/glut.h MesaGL/gl.h MesaGL/glu.h MesaGL/glut.h MesaGL/glaux.h libnotify/notify.h gtk/gtk.h xlocale.h]) + AC_CHECK_HEADERS([gl.h glu.h glut.h glaux.h GL/gl.h GL/glu.h GL/glut.h GL/glaux.h OpenGL/gl.h OpenGL/glu.h OpenGL/glut.h OpenGL/glaux.h GLUT/glut.h MesaGL/gl.h MesaGL/glu.h MesaGL/glut.h MesaGL/glaux.h libnotify/notify.h gtk/gtk.h locale.h xlocale.h]) AC_CHECK_LIB([jpeg], [jpeg_start_compress],[have_jpeg=1],[have_jpeg=0]) AC_CHECK_HEADER([jpeglib.h],[have_jpeg=1],[have_jpeg=0]) @@ -621,8 +646,12 @@ AH_TOP([ ]) AH_BOTTOM([ -#ifndef HAVE_XLOCALE_H +#if !HAVE_DECL__CONFIGTHREADLOCALE #define NO_PER_THREAD_LOCALE 1 +#undef HAVE__CONFIGTHREADLOCALE +#else +#undef NO_PER_THREAD_LOCALE +#define HAVE__CONFIGTHREADLOCALE 1 #endif #ifndef HAVE_RES_INIT @@ -642,40 +671,95 @@ AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_HEADER_TIME AC_TYPE_SIGNAL -AC_CHECK_HEADERS(winsock2.h winsock.h windows.h ws2tcpip.h winternl.h crtdbg.h sys/types.h sys/un.h arpa/inet.h dirent.h grp.h fcntl.h inttypes.h stdint.h memory.h netdb.h netinet/in.h netinet/tcp.h netinet/ether.h net/if.h net/if_arp.h signal.h strings.h sys/auxv.h sys/file.h sys/fcntl.h sys/ipc.h sys/ioctl.h sys/msg.h sys/param.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/socket.h sys/stat.h sys/statvfs.h sys/statfs.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h utmp.h errno.h procfs.h ieeefp.h setjmp.h float.h) - -if test x${ac_cv_header_windows_h} = xyes ; then - -AC_CHECK_HEADERS([winhttp.h ntapi.h ddk/ntapi.h dbghelp.h delayimp.h],[], [], [[ -#if HAVE_WINDOWS_H -# include -#endif -]]) - -AC_CHECK_HEADER(security.h, [ -AC_DEFINE(HAVE_SECURITY_H,1,[Define to 1 if your compiler has the security.h header file]) -AC_DEFINE(SECURITY_WIN32,1,[Define to 1 if your compiler has the security.h header file]) -], [], [[ -#define SECURITY_WIN32 1 -#if HAVE_WINDOWS_H -# include -#endif -]]) +if test "${isWIN32}" = "yes" ; then + AC_CHECK_HEADERS(winsock2.h winsock.h windows.h ws2tcpip.h winternl.h crtdbg.h) +fi +AC_CHECK_HEADERS(sys/types.h sys/un.h arpa/inet.h dirent.h grp.h fcntl.h inttypes.h stdint.h memory.h netdb.h netinet/in.h netinet/tcp.h netinet/ether.h net/if.h net/if_arp.h signal.h strings.h sys/auxv.h sys/file.h sys/fcntl.h sys/ipc.h sys/ioctl.h sys/msg.h sys/param.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/socket.h sys/stat.h sys/statvfs.h sys/statfs.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h utmp.h errno.h procfs.h ieeefp.h setjmp.h float.h sal.h) + +if test "${isWIN32}" = "yes" ; then + AC_CHECK_HEADERS([winhttp.h ntapi.h ddk/ntapi.h dbghelp.h delayimp.h],[], [], [[ + #if HAVE_WINDOWS_H + # include + #endif + ]]) + + AC_CHECK_HEADER(security.h, [ + AC_DEFINE(HAVE_SECURITY_H,1,[Define to 1 if your compiler has the security.h header file]) + AC_DEFINE(SECURITY_WIN32,1,[Define to 1 if your compiler has the security.h header file]) + ], [], [[ + #define SECURITY_WIN32 1 + #if HAVE_WINDOWS_H + # include + #endif + ]]) + + AC_CHECK_TYPES([SYSTEM_PROCESSES, CLIENT_ID, VM_COUNTERS, SYSTEM_THREADS, THREAD_STATE, THREAD_WAIT_REASON],[],[],[[ + #if HAVE_WINDOWS_H + #include + #endif + #ifdef HAVE_WINTERNL_H + #include + #elif defined(HAVE_DDK_NTAPI_H) + #include + #elif defined(HAVE_NTAPI_H) + #include + #endif + ]]) +fi -AC_CHECK_TYPES([SYSTEM_PROCESSES, CLIENT_ID, VM_COUNTERS, SYSTEM_THREADS, THREAD_STATE, THREAD_WAIT_REASON],[],[],[[ -#if HAVE_WINDOWS_H -#include -#endif -#ifdef HAVE_WINTERNL_H -#include -#elif defined(HAVE_DDK_NTAPI_H) -#include -#elif defined(HAVE_NTAPI_H) -#include -#endif +AC_CHECK_HEADER(nvapi.h, [ + AC_DEFINE(HAVE_NVAPI_H,1,[Define to 1 if your compiler has the nvapi.h header file]) + ],[],[[ + #ifdef HAVE_WINDOWS_H + #include + #endif + #ifdef HAVE_SAL_H + #include "sal.h" + #endif + #ifndef __success + #define __success(x) + #endif + #ifndef __in + #define __in + #endif + #ifndef __out + #define __out + #endif + #ifndef __in_ecount + #define __in_ecount(x) + #endif + #ifndef __out_ecount + #define __out_ecount(x) + #endif + #ifndef __in_opt + #define __in_opt + #endif + #ifndef __out_opt + #define __out_opt + #endif + #ifndef __inout + #define __inout + #endif + #ifndef __inout_opt + #define __inout_opt + #endif + #ifndef __inout_ecount + #define __inout_ecount(x) + #endif + #ifndef __inout_ecount_full + #define __inout_ecount_full(x) + #endif + #ifndef __inout_ecount_part_opt + #define __inout_ecount_part_opt(x,y) + #endif + #ifndef __inout_ecount_full_opt + #define __inout_ecount_full_opt(x,y) + #endif + #ifndef __out_ecount_full_opt + #define __out_ecount_full_opt(x) + #endif ]]) -fi AC_CHECK_TYPES([socklen_t],[],[],[[ #if HAVE_WINDOWS_H @@ -804,9 +888,9 @@ AC_LANG_POP dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL AC_FUNC_VPRINTF -AC_CHECK_FUNCS(ether_ntoa setpriority sched_setscheduler strlcpy strlcat strcasestr strcasecmp sigaction getutent setutent getisax strdup strdupa daemon stat64 putenv setenv unsetenv res_init strtoull) +AC_CHECK_FUNCS(ether_ntoa setpriority sched_setscheduler strlcpy strlcat strcasestr strcasecmp sigaction getutent setutent getisax strdup _strdup strdupa _strdupa daemon stat64 putenv setenv unsetenv res_init strtoull localtime localtime_r gmtime gmtime_r) -AC_CHECK_DECLS([_fpreset, fpreset], +AC_CHECK_DECLS([_fpreset, fpreset, _configthreadlocale], [],[],[[ #include #if HAVE_SYS_TYPES_H @@ -853,6 +937,12 @@ AC_CHECK_DECLS([_fpreset, fpreset], #ifdef HAVE_MATH_H #include #endif +#ifdef HAVE_LOCALE_H +#include +#endif +#ifdef HAVE_XLOCALE_H +#include +#endif ]]) dnl Checks for typedefs, structures, and compiler characteristics. @@ -924,7 +1014,7 @@ if echo $host_os | grep '^darwin' >/dev/null ; then fi fi -AM_CONDITIONAL(OS_LINUX, [echo $host_os | grep '^linux' > /dev/null]) +AM_CONDITIONAL(OS_LINUX, [echo $host_os | grep '^linux' > /dev/null]) dnl In case anyone wants to try building the windows code using mingw! AM_CONDITIONAL(OS_WIN32, [echo $host_os | egrep '^mingw|^winnt' > /dev/null]) AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null]) @@ -985,14 +1075,79 @@ if test x${ac_cv_cxx_compiler_gnu} != xno ; then echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 fi fi -SAH_CHECK_LIB([wsock32],[fopen],[ - AC_DEFINE([HAVE_LIBWSOCK32],[1],[Define to 1 if you have the wsock32 library]) - CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) - echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 -SAH_CHECK_LIB([userenv],[fopen],[ - AC_DEFINE([HAVE_LIBUSERENV],[1],[Define to 1 if you have the userenv library]) +SAH_CHECK_LIB([nvapi],[fopen],[ + AC_DEFINE([HAVE_LIBNVAPI],[1],[Define to 1 if you have the NVIDIA API library]) CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 +if test ${isWIN32} = "yes" ; then + SAH_CHECK_LIB([gdi32],[fopen],[ + AC_DEFINE([HAVE_LIBWGDI32],[1],[Define to 1 if you have the gdi32 library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + found_msvcrt=no + SAH_CHECK_LIB([msvcr110],[fopen],[ + found_msvcrt=yes + AC_DEFINE([HAVE_LIBMSVCR110],[1],[Define to 1 if you have the msvcr110 library]) + AC_DEFINE([HAVE_MSVCRT],[1],[Define to 1 if you have a visual c runtime library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + if test $found_msvcrt = no ; then + SAH_CHECK_LIB([msvcr100],[fopen],[ + found_msvcrt=yes + AC_DEFINE([HAVE_LIBMSVCR100],[1],[Define to 1 if you have the msvcr100 library]) + AC_DEFINE([HAVE_MSVCRT],[1],[Define to 1 if you have a visual c runtime library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + fi + if test $found_msvcrt = no ; then + SAH_CHECK_LIB([msvcr90d],[fopen],[ + found_msvcrt=yes + AC_DEFINE([HAVE_LIBMSVCR90D],[1],[Define to 1 if you have the msvcr90d library]) + AC_DEFINE([HAVE_MSVCRT],[1],[Define to 1 if you have a visual c runtime library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + fi + if test $found_msvcrt = no ; then + SAH_CHECK_LIB([msvcr90],[fopen],[ + found_msvcrt=yes + AC_DEFINE([HAVE_LIBMSVCR90],[1],[Define to 1 if you have the msvcr90 library]) + AC_DEFINE([HAVE_MSVCRT],[1],[Define to 1 if you have a visual c runtime library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + fi + SAH_CHECK_LIB([wininet],[fopen],[ + AC_DEFINE([HAVE_LIBWININET],[1],[Define to 1 if you have the wininet library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + SAH_CHECK_LIB([wsock32],[fopen],[ + AC_DEFINE([HAVE_LIBWSOCK32],[1],[Define to 1 if you have the wsock32 library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + SAH_CHECK_LIB([userenv],[fopen],[ + AC_DEFINE([HAVE_LIBUSERENV],[1],[Define to 1 if you have the userenv library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + SAH_CHECK_LIB([iphlpapi],[fopen],[ + AC_DEFINE([HAVE_LIBIPHLPAPI],[1],[Define to 1 if you have the iphlpapi library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + SAH_CHECK_LIB([sensapi],[fopen],[ + AC_DEFINE([HAVE_LIBSENSAPI],[1],[Define to 1 if you have the sensapi library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + SAH_CHECK_LIB([wtsapi32],[fopen],[ + AC_DEFINE([HAVE_LIBWTSAPI32],[1],[Define to 1 if you have the wtsapi32 library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + SAH_CHECK_LIB([winhttp],[fopen],[ + AC_DEFINE([HAVE_LIBWINHTTP],[1],[Define to 1 if you have the WinHttp library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 + SAH_CHECK_LIB([secur32],[fopen],[ + AC_DEFINE([HAVE_LIBSECUR32],[1],[Define to 1 if you have the secur32 library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) + echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 +fi svlibs=$LIBS if test "${ac_cv_func_res_init}" != "yes" ; then diff --git a/lib/app_ipc.cpp b/lib/app_ipc.cpp index 3aa6066a23b..262ab47e905 100644 --- a/lib/app_ipc.cpp +++ b/lib/app_ipc.cpp @@ -35,7 +35,7 @@ #include "app_ipc.h" -#ifdef _MSC_VER +#if !defined(HAVE_STRDUP) && defined(HAVE__STRDUP) #define strdup _strdup #endif diff --git a/lib/boinc_win.h b/lib/boinc_win.h index ed01c1791b9..da9f8e26386 100644 --- a/lib/boinc_win.h +++ b/lib/boinc_win.h @@ -41,7 +41,6 @@ #define HAVE_STD_TRANSFORM 1 #endif - #ifndef HAVE_ALLOCA #define HAVE_ALLOCA 1 #endif @@ -66,10 +65,26 @@ #define HAVE_WINHTTP_H 1 #define HAVE_WINTERNL_H 1 #define HAVE_DELAYIMP_H 1 +#define HAVE_INTRIN_H 1 #define HAVE_FCNTL_H 1 #define HAVE_CRTDBG_H 1 #define HAVE_DECL_FPRESET 1 #define HAVE_DECL__FPRESET 1 +#define HAVE_DECL___CPUID 1 +#define HAVE_MSVCRT 1 +#undef HAVE_STRDUP +#define HAVE__STRDUP 1 +#undef NO_PER_THREAD_LOCALE +#define HAVE_DECL__CONFIGTHREADLOCALE 1 +#define HAVE__CONFIGTHREADLOCALE 1 +#define HAVE_DECL___CPUID 1 + +#if ( _MSC_FULL_VER >= 160040219 ) +#define HAVE_DECL__XGETBV 1 +#else +#define HAVE_DECL__XGETBV 0 +#endif + #else // Under any system that can run configure we need to include config.h first. @@ -120,6 +135,7 @@ /* If we're not running under CYGWIN use windows networking */ #undef USE_WINSOCK #define USE_WINSOCK 1 +/* wxWidgets doesn't do winsock 2, so ignore it for now */ #ifdef HAVE_WINSOCK2_H #include #elif defined(HAVE_WINSOCK_H) diff --git a/xcompile/xcompile.MinGW32_on_cygwin.sh b/xcompile/xcompile.MinGW32_on_cygwin.sh index d74ccf11fab..6d767eb5bd7 100755 --- a/xcompile/xcompile.MinGW32_on_cygwin.sh +++ b/xcompile/xcompile.MinGW32_on_cygwin.sh @@ -8,14 +8,16 @@ case $1 in export TARGET_HOST=$1 ;; esac +echo -n Checking for cross compiling environment ... for target_host in ${TARGET_HOST} i686-w64-mingw32 i686-pc-mingw32 x86_64-w64-mingw32 x86_64-pc-mingw32 none ; do if test ${target_host} = none ; then + echo ${target_host} echo Cross compiling environment not found in /usr exit 1 fi - echo Checking for cross compiling environment in /usr/${target_host} if test -d /usr/${target_host}; then export TARGET_HOST=${target_host} + echo /usr/${target_host} break fi done @@ -28,7 +30,7 @@ case $TARGET_HOST in esac build_manager=no -build_client=no +build_client=yes build_libs=yes build_server=no @@ -123,36 +125,76 @@ if test $build_client != no -o $build_manager != no ; then fi fi -if test $build_manager != no ; then - if ! test -f ${XCOMPILE_ROOT}/lib/libwxbase30u.a ; then - z7=`which 7z` - if test "x${z7}" = x ; then - echo you must install 7z in the path in order to install wxwidgets - exit 1 +if test $build_client != no ; then + thisdir=`pwd` + if ! test -f ${XCOMPILE_ROOT}/include/nvapi.h ; then + rsync -va ../coprocs/NVIDIA/include/* ${XCOMPILE_ROOT}/include + fi + nvdir= + if ! test -f ${XCOMPILE_ROOT}/lib/libnvapi.a ; then + mkdir NVIDIA + case $target_host in + i[56]86-*) nvdir=../coprocs/NVIDIA/mswin/Win32/Release/lib + ;; + x86*|x64*) nvdir=../coprocs/NVIDIA/mswin/x64/Release/lib + ;; + esac + if test x$nvdir != x ; then + rsync -va $nvdir/* NVIDIA + cd NVIDIA + obj=`ar t nvapi.lib | head -1` + objdir=`dirname $obj` + mkdir -p $objdir + ar x nvapi.lib + cd $objdir + ar cr libnvapi.a *.obj + mv *.a ${XCOMPILE_ROOT}/lib fi + fi + cd $thisdir + rm -rf NVIDIA +fi + +if test $build_manager != no ; then + if ! test -f ${XCOMPILE_ROOT}/lib/libwx_baseu_net-3.0-i686-w64-mingw32.dll.a ; then wxver=3.0.0 - gccver=481 - filename=wxMSW-${wxver}_gcc${gccver}TDM_Dev.7z - mkdir wxdist - cd wxdist - wget http://sourceforge.net/projects/wxwindows/files/3.0.0/binaries/$filename/download - mv download $filename - 7z x $filename - rm $filename - rsync lib/gcc${gccver}TDM_dll/*.a ${XCOMPILE_ROOT}/lib - rsync lib/gcc${gccver}TDM_dll/*.dll ${XCOMPILE_ROOT}/bin - filename=wxWidgets-${wxver}_headers.7z + filename=wxWidgets-${wxver}.tar.bz2 wget http://sourceforge.net/projects/wxwindows/files/3.0.0/$filename/download mv download $filename - 7z x $filename - rm $filename - rsync -va include/wx ${XCOMPILE_ROOT}/include - rsync -va lib/gcc${gccver}TDM_dll/mswu/wx ${XCOMPILE_ROOT}/include + tar jxf $filename +# rm -f $filename + cd wxWidgets-${wxver} + enables="--with-msw --with-libpng --with-libjpeg --with-libtiff --with-opengl --with-zlib --enable-toolbar --enable-statusbar --enable-statbmp --enable-intl --enable-accessibility --enable-catch_segvs --enable-std_containers --enable-std_iostreams --enable-std_string --enable-std_string_conv_in_wxstring --enable-permissive --enable-xlocale --enable-config --enable-protocols --enable-ftp --enable-http --enable-fileproto --enable-sockets --enable-ole --enable-dataobj --enable-ipc --enable-baseevtloop --enable-selectloop --enable-any --enable-base64 --enable-dialupman --enable-uxtheme " + ./configure -C --host=$TARGET_HOST --build=$BUILD_HOST ${enables} --with-libcurl=${XCOMPILE_ROOT} --with-ssl=${XCOMPILE_ROOT} --with-winsock --prefix=${XCOMPILE_ROOT} + make all + make install + /bin/cp lib/*.a ${XCOMPILE_ROOT}/lib + /bin/cp lib/*.dll ${XCOMPILE_ROOT}/bin + /bin/mv -f ${XCOMPILE_ROOT}/lib/wx*.dll ${XCOMPILE_ROOT}/bin cd .. - rm -rf wxdist + rm -rf wxWidgets-${wxver} fi fi +if test $build_manager != no ; then + if ! test -f ${XCOMPILE_ROOT}/lib/libsqlite3.a ; then + sqlite_year=2014 + sqlite_ver=3080403 + filename=sqlite-autoconf-${sqlite_ver}.tar.gz + wget http://www.sqlite.org/${sqlite_year}/$filename + tar zxf $filename + cd sqlite-autoconf-${sqlite_ver} + ./configure -C --host=$TARGET_HOST --build=$BUILD_HOST --prefix=${XCOMPILE_ROOT} --with-sysroot=${XCOMPILE_ROOT} + make all + make install + cd .. + /bin/rm -f $filename + /bin/rm -rf sqlite-autoconf-${sqlite_ver} + fi +fi + + + if test $build_manager != no -o $build_libs != no ; then if ! test -f ${XCOMPILE_ROOT}/include/GL/glut.h -a -f ${XCOMPILE_ROOT}/lib/libfreeglut_static.a ; then svn co http://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut freeglut @@ -197,4 +239,4 @@ fi ../configure -C --host=$TARGET_HOST --build=$BUILD_HOST ${enables} --with-libcurl=${XCOMPILE_ROOT} --with-ssl=${XCOMPILE_ROOT} --with-winsock --prefix=${XCOMPILE_ROOT} make -j 4 all -exit 0 +#exit 0