-
Notifications
You must be signed in to change notification settings - Fork 51
/
libxml2.sh
175 lines (153 loc) · 6.34 KB
/
libxml2.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env bash
#
# libxml2
# XML parser
# http://xmlsoft.org/index.html
#
# uses an automake build system
FORMULA_TYPES=( "osx" "vs" "ios" "tvos" "android" "emscripten" )
# define the version by sha
VER=2.9.4
# download the source code and unpack it into LIB_NAME
function download() {
wget ftp://xmlsoft.org/libxml2/libxml2-${VER}.tar.gz
tar xzf libxml2-${VER}.tar.gz
mv libxml2-${VER} libxml2
rm libxml2-${VER}.tar.gz
}
# prepare the build environment, executed inside the lib src dir
function prepare() {
if [ "$TYPE" == "android" ]; then
cp $FORMULA_DIR/glob.h .
fi
if [ "$TYPE" == "vs" ]; then
cp $FORMULA_DIR/vs2015/*.h include/libxml/
cp -r $FORMULA_DIR/vs2015/* win32/VC10/
fi
}
# executed inside the lib src dir
function build() {
if [ "$TYPE" == "vs" ] ; then
unset TMP
unset TEMP
cd win32/VC10
if [ $ARCH == 32 ] ; then
vs-build libxml2.vcxproj Build "Release|Win32"
else
vs-build libcurl.vcxproj Build "Release|x64"
fi
elif [ "$TYPE" == "android" ]; then
source ../../android_configure.sh $ABI
wget http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
wget http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
if [ "$ARCH" == "armv7" ]; then
HOST=armv7a-linux-android
elif [ "$ARCH" == "x86" ]; then
HOST=x86-linux-android
fi
./configure --host=$HOST --without-lzma --without-zlib --disable-shared --enable-static --with-sysroot=$SYSROOT --without-ftp --without-html --without-http --without-iconv --without-legacy --without-modules --without-output --without-python
make clean
make -j${PARALLEL_MAKE}
elif [ "$TYPE" == "osx" ]; then
export CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
./configure --without-lzma --without-zlib --disable-shared --enable-static --without-ftp --without-html --without-http --without-iconv --without-legacy --without-modules --without-output --without-python
make clean
make -j${PARALLEL_MAKE}
elif [ "$TYPE" == "emscripten" ]; then
wget http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
wget http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
emconfigure ./configure --without-lzma --without-zlib --disable-shared --enable-static --without-ftp --without-html --without-http --without-iconv --without-legacy --without-modules --without-output --without-python
make clean
make -j${PARALLEL_MAKE}
elif [ "$TYPE" == "osx" ]; then
export CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
export LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=${OSX_MIN_SDK_VER}"
./configure --without-lzma --without-zlib --disable-shared --enable-static --without-ftp --without-html --without-http --without-iconv --without-legacy --without-modules --without-output --without-python
make clean
make -j${PARALLEL_MAKE}
elif [ "$TYPE" == "ios" ] || [ "$TYPE" == "tvos" ]; then
if [ "${TYPE}" == "tvos" ]; then
IOS_ARCHS="x86_64 arm64"
elif [ "$TYPE" == "ios" ]; then
IOS_ARCHS="i386 x86_64 armv7 arm64" #armv7s
fi
for IOS_ARCH in ${IOS_ARCHS}; do
echo
echo
echo "Compiling for $IOS_ARCH"
source ../../ios_configure.sh $TYPE $IOS_ARCH
local PREFIX=$PWD/build/$TYPE/$IOS_ARCH
./configure --prefix=$PREFIX --host=$HOST --target=$HOST --without-lzma --without-zlib --disable-shared --enable-static --without-ftp --without-html --without-http --without-iconv --without-legacy --without-modules --without-output --without-python
make clean
make -j${PARALLEL_MAKE}
make install
done
cp -r build/$TYPE/arm64/* build/$TYPE/
if [ "$TYPE" == "ios" ]; then
lipo -create build/$TYPE/i386/lib/libxml2.a \
build/$TYPE/x86_64/lib/libxml2.a \
build/$TYPE/armv7/lib/libxml2.a \
build/$TYPE/arm64/lib/libxml2.a \
-output build/$TYPE/lib/libxml2.a
elif [ "$TYPE" == "tvos" ]; then
lipo -create build/$TYPE/x86_64/lib/libxml2.a \
build/$TYPE/arm64/lib/libxml2.a \
-output build/$TYPE/lib/libxml2.a
fi
else
echo "building other for $TYPE"
if [ $CROSSCOMPILING -eq 1 ]; then
source ../../${TYPE}_configure.sh
export LDFLAGS=-L$SYSROOT/usr/lib
export CFLAGS=-I$SYSROOT/usr/include
fi
local OPENSSL_DIR=$BUILD_DIR/openssl/build/$TYPE
./buildconf
wget http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
wget http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
./configure --with-ssl=$OPENSSL_DIR --enable-static --disable-shared
make clean
make -j${PARALLEL_MAKE}
fi
}
# executed inside the lib src dir, first arg $1 is the dest libs dir root
function copy() {
# prepare headers directory if needed
mkdir -p $1/include/libxml
# prepare libs directory if needed
mkdir -p $1/lib/$TYPE
cp -Rv include/libxml/* $1/include/libxml/
if [ "$TYPE" == "vs" ] ; then
if [ $ARCH == 32 ] ; then
mkdir -p $1/lib/$TYPE/Win32
cp -v "win32/VC10/Release/libxml2.lib" $1/lib/$TYPE/Win32/
elif [ $ARCH == 64 ] ; then
mkdir -p $1/lib/$TYPE/x64
cp -v "win32/VC10/Release/libxml2.lib" $1/lib/$TYPE/x64/
fi
elif [ "$TYPE" == "osx" ] || [ "$TYPE" == "ios" ] || [ "$TYPE" == "tvos" ]; then
# copy lib
cp -Rv .libs/libxml2.a $1/lib/$TYPE/xml2.a
elif [ "$TYPE" == "android" ] ; then
mkdir -p $1/lib/$TYPE/$ABI
# copy lib
cp -Rv .libs/libxml2.a $1/lib/$TYPE/$ABI/libxml2.a
elif [ "$TYPE" == "emscripten" ] ; then
mkdir -p $1/lib/$TYPE
# copy lib
cp -Rv .libs/libxml2.a $1/lib/$TYPE/libxml2.a
fi
# copy license file
rm -rf $1/license # remove any older files if exists
mkdir -p $1/license
cp -v Copyright $1/license/
}
# executed inside the lib src dir
function clean() {
if [ "$TYPE" == "vs" ] ; then
rm -f *.lib
else
make clean
fi
}