1
1
#
2
2
# Useful targets:
3
- # - all - build everything
4
- # - iOS - build everything for iOS
5
- # - tvOS - build everything for tvOS
6
- # - watchOS - build everything for watchOS
7
- # - OpenSSL.framework-iOS - build OpenSSL.framework for iOS
8
- # - OpenSSL.framework-tvOS - build OpenSSL.framework for tvOS
3
+ # - all - build everything
4
+ # - iOS - build everything for iOS
5
+ # - tvOS - build everything for tvOS
6
+ # - watchOS - build everything for watchOS
7
+ # - OpenSSL.framework-iOS - build OpenSSL.framework for iOS
8
+ # - OpenSSL.framework-tvOS - build OpenSSL.framework for tvOS
9
9
# - OpenSSL.framework-watchOS - build OpenSSL.framework for watchOS
10
- # - Python.framework-iOS - build Python.framework for iOS
11
- # - Python.framework-tvOS - build Python.framework for tvOS
12
- # - Python.framework-watchOS - build Python.framework for watchOS
13
- # - Python-host - build host python
10
+ # - BZip2-iOS - build BZip2 library for iOS
11
+ # - BZip2-tvOS - build BZip2 library for tvOS
12
+ # - BZip2-watchOS - build BZip2 library for watchOS
13
+ # - XZ-iOS - build XZ library for iOS
14
+ # - XZ-tvOS - build XZ library for tvOS
15
+ # - XZ-watchOS - build XZ library for watchOS
16
+ # - Python.framework-iOS - build Python.framework for iOS
17
+ # - Python.framework-tvOS - build Python.framework for tvOS
18
+ # - Python.framework-watchOS - build Python.framework for watchOS
19
+ # - Python-host - build host python
14
20
15
21
# Current director
16
22
PROJECT_DIR =$(shell pwd)
@@ -19,32 +25,36 @@ BUILD_NUMBER=1
19
25
20
26
# Version of packages that will be compiled by this meta-package
21
27
PYTHON_VERSION =3.5.1
22
- PYTHON_VER = $(basename $(PYTHON_VERSION ) )
28
+ PYTHON_VER = $(basename $(PYTHON_VERSION ) )
23
29
24
30
OPENSSL_VERSION_NUMBER =1.0.2
25
31
OPENSSL_REVISION =f
26
32
OPENSSL_VERSION =$(OPENSSL_VERSION_NUMBER )$(OPENSSL_REVISION )
27
33
34
+ BZIP2_VERSION =1.0.6
35
+
36
+ XZ_VERSION =5.2.2
37
+
28
38
# Supported OS
29
- OS = iOS tvOS watchOS
39
+ OS = iOS tvOS watchOS
30
40
31
41
# iOS targets
32
42
TARGETS-iOS =iphonesimulator.x86_64 iphonesimulator.i386 iphoneos.armv7 iphoneos.armv7s iphoneos.arm64
33
43
CFLAGS-iOS=-miphoneos-version-min =7.0
34
- CFLAGS-iphoneos.armv7 = -fembed-bitcode
35
- CFLAGS-iphoneos.armv7s = -fembed-bitcode
36
- CFLAGS-iphoneos.arm64 = -fembed-bitcode
44
+ CFLAGS-iphoneos.armv7 = -fembed-bitcode
45
+ CFLAGS-iphoneos.armv7s = -fembed-bitcode
46
+ CFLAGS-iphoneos.arm64 = -fembed-bitcode
37
47
38
48
# tvOS targets
39
49
TARGETS-tvOS =appletvsimulator.x86_64 appletvos.arm64
40
50
CFLAGS-tvOS=-mtvos-version-min =9.0
41
- CFLAGS-appletvos.arm64 = -fembed-bitcode
42
- PYTHON_CONFIGURE-tvOS = ac_cv_func_sigaltstack=no
51
+ CFLAGS-appletvos.arm64 = -fembed-bitcode
52
+ PYTHON_CONFIGURE-tvOS = ac_cv_func_sigaltstack=no
43
53
44
54
# watchOS targets
45
55
TARGETS-watchOS =watchsimulator.i386 watchos.armv7k
46
56
CFLAGS-watchOS=-mwatchos-version-min =2.0
47
- CFLAGS-watchos.armv7k = -fembed-bitcode
57
+ CFLAGS-watchos.armv7k = -fembed-bitcode
48
58
PYTHON_CONFIGURE-watchOS=ac_cv_func_sigaltstack =no
49
59
50
60
# override machine for arm64
@@ -80,6 +90,35 @@ downloads/openssl-$(OPENSSL_VERSION).tgz:
80
90
-if [ ! -e downloads/openssl-$( OPENSSL_VERSION) .tgz ]; then curl --fail -L http://openssl.org/source/openssl-$(OPENSSL_VERSION ) .tar.gz -o downloads/openssl-$(OPENSSL_VERSION ) .tgz; fi
81
91
if [ ! -e downloads/openssl-$( OPENSSL_VERSION) .tgz ]; then curl --fail -L http://openssl.org/source/old/$( OPENSSL_VERSION_NUMBER) /openssl-$( OPENSSL_VERSION) .tar.gz -o downloads/openssl-$( OPENSSL_VERSION) .tgz; fi
82
92
93
+
94
+ # ##########################################################################
95
+ # BZip2
96
+ # ##########################################################################
97
+
98
+ # Clean the bzip2 project
99
+ clean-bzip2 :
100
+ rm -rf build/* /bzip2-$(BZIP2_VERSION ) -* \
101
+ build/* /bzip2
102
+
103
+ # Download original OpenSSL source code archive.
104
+ downloads/bzip2-$(BZIP2_VERSION ) .tgz :
105
+ mkdir -p downloads
106
+ if [ ! -e downloads/bzip2-$( BZIP2_VERSION) .tgz ]; then curl --fail -L http://www.bzip.org/$( BZIP2_VERSION) /bzip2-$( BZIP2_VERSION) .tar.gz -o downloads/bzip2-$( BZIP2_VERSION) .tgz; fi
107
+
108
+ # ##########################################################################
109
+ # XZ (LZMA)
110
+ # ##########################################################################
111
+
112
+ # Clean the XZ project
113
+ clean-xz :
114
+ rm -rf build/* /xz-$(XZ_VERSION ) -* \
115
+ build/* /xz
116
+
117
+ # Download original OpenSSL source code archive.
118
+ downloads/xz-$(XZ_VERSION ) .tgz :
119
+ mkdir -p downloads
120
+ if [ ! -e downloads/xz-$( XZ_VERSION) .tgz ]; then curl --fail -L http://tukaani.org/xz/xz-$( XZ_VERSION) .tar.gz -o downloads/xz-$( XZ_VERSION) .tgz; fi
121
+
83
122
# ##########################################################################
84
123
# Python
85
124
# ##########################################################################
@@ -122,19 +161,21 @@ $(PYTHON_DIR-host)/dist/bin/python$(PYTHON_VER): $(PYTHON_DIR-host)/Makefile
122
161
define build-target
123
162
ARCH-$1= $$(subst .,,$$(suffix $1) )
124
163
ifdef MACHINE-$$(ARCH-$1)
125
- MACHINE-$1 = $$(MACHINE-$$(ARCH-$1 ) )
164
+ MACHINE-$1 = $$(MACHINE-$$(ARCH-$1 ) )
126
165
else
127
- MACHINE-$1 = $$(ARCH-$1 )
166
+ MACHINE-$1 = $$(ARCH-$1 )
128
167
endif
129
- SDK-$1= $$(basename $1)
168
+ SDK-$1= $$(basename $1)
130
169
131
170
SDK_ROOT-$1= $$(shell xcrun --sdk $$(SDK-$1 ) --show-sdk-path)
132
- CC-$1= xcrun --sdk $$(SDK-$1 ) clang\
171
+ CC-$1= xcrun --sdk $$(SDK-$1 ) clang\
133
172
-arch $$(ARCH-$1 ) --sysroot=$$(SDK_ROOT-$1 ) $$(CFLAGS-$2 ) $$(CFLAGS-$1 )
134
173
135
- OPENSSL_DIR-$1= build/$2/openssl-$(OPENSSL_VERSION ) -$1
136
- PYTHON_DIR-$1= build/$2/Python-$(PYTHON_VERSION ) -$1
137
- pyconfig.h-$1= pyconfig-$$(ARCH-$1 ) .h
174
+ OPENSSL_DIR-$1= build/$2/openssl-$(OPENSSL_VERSION ) -$1
175
+ BZIP2_DIR-$1= build/$2/bzip2-$(BZIP2_VERSION ) -$1
176
+ XZ_DIR-$1= build/$2/xz-$(XZ_VERSION ) -$1
177
+ PYTHON_DIR-$1= build/$2/Python-$(PYTHON_VERSION ) -$1
178
+ pyconfig.h-$1= pyconfig-$$(ARCH-$1 ) .h
138
179
139
180
# Unpack OpenSSL
140
181
$$(OPENSSL_DIR-$1 ) /Makefile: downloads/openssl-$(OPENSSL_VERSION ) .tgz
@@ -167,6 +208,35 @@ $$(OPENSSL_DIR-$1)/libssl.a $$(OPENSSL_DIR-$1)/libcrypto.a: $$(OPENSSL_DIR-$1)/M
167
208
CROSS_SDK="$$(notdir $$(SDK_ROOT-$1 ) ) " \
168
209
make all
169
210
211
+ # Unpack BZip2
212
+ $$(BZIP2_DIR-$1 ) /Makefile: downloads/bzip2-$(BZIP2_VERSION ) .tgz
213
+ # Unpack sources
214
+ mkdir -p $$(BZIP2_DIR-$1 )
215
+ tar zxf downloads/bzip2-$(BZIP2_VERSION ) .tgz --strip-components 1 -C $$(BZIP2_DIR-$1 )
216
+ # Patch sources to use correct compiler
217
+ sed -ie 's# CC=gcc#CC=$$(CC-$1)#' $$(BZIP2_DIR-$1)/Makefile
218
+ # Patch sources to use correct install directory
219
+ sed -ie 's# PREFIX=/usr/local#PREFIX=$(PROJECT_DIR)/build/$2/bzip2#' $$(BZIP2_DIR-$1)/Makefile
220
+
221
+ # Build BZip2
222
+ $$(BZIP2_DIR-$1 ) /libbz2.a: $$(BZIP2_DIR-$1 ) /Makefile
223
+ cd $$(BZIP2_DIR-$1 ) && make install
224
+
225
+ # Unpack XZ
226
+ $$(XZ_DIR-$1 ) /Makefile: downloads/xz-$(XZ_VERSION ) .tgz
227
+ # Unpack sources
228
+ mkdir -p $$(XZ_DIR-$1 )
229
+ tar zxf downloads/xz-$(XZ_VERSION ) .tgz --strip-components 1 -C $$(XZ_DIR-$1 )
230
+ # Configure the build
231
+ cd $$(XZ_DIR-$1 ) && ./configure \
232
+ CC="$$(CC-$1 ) " \
233
+ --host=$$(MACHINE-$1 ) -apple-ios --build=x86_64-apple-darwin$(shell uname -r) \
234
+ --prefix=$(PROJECT_DIR ) /build/$2/xz
235
+
236
+ # Build XZ
237
+ $$(XZ_DIR-$1 ) /src/liblzma/.libs/liblzma.a: $$(XZ_DIR-$1 ) /Makefile
238
+ cd $$(XZ_DIR-$1 ) && make && make install
239
+
170
240
# Unpack Python
171
241
$$(PYTHON_DIR-$1 ) /Makefile: downloads/Python-$(PYTHON_VERSION ) .tgz $(PYTHON_HOST )
172
242
# Unpack target Python
@@ -187,7 +257,7 @@ $$(PYTHON_DIR-$1)/Makefile: downloads/Python-$(PYTHON_VERSION).tgz $(PYTHON_HOST
187
257
$$(PYTHON_CONFIGURE-$2 )
188
258
189
259
# Build Python
190
- $$(PYTHON_DIR-$1 ) /dist/lib/libpython$(PYTHON_VER ) .a: $$(PYTHON_DIR-$1 ) /Makefile build/$2/OpenSSL.framework
260
+ $$(PYTHON_DIR-$1 ) /dist/lib/libpython$(PYTHON_VER ) .a: $$(PYTHON_DIR-$1 ) /Makefile build/$2/OpenSSL.framework build/$2/bzip2/lib/libbz2.a
191
261
# Build target Python
192
262
cd $$(PYTHON_DIR-$1 ) && PATH=$(PROJECT_DIR ) /$(PYTHON_DIR-host ) /dist/bin:$(PATH ) make all install
193
263
@@ -219,6 +289,8 @@ define build
219
289
$$(foreach target,$$(TARGETS-$1 ) ,$$(eval $$(call build-target,$$(target ) ,$1) ) )
220
290
221
291
OPENSSL_FRAMEWORK-$1= build/$1/OpenSSL.framework
292
+ BZIP2_LIB-$1= build/$1/bzip2/lib/libbz2.a
293
+ XZ_LIB-$1= build/$1/xz/lib/liblzma.a
222
294
PYTHON_FRAMEWORK-$1= build/$1/Python.framework
223
295
PYTHON_RESOURCES-$1= $$(PYTHON_FRAMEWORK-$1 ) /Versions/$(PYTHON_VER ) /Resources
224
296
@@ -258,6 +330,18 @@ build/$1/libcrypto.a: $$(foreach target,$$(TARGETS-$1),$$(OPENSSL_DIR-$$(target)
258
330
mkdir -p build/$1
259
331
xcrun lipo -create -output $$@ $$^
260
332
333
+ BZip2-$1: $$(BZIP2_LIB-$1 )
334
+
335
+ build/$1/bzip2/lib/libbz2.a: $$(foreach target,$$(TARGETS-$1 ) ,$$(BZIP2_DIR-$$(target ) ) /libbz2.a)
336
+ mkdir -p build/$1/bzip2/lib
337
+ xcrun lipo -create -o $$(BZIP2_LIB-$1 ) $$^
338
+
339
+ XZ-$1: $$(XZ_LIB-$1 )
340
+
341
+ build/$1/xz/lib/liblzma.a: $$(foreach target,$$(TARGETS-$1 ) ,$$(XZ_DIR-$$(target ) ) /src/liblzma/.libs/liblzma.a)
342
+ mkdir -p build/$1/xz/lib
343
+ xcrun lipo -create -o $$(XZ_LIB-$1 ) $$^
344
+
261
345
Python.framework-$1: $$(PYTHON_FRAMEWORK-$1 )
262
346
263
347
# Build Python.framework
0 commit comments