|
| 1 | +PROJECTDIR=$(shell pwd) |
| 2 | + |
| 3 | +BUILD_NUMBER=1 |
| 4 | + |
| 5 | +# Version of packages that will be compiled by this meta-package |
| 6 | +PYTHON_VERSION=3.4.2 |
| 7 | + |
| 8 | +OPENSSL_VERSION_NUMBER=1.0.2 |
| 9 | +OPENSSL_REVISION=d |
| 10 | +OPENSSL_VERSION=$(OPENSSL_VERSION_NUMBER)$(OPENSSL_REVISION) |
| 11 | + |
| 12 | +# 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) |
| 15 | + |
| 16 | + |
| 17 | +all: Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz |
| 18 | + |
| 19 | +# Clean all builds |
| 20 | +clean: |
| 21 | + rm -rf build dist Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz |
| 22 | + |
| 23 | +# Full clean - includes all downloaded products |
| 24 | +distclean: clean |
| 25 | + rm -rf downloads |
| 26 | + |
| 27 | +Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz: dist/python/bin/python$(basename $(PYTHON_VERSION))m |
| 28 | + cd dist && tar zcvf ../Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz python |
| 29 | + |
| 30 | +########################################################################### |
| 31 | +# Working directories |
| 32 | +########################################################################### |
| 33 | + |
| 34 | +downloads: |
| 35 | + mkdir -p downloads |
| 36 | + |
| 37 | +build: |
| 38 | + mkdir -p build |
| 39 | + |
| 40 | +dist: |
| 41 | + mkdir -p dist |
| 42 | + |
| 43 | +# Clean the OpenSSL project |
| 44 | +clean-OpenSSL: |
| 45 | + rm -rf build/openssl-$(OPENSSL_VERSION) |
| 46 | + rm -rf build/OpenSSL |
| 47 | + rm -rf dist/OpenSSL.framework |
| 48 | + |
| 49 | +# Download original OpenSSL source code archive. |
| 50 | +downloads/openssl-$(OPENSSL_VERSION).tgz: downloads |
| 51 | + -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 |
| 52 | + 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 |
| 53 | + |
| 54 | +build/OpenSSL/lib/libssl.a: build downloads/openssl-$(OPENSSL_VERSION).tgz |
| 55 | + # Unpack sources |
| 56 | + cd build && tar zxf ../downloads/openssl-$(OPENSSL_VERSION).tgz |
| 57 | + mkdir -p build/OpenSSL |
| 58 | + # Configure the build |
| 59 | + cd build/openssl-$(OPENSSL_VERSION) && \ |
| 60 | + CC="$(OSX_CC)" ./Configure darwin64-x86_64-cc --openssldir=$(PROJECTDIR)/build/OpenSSL |
| 61 | + # Make the build |
| 62 | + cd build/openssl-$(OPENSSL_VERSION) && CC="$(OSX_CC)" make all |
| 63 | + # Install the build |
| 64 | + cd build/openssl-$(OPENSSL_VERSION) && make install |
| 65 | + |
| 66 | +########################################################################### |
| 67 | +# Python |
| 68 | +########################################################################### |
| 69 | + |
| 70 | +# Clean the Python project |
| 71 | +clean-Python: |
| 72 | + rm -rf build/Python-$(PYTHON_VERSION) |
| 73 | + rm -rf build/python |
| 74 | + rm -rf dist/Python.framework |
| 75 | + |
| 76 | +# Download original Python source code archive. |
| 77 | +downloads/Python-$(PYTHON_VERSION).tgz: downloads |
| 78 | + curl -L https://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz > downloads/Python-$(PYTHON_VERSION).tgz |
| 79 | + |
| 80 | +# build/Python-$(PYTHON_VERSION)/Python.framework: build dist/OpenSSL.framework downloads/Python-$(PYTHON_VERSION).tgz |
| 81 | +dist/python/bin/python$(basename $(PYTHON_VERSION))m: build downloads/Python-$(PYTHON_VERSION).tgz build/OpenSSL/lib/libssl.a |
| 82 | + # Unpack sources |
| 83 | + cd build && tar zxf ../downloads/Python-$(PYTHON_VERSION).tgz |
| 84 | + mkdir -p build/python |
| 85 | + # Apply patches |
| 86 | + cd build/Python-$(PYTHON_VERSION) && cp ../../patch/Python/Setup.embedded Modules/Setup.embedded |
| 87 | + # Configure the build |
| 88 | + cd build/Python-$(PYTHON_VERSION) && ./configure --prefix=$(PROJECTDIR)/dist/python --without-ensurepip |
| 89 | + # Make the build |
| 90 | + cd build/Python-$(PYTHON_VERSION) && make |
| 91 | + # Install the build |
| 92 | + cd build/Python-$(PYTHON_VERSION) && make install |
| 93 | + # Prune out things that aren't needed |
| 94 | + cd dist/python && rm -rf share include |
| 95 | + cd dist/python/bin && rm -rf 2to3* idle* pydoc* python*-config pyvenv* python*m |
| 96 | + cd dist/python/lib && rm -rf libpython$(basename $(PYTHON_VERSION)).a pkgconfig |
| 97 | + cd dist/python/lib/python$(basename $(PYTHON_VERSION)); \ |
| 98 | + rm -rf *test* bsddb curses ensurepip hotshot idlelib tkinter turtledemo wsgiref \ |
| 99 | + config-$(basename $(PYTHON_VERSION))m ctypes/test distutils/tests site-packages sqlite3/test |
| 100 | + # Make sure python always works as an executable name |
| 101 | + cd dist/python/bin && ln -si python$(basename $(PYTHON_VERSION)) python |
0 commit comments