-
Notifications
You must be signed in to change notification settings - Fork 4
/
BUILD-OpenSSL.sh
92 lines (67 loc) · 2.11 KB
/
BUILD-OpenSSL.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
TARGET=openssl-1.0.1c
SDK_VERSION=6.0
DEVROOT="/Applications/Xcode.app/Contents/Developer"
OPATH=$PATH
############################################################
build_openssl() {
LIBNAME=$1
DISTDIR=`pwd`/dist-$LIBNAME
PLATFORM=$2
echo "Building binary for iPhone $LIBNAME $PLATFORM to $DISTDIR"
echo Removing ${TARGET}
/bin/rm -rf ${TARGET}
echo Extracting ${TARGET}
tar zxf ${TARGET}.tar.gz
case $LIBNAME in
device) ARCH="armv7";ASSEMBLY="no-asm";;
*) ARCH="i386";ASSEMBLY="";;
esac
cd ${TARGET}
echo Patching crypto/ui/ui_openssl.c
echo From: `fgrep 'intr_signal;' crypto/ui/ui_openssl.c`
perl -pi.bak \
-e 's/static volatile sig_atomic_t intr_signal;/static volatile int intr_signal;/;' \
crypto/ui/ui_openssl.c
echo To: `fgrep 'intr_signal;' crypto/ui/ui_openssl.c`
# Compile a version for the device...
PATH="${DEVROOT}/Platforms/${PLATFORM}.platform/Developer/usr/bin:$OPATH"
export PATH
SDKPATH="${DEVROOT}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDK_VERSION}.sdk"
mkdir ${DISTDIR}
./config --openssldir=${DISTDIR} ${ASSEMBLY}
perl -pi.bak \
-e "s;CC= cc;CC = ${DEVROOT}/Platforms/${PLATFORM}.platform/Developer/usr/bin/gcc; ;" \
-e "s;CFLAG= ;CFLAG=-arch ${ARCH} -isysroot ${SDKPATH} ; ;" \
-e "s;-arch i386;-arch ${ARCH}; ;" \
Makefile
case $LIBNAME in
simulator)
perl -pi.bak \
-e 'if (/LIBDEPS=/) { s/\)}";/\)} -L.";/; }' \
Makefile.shared
(cd apps; ln -s ${SDKPATH}/usr/lib/crt1.10.5.o crt1.10.6.o);
(cd test; ln -s ${SDKPATH}/usr/lib/crt1.10.5.o crt1.10.6.o);
;;
esac
make
make install
cd ..
echo Clean-up ${TARGET}
/bin/rm -rf ${TARGET}
}
build_openssl "device" "iPhoneOS"
build_openssl "simulator" "iPhoneSimulator"
### Then, combine them into one..
echo "Creating combined binary into directory 'dist'"
/bin/rm -rf dist
mkdir dist
TOP=`pwd`
(cd ${TOP}/dist-device; /usr/bin/tar cf - . ) | (cd ${TOP}/dist; /usr/bin/tar xf -)
for i in crypto ssl
do
lipo -create dist-device/lib/lib$i.a dist-simulator/lib/lib$i.a \
-o dist/lib/lib$i.a
done
/bin/rm -rf dist-simulator dist-device
echo "Now package is ready in 'dist' directory'"