1
1
#
2
2
# Useful targets:
3
3
# - all - build everything
4
+ # - macOS - build everything for macOS
4
5
# - iOS - build everything for iOS
5
6
# - tvOS - build everything for tvOS
6
7
# - watchOS - build everything for watchOS
8
+ # - OpenSSL.framework-macOS - build OpenSSL.framework for macOS
7
9
# - OpenSSL.framework-iOS - build OpenSSL.framework for iOS
8
10
# - OpenSSL.framework-tvOS - build OpenSSL.framework for tvOS
9
11
# - OpenSSL.framework-watchOS - build OpenSSL.framework for watchOS
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
12
+ # - BZip2.framework-macOS - build BZip2.framework for macOS
13
+ # - BZip2.framework-iOS - build BZip2.framework for iOS
14
+ # - BZip2.framework-tvOS - build BZip2.framework for tvOS
15
+ # - BZip2.framework-watchOS - build BZip2.framework for watchOS
16
+ # - XZ.framework-macOS - build XZ.framework for macOS
17
+ # - XZ.framework-iOS - build XZ.framework for iOS
18
+ # - XZ.framework-tvOS - build XZ.framework for tvOS
19
+ # - XZ.framework-watchOS - build XZ.framework for watchOS
20
+ # - Python.framework-macOS - build Python.framework for macOS
16
21
# - Python.framework-iOS - build Python.framework for iOS
17
22
# - Python.framework-tvOS - build Python.framework for tvOS
18
23
# - Python.framework-watchOS - build Python.framework for watchOS
19
- # - Python-host - build host python
20
24
21
25
# Current director
22
26
PROJECT_DIR =$(shell pwd)
23
27
24
- BUILD_NUMBER =5
28
+ BUILD_NUMBER =6
25
29
26
30
# Version of packages that will be compiled by this meta-package
27
31
PYTHON_VERSION =3.4.2
28
32
PYTHON_VER =$(basename $(PYTHON_VERSION ) )
29
33
30
34
OPENSSL_VERSION_NUMBER =1.0.2
31
- OPENSSL_REVISION =f
35
+ OPENSSL_REVISION =h
32
36
OPENSSL_VERSION =$(OPENSSL_VERSION_NUMBER )$(OPENSSL_REVISION )
33
37
34
38
BZIP2_VERSION =1.0.6
35
39
36
40
XZ_VERSION =5.2.2
37
41
38
42
# Supported OS
39
- OS =iOS tvOS watchOS
43
+ OS =macOS iOS tvOS watchOS
44
+
45
+ # macOS targets
46
+ TARGETS-macOS =macosx.x86_64
40
47
41
48
# iOS targets
42
49
TARGETS-iOS =iphonesimulator.x86_64 iphonesimulator.i386 iphoneos.armv7 iphoneos.armv7s iphoneos.arm64
@@ -126,34 +133,20 @@ downloads/xz-$(XZ_VERSION).tgz:
126
133
127
134
# Clean the Python project
128
135
clean-Python :
129
- rm -rf build/Python-$(PYTHON_VERSION ) -host build/* /Python-$(PYTHON_VERSION ) -* \
130
- build/* /libpython$(PYTHON_VER ) .a build/* /pyconfig-* .h \
136
+ rm -rf \
137
+ build/* /Python-$(PYTHON_VERSION ) -* \
138
+ build/* /libpython$(PYTHON_VER ) .a \
139
+ build/* /pyconfig-* .h \
131
140
build/* /Python.framework
132
141
133
142
# Download original Python source code archive.
134
143
downloads/Python-$(PYTHON_VERSION ) .tgz :
135
144
mkdir -p downloads
136
145
if [ ! -e downloads/Python-$( PYTHON_VERSION) .tgz ]; then curl -L https://www.python.org/ftp/python/$( PYTHON_VERSION) /Python-$( PYTHON_VERSION) .tgz > downloads/Python-$( PYTHON_VERSION) .tgz; fi
137
146
138
- PYTHON_DIR-host =build/Python-$(PYTHON_VERSION ) -host
139
- PYTHON_HOST =$(PYTHON_DIR-host ) /dist/bin/python$(PYTHON_VER )
140
-
141
- Python-host : $(PYTHON_HOST )
142
-
143
- # Unpack host Python
144
- $(PYTHON_DIR-host ) /Makefile : downloads/Python-$(PYTHON_VERSION ) .tgz
145
- # Unpack host Python
146
- mkdir -p $(PYTHON_DIR-host )
147
- tar zxf downloads/Python-$(PYTHON_VERSION ) .tgz --strip-components 1 -C $(PYTHON_DIR-host )
148
- # Configure host Python
149
- cd $(PYTHON_DIR-host ) && ./configure --prefix=$(PROJECT_DIR ) /$(PYTHON_DIR-host ) /dist --without-ensurepip
147
+ PYTHON_DIR-macOS =build/macOS/Python-$(PYTHON_VERSION ) -macosx.x86_64
148
+ PYTHON_HOST =$(PYTHON_DIR-macOS ) /dist/lib/libpython$(PYTHON_VER ) .a
150
149
151
- # Build host Python
152
- $(PYTHON_DIR-host ) /dist/bin/python$(PYTHON_VER ) : $(PYTHON_DIR-host ) /Makefile
153
- # Build host Python
154
- make -C $(PYTHON_DIR-host ) all install
155
-
156
- #
157
150
# Build for specified target (from $(TARGETS))
158
151
#
159
152
# Parameters:
@@ -199,12 +192,19 @@ ifeq ($$(findstring iphone,$$(SDK-$1)),)
199
192
# Patch Configure to build for tvOS or watchOS, not iOS
200
193
LC_ALL=C sed -ie 's/-D_REENTRANT:iOS/-D_REENTRANT:$2/' $$(OPENSSL_DIR-$1)/Configure
201
194
endif
195
+
202
196
# Configure the build
197
+ ifeq ($2,macOS)
198
+ cd $$(OPENSSL_DIR-$1) && \
199
+ CC="$$(CC-$1)" \
200
+ ./Configure darwin64-x86_64-cc --openssldir=$(PROJECT_DIR)/$$(OPENSSL_DIR-$1)
201
+ else
203
202
cd $$(OPENSSL_DIR-$1) && \
204
203
CC="$$(CC-$1)" \
205
204
CROSS_TOP="$$(dir $$(SDK_ROOT-$1)).." \
206
205
CROSS_SDK="$$(notdir $$(SDK_ROOT-$1))" \
207
206
./Configure iphoneos-cross no-asm --openssldir=$(PROJECT_DIR)/$$(OPENSSL_DIR-$1)
207
+ endif
208
208
209
209
# Build OpenSSL
210
210
$$(OPENSSL_DIR-$1 ) /libssl.a $$(OPENSSL_DIR-$1 ) /libcrypto.a: $$(OPENSSL_DIR-$1 ) /Makefile
@@ -253,20 +253,29 @@ $$(PYTHON_DIR-$1)/Makefile: downloads/Python-$(PYTHON_VERSION).tgz $(PYTHON_HOST
253
253
tar zxf downloads/Python-$(PYTHON_VERSION ) .tgz --strip-components 1 -C $$(PYTHON_DIR-$1 )
254
254
# Apply target Python patches
255
255
cd $$(PYTHON_DIR-$1 ) && patch -p1 < $(PROJECT_DIR ) /patch/Python/Python.patch
256
- cp -f $( PROJECT_DIR ) /patch/Python/Setup.embedded $$( PYTHON_DIR-$1 ) /Modules/Setup.embedded
256
+
257
257
# Configure target Python
258
- cd $$(PYTHON_DIR-$1 ) && PATH=$(PROJECT_DIR ) /$(PYTHON_DIR-host ) /dist/bin:$(PATH ) ./configure \
258
+ ifeq ($2,macOS)
259
+ cd $$(PYTHON_DIR-$1) && PATH=$(PROJECT_DIR)/$(PYTHON_DIR-macOS)/dist/bin:$(PATH) ./configure \
260
+ CC="$$(CC-$1)" LD="$$(CC-$1)" \
261
+ --prefix=$(PROJECT_DIR)/$$(PYTHON_DIR-$1)/dist \
262
+ --without-pymalloc --without-doc-strings --disable-ipv6 --without-ensurepip \
263
+ $$(PYTHON_CONFIGURE-$2)
264
+ else
265
+ cp -f $(PROJECT_DIR)/patch/Python/Setup.embedded $$(PYTHON_DIR-$1)/Modules/Setup.embedded
266
+ cd $$(PYTHON_DIR-$1) && PATH=$(PROJECT_DIR)/$(PYTHON_DIR-macOS)/dist/bin:$(PATH) ./configure \
259
267
CC="$$(CC-$1)" LD="$$(CC-$1)" \
260
268
--host=$$(MACHINE_DETAILED-$1)-apple-ios --build=x86_64-apple-darwin$(shell uname -r) \
261
269
--prefix=$(PROJECT_DIR)/$$(PYTHON_DIR-$1)/dist \
262
270
--without-pymalloc --without-doc-strings --disable-ipv6 --without-ensurepip \
263
271
ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no \
264
272
$$(PYTHON_CONFIGURE-$2)
273
+ endif
265
274
266
275
# Build Python
267
- $$(PYTHON_DIR-$1 ) /dist/lib/libpython$(PYTHON_VER ) .a: build/$2/OpenSSL.framework build/$2/bzip2/lib/libbz2.a build/$2/xz/lib/liblzma.a $$(PYTHON_DIR-$1 ) /Makefile
276
+ $$(PYTHON_DIR-$1 ) /dist/lib/libpython$(PYTHON_VER ) .a: build/$2/OpenSSL.framework build/$2/BZip2.framework build/$2/XZ.framework $$(PYTHON_DIR-$1 ) /Makefile
268
277
# Build target Python
269
- cd $$(PYTHON_DIR-$1 ) && PATH=$(PROJECT_DIR ) /$(PYTHON_DIR-host ) /dist/bin:$(PATH ) make all install
278
+ cd $$(PYTHON_DIR-$1 ) && PATH=$(PROJECT_DIR ) /$(PYTHON_DIR-macOS ) /dist/bin:$(PATH ) make all install
270
279
271
280
build/$2/$$(pyconfig.h-$1 ) : $$(PYTHON_DIR-$1 ) /dist/include/python$(PYTHON_VER ) /pyconfig.h
272
281
cp -f $$^ $$@
@@ -296,8 +305,8 @@ define build
296
305
$$(foreach target,$$(TARGETS-$1 ) ,$$(eval $$(call build-target,$$(target ) ,$1) ) )
297
306
298
307
OPENSSL_FRAMEWORK-$1=build/$1/OpenSSL.framework
299
- BZIP2_LIB -$1=build/$1/bzip2/lib/libbz2.a
300
- XZ_LIB -$1=build/$1/xz/lib/liblzma.a
308
+ BZIP2_FRAMEWORK -$1=build/$1/BZip2.framework
309
+ XZ_FRAMEWORK -$1=build/$1/XZ.framework
301
310
PYTHON_FRAMEWORK-$1=build/$1/Python.framework
302
311
PYTHON_RESOURCES-$1=$$(PYTHON_FRAMEWORK-$1 ) /Versions/$(PYTHON_VER ) /Resources
303
312
@@ -310,14 +319,14 @@ dist/Python-$(PYTHON_VERSION)-$1-support.b$(BUILD_NUMBER).tar.gz: $$(OPENSSL_FRA
310
319
mkdir -p dist
311
320
tar zcvf $$@ -C build/$1 $$(notdir $$^ )
312
321
322
+ # Build OpenSSL.framework
313
323
OpenSSL.framework-$1: $$(OPENSSL_FRAMEWORK-$1 )
314
324
315
- # Build OpenSSL.framework
316
325
$$(OPENSSL_FRAMEWORK-$1 ) : build/$1/libssl.a build/$1/libcrypto.a
317
326
# Create framework directory structure
318
327
mkdir -p $$(OPENSSL_FRAMEWORK-$1 ) /Versions/$(OPENSSL_VERSION )
319
328
320
- # Copy the headers (use the version from the simulator because reasons)
329
+ # Copy the headers
321
330
cp -f -r $$(OPENSSL_DIR-$$(firstword $$(TARGETS-$1 ) ) ) /include $$(OPENSSL_FRAMEWORK-$1 ) /Versions/$(OPENSSL_VERSION ) /Headers
322
331
323
332
# Create the fat library
@@ -337,17 +346,51 @@ build/$1/libcrypto.a: $$(foreach target,$$(TARGETS-$1),$$(OPENSSL_DIR-$$(target)
337
346
mkdir -p build/$1
338
347
xcrun lipo -create -output $$@ $$^
339
348
340
- BZip2-$1: $$(BZIP2_LIB-$1 )
349
+ # Build BZip2.framework
350
+ BZip2.framework-$1: $$(BZIP2_FRAMEWORK-$1 )
351
+
352
+ $$(BZIP2_FRAMEWORK-$1 ) : build/$1/bzip2/lib/libbz2.a
353
+ # Create framework directory structure
354
+ mkdir -p $$(BZIP2_FRAMEWORK-$1 ) /Versions/$(BZIP2_VERSION )
355
+
356
+ # Copy the headers
357
+ cp -f -r build/$1/bzip2/include $$(BZIP2_FRAMEWORK-$1 ) /Versions/$(BZIP2_VERSION ) /Headers
358
+
359
+ # Create the fat library
360
+ xcrun libtool -no_warning_for_no_symbols -static \
361
+ -o $$(BZIP2_FRAMEWORK-$1 ) /Versions/$(BZIP2_VERSION ) /bzip2 $$^
362
+
363
+ # Create symlinks
364
+ ln -fs $(BZIP2_VERSION ) $$(BZIP2_FRAMEWORK-$1 ) /Versions/Current
365
+ ln -fs Versions/Current/Headers $$(BZIP2_FRAMEWORK-$1 )
366
+ ln -fs Versions/Current/bzip2 $$(BZIP2_FRAMEWORK-$1 )
341
367
342
368
build/$1/bzip2/lib/libbz2.a: $$(foreach target,$$(TARGETS-$1 ) ,$$(BZIP2_DIR-$$(target ) ) /libbz2.a)
343
- mkdir -p build/$1/bzip2/lib
344
- xcrun lipo -create -o $$( BZIP2_LIB-$1 ) $$^
369
+ mkdir -p build/$1
370
+ xcrun lipo -create -o $$@ $$^
345
371
346
- XZ-$1: $$(XZ_LIB-$1 )
372
+ # Build XZ.framework
373
+ XZ.framework-$1: $$(XZ_FRAMEWORK-$1 )
374
+
375
+ $$(XZ_FRAMEWORK-$1 ) : build/$1/xz/lib/liblzma.a
376
+ # Create framework directory structure
377
+ mkdir -p $$(XZ_FRAMEWORK-$1 ) /Versions/$(XZ_VERSION )
378
+
379
+ # Copy the headers
380
+ cp -f -r build/$1/xz/include $$(XZ_FRAMEWORK-$1 ) /Versions/$(XZ_VERSION ) /Headers
381
+
382
+ # Create the fat library
383
+ xcrun libtool -no_warning_for_no_symbols -static \
384
+ -o $$(XZ_FRAMEWORK-$1 ) /Versions/$(XZ_VERSION ) /xz $$^
385
+
386
+ # Create symlinks
387
+ ln -fs $(XZ_VERSION ) $$(XZ_FRAMEWORK-$1 ) /Versions/Current
388
+ ln -fs Versions/Current/Headers $$(XZ_FRAMEWORK-$1 )
389
+ ln -fs Versions/Current/xz $$(XZ_FRAMEWORK-$1 )
347
390
348
391
build/$1/xz/lib/liblzma.a: $$(foreach target,$$(TARGETS-$1 ) ,$$(XZ_DIR-$$(target ) ) /src/liblzma/.libs/liblzma.a)
349
- mkdir -p build/$1/xz/lib
350
- xcrun lipo -create -o $$( XZ_LIB-$1 ) $$^
392
+ mkdir -p build/$1
393
+ xcrun lipo -create -o $$@ $$^
351
394
352
395
Python.framework-$1: $$(PYTHON_FRAMEWORK-$1 )
353
396
0 commit comments