Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit e5b6e44

Browse files
committed
Added BZip2 to the builtins, plus stubs for lzma.
1 parent da32c22 commit e5b6e44

File tree

3 files changed

+488
-2656
lines changed

3 files changed

+488
-2656
lines changed

Makefile

Lines changed: 110 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
#
22
# 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
99
# - 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
1420

1521
# Current director
1622
PROJECT_DIR=$(shell pwd)
@@ -19,32 +25,36 @@ BUILD_NUMBER=1
1925

2026
# Version of packages that will be compiled by this meta-package
2127
PYTHON_VERSION=3.5.1
22-
PYTHON_VER= $(basename $(PYTHON_VERSION))
28+
PYTHON_VER= $(basename $(PYTHON_VERSION))
2329

2430
OPENSSL_VERSION_NUMBER=1.0.2
2531
OPENSSL_REVISION=f
2632
OPENSSL_VERSION=$(OPENSSL_VERSION_NUMBER)$(OPENSSL_REVISION)
2733

34+
BZIP2_VERSION=1.0.6
35+
36+
XZ_VERSION=5.2.2
37+
2838
# Supported OS
29-
OS= iOS tvOS watchOS
39+
OS= iOS tvOS watchOS
3040

3141
# iOS targets
3242
TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.i386 iphoneos.armv7 iphoneos.armv7s iphoneos.arm64
3343
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
3747

3848
# tvOS targets
3949
TARGETS-tvOS=appletvsimulator.x86_64 appletvos.arm64
4050
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
4353

4454
# watchOS targets
4555
TARGETS-watchOS=watchsimulator.i386 watchos.armv7k
4656
CFLAGS-watchOS=-mwatchos-version-min=2.0
47-
CFLAGS-watchos.armv7k= -fembed-bitcode
57+
CFLAGS-watchos.armv7k= -fembed-bitcode
4858
PYTHON_CONFIGURE-watchOS=ac_cv_func_sigaltstack=no
4959

5060
# override machine for arm64
@@ -80,6 +90,35 @@ downloads/openssl-$(OPENSSL_VERSION).tgz:
8090
-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
8191
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
8292

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+
83122
###########################################################################
84123
# Python
85124
###########################################################################
@@ -122,19 +161,21 @@ $(PYTHON_DIR-host)/dist/bin/python$(PYTHON_VER): $(PYTHON_DIR-host)/Makefile
122161
define build-target
123162
ARCH-$1= $$(subst .,,$$(suffix $1))
124163
ifdef MACHINE-$$(ARCH-$1)
125-
MACHINE-$1= $$(MACHINE-$$(ARCH-$1))
164+
MACHINE-$1= $$(MACHINE-$$(ARCH-$1))
126165
else
127-
MACHINE-$1= $$(ARCH-$1)
166+
MACHINE-$1= $$(ARCH-$1)
128167
endif
129-
SDK-$1= $$(basename $1)
168+
SDK-$1= $$(basename $1)
130169

131170
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\
133172
-arch $$(ARCH-$1) --sysroot=$$(SDK_ROOT-$1) $$(CFLAGS-$2) $$(CFLAGS-$1)
134173

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
138179

139180
# Unpack OpenSSL
140181
$$(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
167208
CROSS_SDK="$$(notdir $$(SDK_ROOT-$1))" \
168209
make all
169210

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+
170240
# Unpack Python
171241
$$(PYTHON_DIR-$1)/Makefile: downloads/Python-$(PYTHON_VERSION).tgz $(PYTHON_HOST)
172242
# Unpack target Python
@@ -187,7 +257,7 @@ $$(PYTHON_DIR-$1)/Makefile: downloads/Python-$(PYTHON_VERSION).tgz $(PYTHON_HOST
187257
$$(PYTHON_CONFIGURE-$2)
188258

189259
# 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
191261
# Build target Python
192262
cd $$(PYTHON_DIR-$1) && PATH=$(PROJECT_DIR)/$(PYTHON_DIR-host)/dist/bin:$(PATH) make all install
193263

@@ -219,6 +289,8 @@ define build
219289
$$(foreach target,$$(TARGETS-$1),$$(eval $$(call build-target,$$(target),$1)))
220290

221291
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
222294
PYTHON_FRAMEWORK-$1= build/$1/Python.framework
223295
PYTHON_RESOURCES-$1= $$(PYTHON_FRAMEWORK-$1)/Versions/$(PYTHON_VER)/Resources
224296

@@ -258,6 +330,18 @@ build/$1/libcrypto.a: $$(foreach target,$$(TARGETS-$1),$$(OPENSSL_DIR-$$(target)
258330
mkdir -p build/$1
259331
xcrun lipo -create -output $$@ $$^
260332

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+
261345
Python.framework-$1: $$(PYTHON_FRAMEWORK-$1)
262346

263347
# Build Python.framework

0 commit comments

Comments
 (0)