Refresh config.guess and config.sub
[libffi.git] / patches / ios-fixes
1 Index: libffi/ChangeLog
2 ===================================================================
3 --- libffi.orig/ChangeLog
4 +++ libffi/ChangeLog
5 @@ -148,7 +148,7 @@
6         * src/prep_cif.c (UNLIKELY, LIKELY): Define.
7         (initialize_aggregate): Check for bad types.
8  
9 -2011-02-09  Landon Fuller <landonf@macports.org>
10 +2011-02-09  Landon Fuller <landonf@plausible.coop>
11  
12         * Makefile.am (EXTRA_DIST): Add build-ios.sh, src/arm/gentramp.sh,
13         src/arm/trampoline.S.
14 Index: libffi/build-ios.sh
15 ===================================================================
16 --- libffi.orig/build-ios.sh
17 +++ libffi/build-ios.sh
18 @@ -2,11 +2,66 @@
19  
20  PLATFORM_IOS=/Developer/Platforms/iPhoneOS.platform/
21  PLATFORM_IOS_SIM=/Developer/Platforms/iPhoneSimulator.platform/
22 -SDK_IOS_VERSION="4.1"
23 +SDK_IOS_VERSION="4.2"
24 +MIN_IOS_VERSION="3.0"
25 +OUTPUT_DIR="universal-ios"
26  
27 -mkdir -p "build-ios"
28 -pushd "build-ios"
29 -export CC="${PLATFORM_IOS}"/Developer/usr/bin/gcc-4.2
30 -export CFLAGS="-arch armv6 -isysroot ${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/"
31 -../configure --host=arm-apple-darwin10 && make
32 -popd
33 +build_target () {
34 +    local platform=$1
35 +    local sdk=$2
36 +    local arch=$3
37 +    local triple=$4
38 +    local builddir=$5
39 +
40 +    mkdir -p "${builddir}"
41 +    pushd "${builddir}"
42 +    export CC="${platform}"/Developer/usr/bin/gcc-4.2
43 +    export CFLAGS="-arch ${arch} -isysroot ${sdk} -miphoneos-version-min=${MIN_IOS_VERSION}"
44 +    ../configure --host=${triple} && make
45 +    popd
46 +}
47 +
48 +# Build all targets
49 +build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv6 arm-apple-darwin10 armv6-ios
50 +build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv7 arm-apple-darwin10 armv7-ios
51 +build_target "${PLATFORM_IOS_SIM}" "${PLATFORM_IOS_SIM}/Developer/SDKs/iPhoneSimulator${SDK_IOS_VERSION}.sdk/" i386 i386-apple-darwin10 i386-ios-sim
52 +
53 +# Create universal output directories
54 +mkdir -p "${OUTPUT_DIR}"
55 +mkdir -p "${OUTPUT_DIR}/include"
56 +mkdir -p "${OUTPUT_DIR}/include/armv6"
57 +mkdir -p "${OUTPUT_DIR}/include/armv7"
58 +mkdir -p "${OUTPUT_DIR}/include/i386"
59 +
60 +# Create the universal binary
61 +lipo -create armv6-ios/.libs/libffi.a armv7-ios/.libs/libffi.a i386-ios-sim/.libs/libffi.a -output "${OUTPUT_DIR}/libffi.a"
62 +
63 +# Copy in the headers
64 +copy_headers () {
65 +    local src=$1
66 +    local dest=$2
67 +
68 +    # Fix non-relative header reference
69 +    sed 's/<ffitarget.h>/"ffitarget.h"/' < "${src}/include/ffi.h" > "${dest}/ffi.h"
70 +    cp "${src}/include/ffitarget.h" "${dest}"
71 +}
72 +
73 +copy_headers armv6-ios "${OUTPUT_DIR}/include/armv6"
74 +copy_headers armv7-ios "${OUTPUT_DIR}/include/armv7"
75 +copy_headers i386-ios-sim "${OUTPUT_DIR}/include/i386"
76 +
77 +# Create top-level header
78 +(
79 +cat << EOF
80 +#ifdef __arm__
81 +  #include <arm/arch.h>
82 +  #ifdef _ARM_ARCH_6
83 +    #include "include/armv6/ffi.h"
84 +  #elif _ARM_ARCH_7
85 +    #include "include/armv7/ffi.h"
86 +  #endif
87 +#elif defined(__i386__)
88 +  #include "include/i386/ffi.h"
89 +#endif
90 +EOF
91 +) > "${OUTPUT_DIR}/ffi.h"