Skip to content

Commit 36ef229

Browse files
committed
Merge pull request #81 - iOS build
2 parents 3068217 + 053706b commit 36ef229

File tree

7 files changed

+1780
-0
lines changed

7 files changed

+1780
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ test.*.log
4242
/swift-api/Makefile
4343
/swift-api/build/
4444
/swift-api/test-swift
45+
build
46+
ios/libserval.xcodeproj/project.xcworkspace/xcuserdata/
47+
ios/libserval.xcodeproj/xcuserdata/
48+
.DS_Store

ios/build.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/sh
2+
3+
# Created by James Moore on 3/25/14.
4+
# Copyright (c) 2014 The Serval Project. All rights reserved.
5+
6+
# set -x
7+
8+
# if we're building inside of xcode we need to back up a level
9+
if [[ -n $DEVELOPER_DIR ]]; then
10+
cd ..
11+
pwd
12+
fi
13+
14+
# Add the homebrew tools to the path since automake no longer is apart of Xcode
15+
PATH=/usr/local/bin:$PATH
16+
ARCHS="armv7 armv7s arm64 i386 x86_64"
17+
SDK_VERSION=8.0
18+
SDK_TARGET=7.1
19+
PREFIX=$(pwd)/build
20+
DEVELOPER=`xcode-select -print-path`
21+
SYMROOT="build"
22+
23+
command -v autoreconf >/dev/null 2>&1 || { echo "In order to build this library you must have the autoreconf tool installed. It's available via homebrew."; exit 1; }
24+
25+
buildIOS()
26+
{
27+
ARCH=$1
28+
HOST=""
29+
PREFIX="/tmp/servald"
30+
31+
if [[ "${ARCH}" == "i386" ]]; then
32+
PLATFORM="iPhoneSimulator"
33+
HOST="--host=i386-apple-darwin"
34+
elif [[ "${ARCH}" == "x86_64" ]]; then
35+
PLATFORM="iPhoneSimulator"
36+
else
37+
PLATFORM="iPhoneOS"
38+
HOST="--host=arm-apple-darwin"
39+
PREFIX="/Library/servald"
40+
fi
41+
42+
CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
43+
CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
44+
SDKROOT="${CROSS_TOP}/SDKs/${CROSS_SDK}"
45+
46+
export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot $SDKROOT -I$SDKROOT/usr/include -miphoneos-version-min=${SDK_TARGET}"
47+
export CC="clang"
48+
49+
echo "=> Building libserval for ${PLATFORM} ${SDK_TARGET} ${ARCH}"
50+
51+
LOG_PATH="${SYMROOT}/libserval-${ARCH}.log"
52+
./configure $HOST --prefix $PREFIX &> "$LOG_PATH" || { echo "configure failed; see $LOG_PATH"; exit 1; }
53+
54+
make libserval.a >> "$LOG_PATH" 2>&1 || { echo "make failed; see $LOG_PATH"; exit 1; }
55+
cp libserval.a ${SYMROOT}/libserval-${ARCH}.a
56+
make clean >> "$LOG_PATH" 2>&1 || { echo "make clean failed; see $LOG_PATH"; exit 1; }
57+
58+
}
59+
60+
#
61+
# Start the build
62+
#
63+
64+
if [[ $ACTION == "clean" ]]; then
65+
echo "=> Cleaning..."
66+
rm ${SYMROOT}/libserval.a 2> /dev/null
67+
rm -rf ${SYMROOT}/libserval-* 2> /dev/null
68+
rm -rf ${SYMROOT}/include 2> /dev/null
69+
exit
70+
fi
71+
72+
if [[ -f ${SYMROOT}/libserval.a ]]; then
73+
echo "libserval has already been built...skipping"
74+
exit
75+
fi
76+
77+
# Generate configure
78+
autoreconf -f -i
79+
80+
mkdir -p ${SYMROOT}
81+
82+
for arch in ${ARCHS}; do
83+
buildIOS "${arch}"
84+
done
85+
86+
echo "=> Building fat binary"
87+
88+
lipo \
89+
"${SYMROOT}/libserval-armv7.a" \
90+
"${SYMROOT}/libserval-armv7s.a" \
91+
"${SYMROOT}/libserval-arm64.a" \
92+
"${SYMROOT}/libserval-i386.a" \
93+
"${SYMROOT}/libserval-x86_64.a" \
94+
-create -output ${SYMROOT}/libserval.a || { echo "failed building fat library"; exit 1; }
95+
96+
echo "=> Copying Headers"
97+
mkdir -p ${SYMROOT}/include
98+
cp *.h ios/confdefs.h ${SYMROOT}/include
99+
100+
echo "=> Done"

ios/confdefs.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// These were taken from the confdefs section of the config.log. This file might have to be regenerated in the future.
2+
3+
#define PACKAGE_NAME "servald"
4+
#define PACKAGE_TARNAME "servald"
5+
#define PACKAGE_VERSION "0.9"
6+
#define PACKAGE_STRING "servald 0.9"
7+
#define PACKAGE_BUGREPORT ""
8+
#define PACKAGE_URL ""
9+
#define STDC_HEADERS 1
10+
#define HAVE_SYS_TYPES_H 1
11+
#define HAVE_SYS_STAT_H 1
12+
#define HAVE_STDLIB_H 1
13+
#define HAVE_STRING_H 1
14+
#define HAVE_MEMORY_H 1
15+
#define HAVE_STRINGS_H 1
16+
#define HAVE_INTTYPES_H 1
17+
#define HAVE_STDINT_H 1
18+
#define HAVE_UNISTD_H 1
19+
#define HAVE_PTHREAD_PRIO_INHERIT 1
20+
#define HAVE_PTHREAD 1
21+
#define HAVE_MATH_H 1
22+
#define HAVE_FLOAT_H 1
23+
#define HAVE_LIBC 1
24+
#define HAVE_GETPEEREID 1
25+
#define HAVE_BCOPY 1
26+
#define HAVE_BZERO 1
27+
#define HAVE_BCMP 1
28+
#define SIZEOF_OFF_T 8
29+
#define HAVE_STDIO_H 1
30+
#define HAVE_ERRNO_H 1
31+
#define HAVE_STDLIB_H 1
32+
#define HAVE_STRINGS_H 1
33+
#define HAVE_UNISTD_H 1
34+
#define HAVE_STRING_H 1
35+
#define HAVE_ARPA_INET_H 1
36+
#define HAVE_SYS_SOCKET_H 1
37+
#define HAVE_SYS_MMAN_H 1
38+
#define HAVE_SYS_TIME_H 1
39+
#define HAVE_SYS_UCRED_H 1
40+
#define HAVE_POLL_H 1
41+
#define HAVE_NETDB_H 1
42+
#define HAVE_NET_IF_H 1
43+
#define HAVE_NETINET_IN_H 1
44+
#define HAVE_IFADDRS_H 1
45+
#define HAVE_SIGNAL_H 1
46+
#define HAVE_SYS_FILIO_H 1
47+
#define HAVE_SYS_SOCKIO_H 1
48+
#define HAVE_SYS_SOCKET_H 1
49+
#define HAVE_SINF 1
50+
#define HAVE_COSF 1
51+
#define HAVE_TANF 1
52+
#define HAVE_ASINF 1
53+
#define HAVE_ACOSF 1
54+
#define HAVE_ATANF 1
55+
#define HAVE_ATAN2F 1
56+
#define HAVE_CEILF 1
57+
#define HAVE_FLOORF 1
58+
#define HAVE_POWF 1
59+
#define HAVE_EXPF 1
60+
#define HAVE_LOGF 1
61+
#define HAVE_LOG10F 1
62+
#define HAVE_STRLCPY 1

0 commit comments

Comments
 (0)