Skip to content

Commit

Permalink
Merge pull request #81 - iOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
quixotique committed Oct 25, 2016
2 parents 62f2b44 + 053706b commit 66ca892
Show file tree
Hide file tree
Showing 10 changed files with 1,784 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ test.*.log
/testlog/
/coverage_html/
*.info
build
ios/libserval.xcodeproj/project.xcworkspace/xcuserdata/
ios/libserval.xcodeproj/xcuserdata/
.DS_Store
100 changes: 100 additions & 0 deletions ios/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/sh

# Created by James Moore on 3/25/14.
# Copyright (c) 2014 The Serval Project. All rights reserved.

# set -x

# if we're building inside of xcode we need to back up a level
if [[ -n $DEVELOPER_DIR ]]; then
cd ..
pwd
fi

# Add the homebrew tools to the path since automake no longer is apart of Xcode
PATH=/usr/local/bin:$PATH
ARCHS="armv7 armv7s arm64 i386 x86_64"
SDK_VERSION=8.0
SDK_TARGET=7.1
PREFIX=$(pwd)/build
DEVELOPER=`xcode-select -print-path`
SYMROOT="build"

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; }

buildIOS()
{
ARCH=$1
HOST=""
PREFIX="/tmp/servald"

if [[ "${ARCH}" == "i386" ]]; then
PLATFORM="iPhoneSimulator"
HOST="--host=i386-apple-darwin"
elif [[ "${ARCH}" == "x86_64" ]]; then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
HOST="--host=arm-apple-darwin"
PREFIX="/Library/servald"
fi

CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
SDKROOT="${CROSS_TOP}/SDKs/${CROSS_SDK}"

export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot $SDKROOT -I$SDKROOT/usr/include -miphoneos-version-min=${SDK_TARGET}"
export CC="clang"

echo "=> Building libserval for ${PLATFORM} ${SDK_TARGET} ${ARCH}"

LOG_PATH="${SYMROOT}/libserval-${ARCH}.log"
./configure $HOST --prefix $PREFIX &> "$LOG_PATH" || { echo "configure failed; see $LOG_PATH"; exit 1; }

make libserval.a >> "$LOG_PATH" 2>&1 || { echo "make failed; see $LOG_PATH"; exit 1; }
cp libserval.a ${SYMROOT}/libserval-${ARCH}.a
make clean >> "$LOG_PATH" 2>&1 || { echo "make clean failed; see $LOG_PATH"; exit 1; }

}

#
# Start the build
#

if [[ $ACTION == "clean" ]]; then
echo "=> Cleaning..."
rm ${SYMROOT}/libserval.a 2> /dev/null
rm -rf ${SYMROOT}/libserval-* 2> /dev/null
rm -rf ${SYMROOT}/include 2> /dev/null
exit
fi

if [[ -f ${SYMROOT}/libserval.a ]]; then
echo "libserval has already been built...skipping"
exit
fi

# Generate configure
autoreconf -f -i

mkdir -p ${SYMROOT}

for arch in ${ARCHS}; do
buildIOS "${arch}"
done

echo "=> Building fat binary"

lipo \
"${SYMROOT}/libserval-armv7.a" \
"${SYMROOT}/libserval-armv7s.a" \
"${SYMROOT}/libserval-arm64.a" \
"${SYMROOT}/libserval-i386.a" \
"${SYMROOT}/libserval-x86_64.a" \
-create -output ${SYMROOT}/libserval.a || { echo "failed building fat library"; exit 1; }

echo "=> Copying Headers"
mkdir -p ${SYMROOT}/include
cp *.h ios/confdefs.h ${SYMROOT}/include

echo "=> Done"
62 changes: 62 additions & 0 deletions ios/confdefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// These were taken from the confdefs section of the config.log. This file might have to be regenerated in the future.

#define PACKAGE_NAME "servald"
#define PACKAGE_TARNAME "servald"
#define PACKAGE_VERSION "0.9"
#define PACKAGE_STRING "servald 0.9"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_PTHREAD_PRIO_INHERIT 1
#define HAVE_PTHREAD 1
#define HAVE_MATH_H 1
#define HAVE_FLOAT_H 1
#define HAVE_LIBC 1
#define HAVE_GETPEEREID 1
#define HAVE_BCOPY 1
#define HAVE_BZERO 1
#define HAVE_BCMP 1
#define SIZEOF_OFF_T 8
#define HAVE_STDIO_H 1
#define HAVE_ERRNO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1
#define HAVE_UNISTD_H 1
#define HAVE_STRING_H 1
#define HAVE_ARPA_INET_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_MMAN_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_UCRED_H 1
#define HAVE_POLL_H 1
#define HAVE_NETDB_H 1
#define HAVE_NET_IF_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_IFADDRS_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_SYS_FILIO_H 1
#define HAVE_SYS_SOCKIO_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SINF 1
#define HAVE_COSF 1
#define HAVE_TANF 1
#define HAVE_ASINF 1
#define HAVE_ACOSF 1
#define HAVE_ATANF 1
#define HAVE_ATAN2F 1
#define HAVE_CEILF 1
#define HAVE_FLOORF 1
#define HAVE_POWF 1
#define HAVE_EXPF 1
#define HAVE_LOGF 1
#define HAVE_LOG10F 1
#define HAVE_STRLCPY 1
Loading

0 comments on commit 66ca892

Please sign in to comment.