forked from shigeyas/build-pcre-iphone
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBUILD-PCRE.sh
96 lines (67 loc) · 2.18 KB
/
BUILD-PCRE.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
93
94
95
96
#!/bin/bash
OPATH=$PATH
TARGET=pcre-8.12
SDK_VERSION=4.3
CONFIG="--disable-shared --enable-utf8"
# This script will compile a PCRE static lib for the device and simulator
build_pcre() {
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
armv6) ARCH="armv6"; HOST="--host=arm-apple-darwin";;
armv7) ARCH="armv7"; HOST="--host=arm-apple-darwin";;
*) ARCH="i386"; HOST="";;
esac
# Compile a version for the device...
cd ${TARGET}
SDKPATH="/Developer/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDK_VERSION}.sdk"
PATH=/Developer/Platforms/${PLATFORM}.platform/Developer/usr/bin:$OPATH
export PATH
case $LIBNAME in
simulator)
ln -s ${SDKPATH}/usr/lib/crt1.10.5.o crt1.10.6.o;
;;
esac
./configure ${CONFIG} ${HOST} \
CFLAGS="-arch ${ARCH} -isysroot ${SDKPATH}" \
CXXFLAGS="-arch ${ARCH} -isysroot ${SDKPATH}" \
LDFLAGS="-L." \
CC="/Developer/Platforms/${PLATFORM}.platform/Developer/usr/bin/gcc" \
CXX="/Developer/Platforms/${PLATFORM}.platform/Developer/usr/bin/g++"
# Eliminate test unit entry
perl -pi.bak \
-e 'if (/^all-am:/) { s/\$\(PROGRAMS\) //; }' \
Makefile
make
mkdir ${DISTDIR}
mkdir ${DISTDIR}/lib
mkdir ${DISTDIR}/include
cp -p .libs/libpcre.a ${DISTDIR}/lib
cp -p .libs/libpcrecpp.a ${DISTDIR}/lib
cp -p .libs/libpcreposix.a ${DISTDIR}/lib
cp -p pcre*h ${DISTDIR}/include
cd ..
echo Clean-up ${TARGET}
/bin/rm -rf ${TARGET}
}
build_pcre "armv6" "iPhoneOS"
build_pcre "armv7" "iPhoneOS"
build_pcre "simulator" "iPhoneSimulator"
### Then, combine them into one..
echo "Creating combined binary into directory 'dist'"
/bin/rm -rf dist
mkdir dist
(cd dist-device; tar cf - . ) | (cd dist; tar xf -)
for i in pcre pcrecpp pcreposix
do
lipo -create dist-armv6/lib/lib$i.a dist-simulator/lib/lib$i.a \
dist-armv7/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'"