Skip to content
This repository was archived by the owner on Aug 15, 2017. It is now read-only.

Commit 66ca070

Browse files
committed
Updated build to include BZip2 and XZ.
1 parent faa5018 commit 66ca070

File tree

2 files changed

+146
-59
lines changed

2 files changed

+146
-59
lines changed

Makefile

+144-59
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,187 @@
1-
PROJECTDIR=$(shell pwd)
1+
PROJECT_DIR=$(shell pwd)
22

3-
BUILD_NUMBER=2
3+
BUILD_NUMBER=3
44

55
# Version of packages that will be compiled by this meta-package
66
PYTHON_VERSION=3.4.2
7+
PYTHON_VER= $(basename $(PYTHON_VERSION))
78

89
OPENSSL_VERSION_NUMBER=1.0.2
9-
OPENSSL_REVISION=d
10+
OPENSSL_REVISION=f
1011
OPENSSL_VERSION=$(OPENSSL_VERSION_NUMBER)$(OPENSSL_REVISION)
1112

13+
BZIP2_VERSION=1.0.6
14+
15+
XZ_VERSION=5.2.2
16+
1217
# OS/X build commands and flags
13-
OSX_SDK_ROOT=$(shell xcrun --show-sdk-path)
14-
OSX_CC=$(shell xcrun -find clang) --sysroot=$(OSX_SDK_ROOT)
18+
SDK_ROOT=$(shell xcrun --show-sdk-path)
19+
CC=$(shell xcrun -find clang) --sysroot=$(OSX_SDK_ROOT)
20+
21+
# Working directories
1522

23+
OPENSSL_DIR=build/openssl-$(OPENSSL_VERSION)
24+
BZIP2_DIR=build/bzip2-$(BZIP2_VERSION)
25+
XZ_DIR=build/xz-$(XZ_VERSION)
26+
PYTHON_DIR=build/Python-$(PYTHON_VERSION)
1627

17-
all: Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz
28+
OPENSSL_FRAMEWORK=build/OpenSSL.framework
29+
BZIP2_LIB=build/bzip2/lib/libbz2.a
30+
XZ_LIB=build/xz/lib/liblzma.a
31+
32+
all: OSX
1833

1934
# Clean all builds
2035
clean:
21-
rm -rf build dist Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz
36+
rm -rf build dist
2237

2338
# Full clean - includes all downloaded products
2439
distclean: clean
2540
rm -rf downloads
2641

27-
Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz: dist/python/bin/python$(basename $(PYTHON_VERSION))m
28-
echo "Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER)" > dist/VERSION
29-
cd dist && tar zcvf ../Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz python VERSION
42+
downloads: downloads/openssl-$(OPENSSL_VERSION).tgz downloads/bzip2-$(BZIP2_VERSION).tgz downloads/xz-$(XZ_VERSION).tgz downloads/Python-$(PYTHON_VERSION).tgz
3043

3144
###########################################################################
32-
# Working directories
45+
# OpenSSL
46+
# These build instructions adapted from the scripts developed by
47+
# Felix Shchulze (@x2on) https://github.com/x2on/OpenSSL-for-iPhone
3348
###########################################################################
3449

35-
downloads:
36-
mkdir -p downloads
37-
38-
build:
39-
mkdir -p build
40-
41-
dist:
42-
mkdir -p dist
43-
4450
# Clean the OpenSSL project
4551
clean-OpenSSL:
46-
rm -rf build/openssl-$(OPENSSL_VERSION)
47-
rm -rf build/OpenSSL
48-
rm -rf dist/OpenSSL.framework
52+
rm -rf build/*/openssl-$(OPENSSL_VERSION)-* \
53+
build/*/libssl.a build/*/libcrypto.a \
54+
build/*/OpenSSL.framework
4955

5056
# Download original OpenSSL source code archive.
51-
downloads/openssl-$(OPENSSL_VERSION).tgz: downloads
57+
downloads/openssl-$(OPENSSL_VERSION).tgz:
58+
mkdir -p downloads
5259
-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
5360
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
5461

55-
build/OpenSSL/lib/libssl.a: build downloads/openssl-$(OPENSSL_VERSION).tgz
62+
63+
# Unpack OpenSSL
64+
$(OPENSSL_DIR)/Makefile: downloads/openssl-$(OPENSSL_VERSION).tgz
5665
# Unpack sources
57-
cd build && tar zxf ../downloads/openssl-$(OPENSSL_VERSION).tgz
58-
mkdir -p build/OpenSSL
66+
mkdir -p $(OPENSSL_DIR)
67+
tar zxf downloads/openssl-$(OPENSSL_VERSION).tgz --strip-components 1 -C $(OPENSSL_DIR)
5968
# Configure the build
60-
cd build/openssl-$(OPENSSL_VERSION) && \
61-
CC="$(OSX_CC)" ./Configure darwin64-x86_64-cc --openssldir=$(PROJECTDIR)/build/OpenSSL
69+
cd $(OPENSSL_DIR) && \
70+
CC="$(CC)" ./Configure darwin64-x86_64-cc --openssldir=$(PROJECT_DIR)/$(OPENSSL_DIR)
71+
72+
# Build OpenSSL
73+
$(OPENSSL_DIR)/libssl.a $(OPENSSL_DIR)/libcrypto.a: $(OPENSSL_DIR)/Makefile
6274
# Make the build
63-
cd build/openssl-$(OPENSSL_VERSION) && CC="$(OSX_CC)" make all
64-
# Install the build
65-
cd build/openssl-$(OPENSSL_VERSION) && make install
75+
cd $(OPENSSL_DIR) && \
76+
CC="$(CC)" make all
77+
78+
# Build OpenSSL.framework
79+
$(OPENSSL_FRAMEWORK): $(OPENSSL_DIR)/libssl.a $(OPENSSL_DIR)/libcrypto.a
80+
# Create framework directory structure
81+
mkdir -p $(OPENSSL_FRAMEWORK)/Versions/$(OPENSSL_VERSION)
82+
83+
# Copy the headers (use the version from the simulator because reasons)
84+
cp -f -r $(OPENSSL_DIR)/include $(OPENSSL_FRAMEWORK)/Versions/$(OPENSSL_VERSION)/Headers
85+
86+
# Create the fat library
87+
xcrun libtool -no_warning_for_no_symbols -static \
88+
-o $(OPENSSL_FRAMEWORK)/Versions/$(OPENSSL_VERSION)/OpenSSL $^
89+
90+
# Create symlinks
91+
ln -fs $(OPENSSL_VERSION) $(OPENSSL_FRAMEWORK)/Versions/Current
92+
ln -fs Versions/Current/Headers $(OPENSSL_FRAMEWORK)
93+
ln -fs Versions/Current/OpenSSL $(OPENSSL_FRAMEWORK)
94+
95+
###########################################################################
96+
# BZip2
97+
###########################################################################
98+
99+
# Clean the bzip2 project
100+
clean-bzip2:
101+
rm -rf build/*/bzip2-$(BZIP2_VERSION)-* \
102+
build/*/bzip2
103+
104+
# Download original OpenSSL source code archive.
105+
downloads/bzip2-$(BZIP2_VERSION).tgz:
106+
mkdir -p downloads
107+
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
108+
109+
# Unpack BZip2
110+
$(BZIP2_DIR)/Makefile: downloads/bzip2-$(BZIP2_VERSION).tgz
111+
# Unpack sources
112+
mkdir -p $(BZIP2_DIR)
113+
tar zxf downloads/bzip2-$(BZIP2_VERSION).tgz --strip-components 1 -C $(BZIP2_DIR)
114+
# Patch sources to use correct install directory
115+
sed -ie 's#PREFIX=/usr/local#PREFIX=$(PROJECT_DIR)/build/bzip2#' $(BZIP2_DIR)/Makefile
116+
117+
# Build BZip2
118+
build/bzip2/lib/libbz2.a: $(BZIP2_DIR)/Makefile
119+
cd $(BZIP2_DIR) && make install
120+
121+
###########################################################################
122+
# XZ (LZMA)
123+
###########################################################################
124+
125+
# Clean the XZ project
126+
clean-xz:
127+
rm -rf build/*/xz-$(XZ_VERSION)-* \
128+
build/*/xz
129+
130+
# Download original OpenSSL source code archive.
131+
downloads/xz-$(XZ_VERSION).tgz:
132+
mkdir -p downloads
133+
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
134+
135+
# Unpack XZ
136+
$(XZ_DIR)/Makefile: downloads/xz-$(XZ_VERSION).tgz
137+
# Unpack sources
138+
mkdir -p $(XZ_DIR)
139+
tar zxf downloads/xz-$(XZ_VERSION).tgz --strip-components 1 -C $(XZ_DIR)
140+
# Configure the build
141+
cd $(XZ_DIR) && \
142+
./configure --disable-shared --enable-static --prefix=$(PROJECT_DIR)/build/xz
143+
144+
# Build XZ
145+
build/xz/lib/liblzma.a: $(XZ_DIR)/Makefile
146+
cd $(XZ_DIR) && make && make install
66147

67148
###########################################################################
68149
# Python
69150
###########################################################################
70151

71152
# Clean the Python project
72153
clean-Python:
73-
rm -rf build/Python-$(PYTHON_VERSION)
74-
rm -rf build/python
75-
rm -rf dist/Python.framework
154+
rm -rf build/Python-$(PYTHON_VERSION)-host build/*/Python-$(PYTHON_VERSION)-* \
155+
build/*/libpython$(PYTHON_VER).a build/*/pyconfig-*.h \
156+
build/*/Python.framework
76157

77158
# Download original Python source code archive.
78-
downloads/Python-$(PYTHON_VERSION).tgz: downloads
79-
curl -L https://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz > downloads/Python-$(PYTHON_VERSION).tgz
159+
downloads/Python-$(PYTHON_VERSION).tgz:
160+
mkdir -p downloads
161+
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
80162

81-
# build/Python-$(PYTHON_VERSION)/Python.framework: build dist/OpenSSL.framework downloads/Python-$(PYTHON_VERSION).tgz
82-
dist/python/bin/python$(basename $(PYTHON_VERSION))m: build downloads/Python-$(PYTHON_VERSION).tgz build/OpenSSL/lib/libssl.a
83-
# Unpack sources
84-
cd build && tar zxf ../downloads/Python-$(PYTHON_VERSION).tgz
85-
mkdir -p build/python
86-
# Apply patches
87-
cd build/Python-$(PYTHON_VERSION) && cp ../../patch/Python/Setup.embedded Modules/Setup.embedded
88-
# Configure the build
89-
cd build/Python-$(PYTHON_VERSION) && ./configure --prefix=$(PROJECTDIR)/dist/python --without-ensurepip
90-
# Make the build
91-
cd build/Python-$(PYTHON_VERSION) && make
92-
# Install the build
93-
cd build/Python-$(PYTHON_VERSION) && make install
94-
# Prune out things that aren't needed
95-
cd dist/python && rm -rf share include
96-
cd dist/python/bin && rm -rf 2to3* idle* pydoc* python*-config pyvenv* python*m
97-
cd dist/python/lib && rm -rf libpython$(basename $(PYTHON_VERSION)).a pkgconfig
98-
cd dist/python/lib/python$(basename $(PYTHON_VERSION)); \
99-
rm -rf *test* bsddb curses ensurepip hotshot idlelib tkinter turtledemo wsgiref \
100-
config-$(basename $(PYTHON_VERSION))m ctypes/test distutils/tests site-packages sqlite3/test
101-
# Make sure python always works as an executable name
102-
cd dist/python/bin && ln -si python$(basename $(PYTHON_VERSION)) python
163+
# Unpack Python
164+
$(PYTHON_DIR)/Makefile: downloads/Python-$(PYTHON_VERSION).tgz
165+
# Unpack target Python
166+
mkdir -p $(PYTHON_DIR)
167+
tar zxf downloads/Python-$(PYTHON_VERSION).tgz --strip-components 1 -C $(PYTHON_DIR)
168+
# Apply target Python patches
169+
cp -f $(PROJECT_DIR)/patch/Python/Setup.embedded $(PYTHON_DIR)/Modules/Setup.embedded
170+
# Configure target Python
171+
cd $(PYTHON_DIR) && ./configure --without-ensurepip --prefix=$(PROJECT_DIR)/build/python
172+
173+
# Build Python
174+
$(PROJECT_DIR)/build/python/bin/python: build/OpenSSL.framework build/bzip2/lib/libbz2.a build/xz/lib/liblzma.a $(PYTHON_DIR)/Makefile
175+
# Build target Python
176+
cd $(PYTHON_DIR) && make all install
177+
178+
179+
###########################################################################
180+
# Packaging
181+
###########################################################################
182+
183+
dist/Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz: $(PROJECT_DIR)/build/python/bin/python
184+
mkdir -p dist
185+
tar zcvf $@ -C build python
186+
187+
OSX: dist/Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz

patch/Python/Setup.embedded

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#####################################################################
44

55
_bisect _bisectmodule.c
6+
_bz2 _bz2module.c -I$(srcdir)/../bzip2/include -L$(srcdir)/../bzip2/lib -lbz2
67
_codecs_cn cjkcodecs/_codecs_cn.c
78
_codecs_hk cjkcodecs/_codecs_hk.c
89
_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
@@ -18,6 +19,7 @@ _elementtree _elementtree.c \
1819
_heapq _heapqmodule.c
1920
_json _json.c
2021
_lsprof _lsprof.o rotatingtree.c
22+
_lzma _lzmamodule.c -I$(srcdir)/../xz/include -L$(srcdir)/../xz/lib -llzma
2123
_md5 md5module.c
2224
_multibytecodec cjkcodecs/multibytecodec.c
2325
_multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c

0 commit comments

Comments
 (0)