Ticket #1116: 0005-Fix-autotools-build-with-recent-OS-X-versions.patch

File 0005-Fix-autotools-build-with-recent-OS-X-versions.patch, 10.5 KB (added by MattArsenault, 13 years ago)
  • client/Makefile.am

    From f24ee1733e63e6f2e817797d428bc636025ae45f Mon Sep 17 00:00:00 2001
    From: Matt Arsenault <arsenm2@rpi.edu>
    Date: Wed, 22 Jun 2011 21:56:41 -0400
    Subject: [PATCH 5/6] Fix autotools build with recent OS X versions
    
    ---
     client/Makefile.am       |   15 +++++---
     client/cs_platforms.cpp  |   23 +++++-------
     client/hostinfo_unix.cpp |   84 +++++++++++++++++++++++++--------------------
     3 files changed, 66 insertions(+), 56 deletions(-)
    
    diff --git a/client/Makefile.am b/client/Makefile.am
    index 20b1194..f72d971 100644
    a b endif ## ENABLE_CLIENT_RELEASE 
    1919LIBS += $(CLIENTLIBS)
    2020
    2121if OS_DARWIN
    22    LIBS += -framework IOKit -framework Foundation -framework ScreenSaver -framework Cocoa
     22   LIBS += -framework IOKit -framework Foundation -framework ScreenSaver -framework Cocoa -framework CoreServices
    2323endif
    2424
    2525bin_PROGRAMS = boinc_client switcher boinccmd
    2626
    2727boinccmd_SOURCES = boinc_cmd.cpp
    28 boinccmd_DEPENDENCIES = $(LIBBOINC) 
     28boinccmd_DEPENDENCIES = $(LIBBOINC)
    2929boinccmd_CPPFLAGS = $(AM_CPPFLAGS)
    30 boinccmd_LDFLAGS = $(AM_LDFLAGS) -L../lib 
     30boinccmd_LDFLAGS = $(AM_LDFLAGS) -L../lib
    3131boinccmd_LDADD = $(LIBBOINC) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)
    3232
    3333boinc_client_SOURCES = \
    boinc_client_SOURCES = \ 
    7979
    8080boinc_client_DEPENDENCIES = $(LIBBOINC)
    8181boinc_client_CPPFLAGS = $(AM_CPPFLAGS)
    82 boinc_client_LDFLAGS = $(AM_LDFLAGS) -L../lib
    83 boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)
     82boinc_client_LDFLAGS = $(AM_LDFLAGS) -L../lib
     83if OS_DARWIN
     84boinc_client_LDFLAGS += -Wl,-flat_namespace,-undefined,dynamic_lookup
     85endif
     86boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)
    8487
    8588boinc_clientdir = $(bindir)
    8689
    8790switcher_SOURCES = switcher.cpp
    88 switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib 
     91switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib
    8992switcher_LDADD = $(LIBBOINC)
    9093
    9194## since we are using libtool we need some magic to get boinc and boinc_client
  • client/cs_platforms.cpp

    diff --git a/client/cs_platforms.cpp b/client/cs_platforms.cpp
    index 3b7290f..fd92d5b 100644
    a b LPFN_ISWOW64PROCESS fnIsWow64Process; 
    4040#endif
    4141#endif
    4242
     43#if defined(__APPLE__) && (defined(__i386__) || defined(__x86_64__))
     44#include <CoreServices/CoreServices.h>
     45#include <sys/sysctl.h>
     46#endif
     47
     48
     49
    4350#include "client_types.h"
    4451#include "client_state.h"
    4552#include "error_numbers.h"
    LPFN_ISWOW64PROCESS fnIsWow64Process; 
    4956#include "str_replace.h"
    5057#include "util.h"
    5158
    52 #if (defined (__APPLE__) && (defined(__i386__) || defined(__x86_64__)))
    53 #include <sys/sysctl.h>
    54 #include <Carbon/Carbon.h>
    55 
    56 char *HOSTTYPE = "";
    57 #endif
    58 
    5959// return the primary platform id.
    6060//
    6161const char* CLIENT_STATE::get_primary_platform() {
    void CLIENT_STATE::detect_platforms() { 
    109109    err = Gestalt(gestaltSystemVersion, &version);
    110110    retval = sysctlbyname("hw.optional.x86_64", &response, &len, NULL, 0);
    111111    if ((err == noErr) && (version >= 0x1050) && response && (!retval)) {
    112         HOSTTYPE = "x86_64-apple-darwin";
    113112        add_platform("x86_64-apple-darwin");
    114     } else {
    115         HOSTTYPE = "i686-apple-darwin";
    116113    }
    117114
    118115    // Supported on both Mac Intel architectures
    119116    add_platform("i686-apple-darwin");
    120117#else
    121     // We no longer request PowerPC applications on Intel Macs 
    122     // because all projects supporting Macs should have Intel 
    123     // applications by now, and PowerPC emulation ("Rosetta") 
     118    // We no longer request PowerPC applications on Intel Macs
     119    // because all projects supporting Macs should have Intel
     120    // applications by now, and PowerPC emulation ("Rosetta")
    124121    // is not always supported in newer versions of OS X.
    125122    add_platform("powerpc-apple-darwin");
    126123#endif
  • client/hostinfo_unix.cpp

    diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp
    index afd6f14..ed56da0 100644
    a b  
    1616// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
    1717
    1818// There is a reason that having a file called "cpp.h" that includes config.h
    19 // and some of the C++ header files is bad.  That reason is because there are 
    20 // #defines that alter the behiour of the standard C and C++ headers.  In 
    21 // this case we need to use the "small files" environment on some unix 
     19// and some of the C++ header files is bad.  That reason is because there are
     20// #defines that alter the behiour of the standard C and C++ headers.  In
     21// this case we need to use the "small files" environment on some unix
    2222// systems.  That can't be done if we include "cpp.h"
    2323
    24 // copied directly from cpp.h
    25 #if defined(_WIN32) && !defined(__CYGWIN32__)
    26 
    27 #if defined(_WIN64) && defined(_M_X64)
    28 #define HOSTTYPE    "windows_x86_64"
    29 #define HOSTTYPEALT "windows_intelx86"
    30 #else
    31 #define HOSTTYPE "windows_intelx86"
    32 #endif
    33 
    3424#include "version.h"         // version numbers from autoconf
    35 #endif
    3625
     26#include "cpp.h"
    3727#include "config.h"
    3828
    3929#if !defined(_WIN32) || defined(__CYGWIN32__)
    4030
    4131// Access to binary files in /proc filesystem doesn't work in the 64bit
    42 // files environment on some systems.  None of the functions here need 
     32// files environment on some systems.  None of the functions here need
    4333// 64bit file functions, so we'll undefine _FILE_OFFSET_BITS and _LARGE_FILES.
    4434#undef _FILE_OFFSET_BITS
    4535#undef _LARGE_FILES
     
    110100#include "client_types.h"
    111101#include "client_msgs.h"
    112102#include "hostinfo_network.h"
     103#include "hostinfo.h"
    113104
    114105using std::string;
    115106
    116107#ifdef __APPLE__
     108#include <IOKit/IOKitLib.h>
    117109#include <Carbon/Carbon.h>
    118110#include <CoreFoundation/CoreFoundation.h>
     111
    119112#ifdef __cplusplus
    120113extern "C" {
    121114#endif
    bool HOST_INFO::host_is_running_on_batteries() { 
    208201    CFStringRef psState;
    209202    int i;
    210203    bool retval = false;
    211  
     204
    212205    CFTypeRef blob = IOPSCopyPowerSourcesInfo();
    213206    CFArrayRef list = IOPSCopyPowerSourcesList(blob);
    214207
    static void get_cpu_info_maxosx(HOST_INFO& host) { 
    637630#if defined(__i386__) || defined(__x86_64__)
    638631    char brand_string[256];
    639632    int family, stepping, model;
    640    
     633
    641634    len = sizeof(host.p_vendor);
    642635    sysctlbyname("machdep.cpu.vendor", host.p_vendor, &len, NULL, 0);
    643636
    static void get_cpu_info_maxosx(HOST_INFO& host) { 
    658651
    659652    snprintf(
    660653        host.p_model, sizeof(host.p_model),
    661         "%s [x86 Family %d Model %d Stepping %d]", 
     654        "%s [x86 Family %d Model %d Stepping %d]",
    662655        brand_string, family, model, stepping
    663656    );
    664657#else       // PowerPC
    static void get_cpu_info_maxosx(HOST_INFO& host) { 
    670663    if (response && (!retval)) {
    671664        safe_strcpy(host.p_features, "AltiVec");
    672665    }
    673        
     666
    674667    len = sizeof(model);
    675668    sysctlbyname("hw.model", model, &len, NULL, 0);
    676669
    static void get_cpu_info_haiku(HOST_INFO& host) { 
    703696    cpuid_info cpuInfo;
    704697    int32 maxStandardFunction;
    705698    int32 maxExtendedFunction = 0;
    706    
     699
    707700    char brand_string[256];
    708701
    709702    if (get_system_info(&sys_info) != B_OK) {
    static void get_cpu_info_haiku(HOST_INFO& host) { 
    718711
    719712    snprintf(host.p_vendor, sizeof(host.p_vendor), "%.12s",
    720713        cpuInfo.eax_0.vendor_id);
    721    
     714
    722715    maxStandardFunction = cpuInfo.eax_0.max_eax;
    723716    if (maxStandardFunction >= 500)
    724717        maxStandardFunction = 0; /* old Pentium sample chips has
    int get_network_usage_totals(unsigned int& total_received, unsigned int& total_s 
    855848
    856849    total_received = 0;
    857850    total_sent = 0;
    858    
     851
    859852    if (sysctl(mib, 6, NULL, &currentSize, NULL, 0) != 0) return errno;
    860853    if (!sysctlBuffer || (currentSize > sysctlBufferSize)) {
    861854        if (sysctlBuffer) free(sysctlBuffer);
    kern_return_t SMCClose() 
    996989    return kIOReturnSuccess;
    997990}
    998991
    999 
    1000992kern_return_t SMCReadKey(UInt32 key, SMCBytes_t val) {
    1001993    kern_return_t       result;
    1002994    SMCKeyData_t        inputStructure;
    1003995    SMCKeyData_t        outputStructure;
    1004      size_t              structureInputSize;
    1005     size_t              structureOutputSize;
     996    size_t              structureOutputSize = 0;
    1006997
    1007     memset(&inputStructure, 0, sizeof(SMCKeyData_t));
    1008     memset(&outputStructure, 0, sizeof(SMCKeyData_t));
     998    memset(&inputStructure, 0, sizeof(inputStructure));
     999    memset(&outputStructure, 0, sizeof(outputStructure));
    10091000    memset(val, 0, sizeof(val));
    10101001
    10111002    inputStructure.key = key;
    1012     inputStructure.data8 = SMC_CMD_READ_KEYINFO;   
    1013 
    1014     structureInputSize = sizeof(inputStructure);
    1015     structureOutputSize = sizeof(outputStructure);
    1016     result = IOConnectMethodStructureIStructureO(
    1017         conn, KERNEL_INDEX_SMC, structureInputSize, &structureOutputSize,
    1018         &inputStructure, &outputStructure
    1019     );
     1003    inputStructure.data8 = SMC_CMD_READ_KEYINFO;
     1004
     1005#if MAC_OS_X_VERSION_10_5
     1006    result = IOConnectCallStructMethod(conn,
     1007                                       KERNEL_INDEX_SMC,
     1008                                       &inputStructure,
     1009                                       sizeof(inputStructure),
     1010                                       &inputStructure,
     1011                                       &structureOutputSize);
     1012#else
     1013    result = IOConnectMethodStructureIStructureO(conn,
     1014                                                 KERNEL_INDEX_SMC,
     1015                                                 sizeof(inputStructure),
     1016                                                 &structureOutputSize,
     1017                                                 &inputStructure,
     1018                                                 &outputStructure);
     1019#endif
    10201020    if (result != kIOReturnSuccess) {
    10211021        return result;
    10221022    }
    kern_return_t SMCReadKey(UInt32 key, SMCBytes_t val) { 
    10241024    inputStructure.keyInfo.dataSize = outputStructure.keyInfo.dataSize;
    10251025    inputStructure.data8 = SMC_CMD_READ_BYTES;
    10261026
     1027#if MAC_OS_X_VERSION_10_5
     1028    result = IOConnectCallStructMethod(conn,
     1029                                       KERNEL_INDEX_SMC,
     1030                                       &inputStructure,
     1031                                       sizeof(inputStructure),
     1032                                       &inputStructure,
     1033                                       &structureOutputSize);
     1034#else
    10271035    result = IOConnectMethodStructureIStructureO(
    1028         conn, KERNEL_INDEX_SMC, structureInputSize, &structureOutputSize,
     1036        conn, KERNEL_INDEX_SMC, sizeof(inputStructure), &structureOutputSize),
    10291037        &inputStructure, &outputStructure
    10301038    );
    1031     if (result != kIOReturnSuccess)
     1039#endif
     1040    if (result != kIOReturnSuccess) {
    10321041        return result;
     1042    }
    10331043
    10341044    memcpy(val, outputStructure.bytes, sizeof(outputStructure.bytes));
    10351045