This repository was archived by the owner on Jun 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild-libgnutls.sh
More file actions
executable file
·140 lines (121 loc) · 5.23 KB
/
build-libgnutls.sh
File metadata and controls
executable file
·140 lines (121 loc) · 5.23 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# Automatic build script for gnutls
# for iPhoneOS and iPhoneSimulator
#
# Created by Felix Schulze on 30.01.11.
# Copyright 2010 Felix Schulze. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
# Change values here
#
VERSION="2.12.23"
SDKVERSION="6.1"
#
###########################################################################
#
# Don't change anything here
CURRENTPATH=`pwd`
ARCHS="i386 armv7 armv7s"
DEVELOPER=`xcode-select -print-path`
##########
set -e
if [ ! -e gnutls-${VERSION}.tar.bz2 ]; then
echo "Downloading gnutls-${VERSION}.tar.bz2"
curl -O ftp://ftp.gnutls.org/gcrypt/gnutls/v2.12/gnutls-${VERSION}.tar.bz2
else
echo "Using gnutls-${VERSION}.tar.bz2"
fi
if [ -f ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libgcrypt.a ];
then
echo "Using libgcrypt"
else
echo "Please build libgcrypt first"
exit 1
fi
mkdir -p bin
mkdir -p lib
mkdir -p src
for ARCH in ${ARCHS}
do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi
tar zxvf gnutls-${VERSION}.tar.bz2 -C src
cd src/gnutls-${VERSION}
echo "Building gnutls for ${PLATFORM} ${SDKVERSION} ${ARCH}"
if [ "${VERSION}" == "2.8.6" ];
then
echo "Version 2.8.6 detected - Patch needed"
echo "patching file lib/gnutls_global.c"
sed -ie "s!gnutls_log_func _gnutls_log_func;!gnutls_log_func _gnutls_log_func = NULL;!" "lib/gnutls_global.c"
fi
if [ "${VERSION}" == "2.10.4" ];
then
echo "Version 2.10.4 detected - Patch needed"
cd src
patch -R < ../../../gnutls-patch-${VERSION}.diff
cd ..
fi
if [ "${VERSION}" == "2.10.5" ];
then
echo "Version 2.10.5 detected - Patch needed"
cd src
patch -R < ../../../gnutls-patch-2.10.4.diff
cd ..
fi
if [ "${VERSION}" == "2.12.19" ] || [ "${VERSION}" == "2.12.23" ];
then
EXTRA_CONFIGURE_FLAGS="--without-p11-kit"
echo "Version ${VERSION} detected - Setting extra configure flags: " ${EXTRA_CONFIGURE_FLAGS}
fi
echo "Please stand by..."
export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${SDKVERSION}.sdk"
export LD=${DEVROOT}/usr/bin/ld
if [ "${ARCH}" == "i386" ];
then
export CC=${DEVROOT}/usr/bin/gcc
export CPP=${DEVROOT}/usr/bin/cpp
export CXX=${DEVROOT}/usr/bin/g++
export CXXCPP=$DEVROOT/usr/bin/cpp
else
export CC=${DEVROOT}/usr/bin/gcc
export CXX=${DEVROOT}/usr/bin/g++
fi
export AR=${DEVROOT}/usr/bin/ar
export AS=${DEVROOT}/usr/bin/as
export NM=${DEVROOT}/usr/bin/nm
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -L${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib"
export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/include"
export CXXFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/include"
mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-gnutls-${VERSION}.log"
./configure --host=${ARCH}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" ${EXTRA_CONFIGURE_FLAGS} --enable-shared=no --with-libgcrypt --with-libgcrypt-prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" >> "${LOG}" 2>&1
make >> "${LOG}" 2>&1
make install >> "${LOG}" 2>&1
cd ${CURRENTPATH}
rm -rf src/gnutls-${VERSION}
done
echo "Build library..."
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libgnutls.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libgnutls.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libgnutls.a -output ${CURRENTPATH}/lib/libgnutls.a
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libgnutls-extra.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libgnutls-extra.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libgnutls-extra.a -output ${CURRENTPATH}/lib/libgnutls-extra.a
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libgnutls-openssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libgnutls-openssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libgnutls-openssl.a -output ${CURRENTPATH}/lib/libgnutls-openssl.a
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libgnutlsxx.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libgnutlsxx.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libgnutlsxx.a -output ${CURRENTPATH}/lib/libgnutlsxx.a
cp -R ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/include/gnutls ${CURRENTPATH}/include/
echo "Building done."