1
1
PROJECTDIR =$(shell pwd)
2
2
3
3
# iOS Build variables.
4
- SDKDESCRIPTION =$(shell xcodebuild -showsdks | fgrep "iphoneos" | tail -n 1)
5
- SDKVER =$(word 2, $(SDKDESCRIPTION ) )
6
- DEVROOT =$(shell xcode-select -print-path) /Platforms/iPhoneOS.platform/Developer
7
- IOSSDKROOT =$(DEVROOT ) /SDKs/iPhoneOS$(SDKVER ) .sdk
8
-
9
4
OSX_SDK_ROOT =$(shell xcrun --sdk macosx --show-sdk-path)
10
5
11
6
# Version of packages that will be compiled by this meta-package
12
7
PYTHON_VERSION =2.7.1
13
8
FFI_VERSION =3.0.13
14
9
15
- # ARM build flags
16
- ARM_CC =$(shell xcrun -find -sdk iphoneos clang)
17
- ARM_AR =$(shell xcrun -find -sdk iphoneos ar)
18
- ARM_LD =$(shell xcrun -find -sdk iphoneos ld)
10
+ # IPHONE build commands and flags
11
+ IPHONE_SDK_ROOT =$(shell xcrun --sdk iphoneos --show-sdk-path)
12
+ IPHONE_CC =$(shell xcrun -find -sdk iphoneos clang)
13
+ IPHONE_LD =$(shell xcrun -find -sdk iphoneos ld)
14
+ IPHONE_CFLAGS =-arch armv7 -pipe -no-cpp-precomp -isysroot $(IPHONE_SDK_ROOT ) -miphoneos-version-min=4.0
15
+ IPHONE_LDFLAGS =-arch armv7 -isysroot $(IPHONE_SDK_ROOT ) -miphoneos-version-min=4.0
19
16
20
- ARM_CFLAGS =-arch armv7 -pipe -no-cpp-precomp -isysroot $(IOSSDKROOT ) -miphoneos-version-min=$(SDKVER )
21
- ARM_LDFLAGS =-arch armv7 -isysroot $(IOSSDKROOT ) -miphoneos-version-min=$(SDKVER )
17
+ # IPHONESIMULATOR build commands and flags
18
+ IPHONESIMULATOR_SDK_ROOT =$(shell xcrun --sdk iphonesimulator --show-sdk-path)
19
+ IPHONESIMULATOR_CC =$(shell xcrun -find -sdk iphonesimulator clang)
20
+ IPHONESIMULATOR_LD =$(shell xcrun -find -sdk iphonesimulator ld)
21
+ IPHONESIMULATOR_CFLAGS =-arch i386 -pipe -no-cpp-precomp -isysroot $(IPHONESIMULATOR_SDK_ROOT ) -miphoneos-version-min=4.0
22
+ IPHONESIMULATOR_LDFLAGS =-arch i386 -isysroot $(IPHONESIMULATOR_SDK_ROOT ) -miphoneos-version-min=4.0
22
23
23
24
24
25
all : working-dirs build/ffi.framework build/Python.framework
@@ -80,6 +81,7 @@ build/ffi.framework: src/libffi-$(FFI_VERSION)
80
81
clean-Python :
81
82
rm -rf src/Python-$(PYTHON_VERSION )
82
83
rm -rf build/Python.framework
84
+ rm -rf build/python
83
85
84
86
# Down original Python source code archive.
85
87
downloads/Python-$(PYTHON_VERSION ) .tar.bz2 :
@@ -92,60 +94,105 @@ src/Python-$(PYTHON_VERSION): downloads/Python-$(PYTHON_VERSION).tar.bz2
92
94
93
95
# Patch Python source with iOS patches
94
96
# Produce a dummy "patches-applied" file to mark that this has happened.
95
- src/Python-$(PYTHON_VERSION ) /build_simulator : src/Python-$(PYTHON_VERSION )
97
+ src/Python-$(PYTHON_VERSION ) /build : src/Python-$(PYTHON_VERSION )
96
98
# Apply patches
97
99
cp patch/Python/$(PYTHON_VERSION ) /ModulesSetup src/Python-$(PYTHON_VERSION ) /Modules/Setup.local
98
100
cp patch/Python/$(PYTHON_VERSION ) /_scproxy.py src/Python-$(PYTHON_VERSION ) /Lib/_scproxy.py
99
101
cd src/Python-$(PYTHON_VERSION ) && patch -p1 -N < ../../patch/Python/$(PYTHON_VERSION ) /dynload.patch
100
102
cd src/Python-$(PYTHON_VERSION ) && patch -p1 -N < ../../patch/Python/$(PYTHON_VERSION ) /ssize-t-max.patch
101
103
cd src/Python-$(PYTHON_VERSION ) && patch -p1 -N < ../../patch/Python/$(PYTHON_VERSION ) /static-_sqlite3.patch
102
- # Configure and make the x86 (simulator) build
103
- cd src/Python-$(PYTHON_VERSION ) && ./configure CC=" clang -Qunused-arguments -fcolor-diagnostics" LDFLAGS=" -lsqlite3 -L../../build/ffi.framework" CFLAGS=" -I../../build/ffi.framework/Headers --sysroot=$( OSX_SDK_ROOT) " --prefix=$(PROJECTDIR ) /src/Python-$(PYTHON_VERSION ) /build_simulator
104
- cd src/Python-$(PYTHON_VERSION ) && make -j4 python.exe Parser/pgen libpython$(basename $(PYTHON_VERSION ) ) .a install
105
- # Create the framework directory from the compiled resrouces
106
- mkdir -p build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /
107
- cd build/Python.framework/Versions && ln -fs $(basename $(PYTHON_VERSION ) ) Current
108
- cp -r src/Python-$(PYTHON_VERSION ) /build_simulator/include/python$(basename $(PYTHON_VERSION ) ) build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /Headers
109
- cd build/Python.framework && ln -fs Versions/Current/Headers
110
- cp -r src/Python-$(PYTHON_VERSION ) /build_simulator/lib/python$(basename $(PYTHON_VERSION ) ) build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /Resources
111
- cd build/Python.framework && ln -fs Versions/Current/Resources
112
- # Temporarily move the x86 library into the framework dir to protect it from distclean
113
- mv src/Python-$(PYTHON_VERSION ) /libpython$(basename $(PYTHON_VERSION ) ) .a build/Python.framework
114
- # Clean out all the x86 build data
104
+ # Configure and make the local build, providing compiled resources.
105
+ # cd src/Python-$(PYTHON_VERSION) && ./configure CC="clang -Qunused-arguments -fcolor-diagnostics" LDFLAGS="-lsqlite3 -L../../build/ffi.framework" CFLAGS="-I../../build/ffi.framework/Headers --sysroot=$(OSX_SDK_ROOT)" --prefix=$(PROJECTDIR)/src/Python-$(PYTHON_VERSION)/build
106
+ cd src/Python-$(PYTHON_VERSION ) && ./configure CC=" clang -Qunused-arguments -fcolor-diagnostics" LDFLAGS=" -lsqlite3" CFLAGS=" --sysroot=$( OSX_SDK_ROOT) " --prefix=$(PROJECTDIR ) /src/Python-$(PYTHON_VERSION ) /build
107
+ cd src/Python-$(PYTHON_VERSION ) && make -j4 python.exe Parser/pgen
108
+ cd src/Python-$(PYTHON_VERSION ) && mv python.exe hostpython
109
+ cd src/Python-$(PYTHON_VERSION ) && mv Parser/pgen Parser/hostpgen
110
+ # # Clean out all the build data
115
111
cd src/Python-$(PYTHON_VERSION ) && make distclean
116
- # Restore the x86 library
117
- mv build/Python.framework/libpython$(basename $(PYTHON_VERSION ) ) .a src/Python-$(PYTHON_VERSION ) /build_simulator
118
112
119
- src/Python-$(PYTHON_VERSION ) /build_iphone : src/Python-$(PYTHON_VERSION ) /build_simulator
120
- # Apply extra patches for iOS native build
113
+ build/python/ios-simulator/Python : src/Python-$(PYTHON_VERSION ) /build
114
+ # Apply extra patches for iOS simulator build
115
+ cp patch/Python/$(PYTHON_VERSION ) /ModulesSetup src/Python-$(PYTHON_VERSION ) /Modules/Setup.local
116
+ cat patch/Python/$(PYTHON_VERSION ) /ModulesSetup.mobile >> src/Python-$(PYTHON_VERSION ) /Modules/Setup.local
117
+ cp patch/Python/$(PYTHON_VERSION ) /_scproxy.py src/Python-$(PYTHON_VERSION ) /Lib/_scproxy.py
118
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 < ../../patch/Python/$(PYTHON_VERSION ) /xcompile.patch
119
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 < ../../patch/Python/$(PYTHON_VERSION ) /setuppath.patch
120
+ # Configure and build Simulator library
121
+ cd src/Python-$(PYTHON_VERSION ) && ./configure CC=" $( IPHONESIMULATOR_CC) " LD=" $( IPHONESIMULATOR_LD) " CFLAGS=" $( IPHONESIMULATOR_CFLAGS) -I../../build/ffi.framework/Headers" LDFLAGS=" $( IPHONESIMULATOR_LDFLAGS) -L../../build/ffi.framework/ -lsqlite3 -undefined dynamic_lookup" --without-pymalloc --disable-toolbox-glue --prefix=/python --without-doc-strings
122
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 < ../../patch/Python/$(PYTHON_VERSION ) /ctypes_duplicate.patch
123
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 < ../../patch/Python/$(PYTHON_VERSION ) /pyconfig.patch
124
+ mkdir -p build/python/ios-simulator
125
+ cd src/Python-$(PYTHON_VERSION ) && make altbininstall libinstall inclinstall libainstall HOSTPYTHON=./hostpython CROSS_COMPILE_TARGET=yes prefix=" ../../build/python/ios-simulator"
126
+ # Relocate and rename the libpython binary
127
+ cd build/python/ios-simulator/lib && mv libpython$(basename $(PYTHON_VERSION ) ) .a ../Python
128
+ # Clean out all the build data
129
+ cd src/Python-$(PYTHON_VERSION ) && make distclean
130
+ # Reverse the source patches.
131
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 -R < ../../patch/Python/$(PYTHON_VERSION ) /xcompile.patch
132
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 -R < ../../patch/Python/$(PYTHON_VERSION ) /setuppath.patch
133
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 -R < ../../patch/Python/$(PYTHON_VERSION ) /ctypes_duplicate.patch
134
+ # cd src/Python-$(PYTHON_VERSION) && patch -p1 -R < ../../patch/Python/$(PYTHON_VERSION)/pyconfig.patch
135
+ # Clean up build directory
136
+ cd build/python/ios-simulator/lib/python2.7 && rm -rf * test* lib* wsgiref bsddb curses idlelib hotshot
137
+ cd build/python/ios-simulator/lib/python2.7 && find . -iname ' *.pyc' | xargs rm
138
+ cd build/python/ios-simulator/lib/python2.7 && find . -iname ' *.py' | xargs rm
139
+ cd build/python/ios-simulator/lib && rm -rf pkgconfig
140
+
141
+ build/python/ios-armv7/Python : src/Python-$(PYTHON_VERSION ) /build
142
+ # Apply extra patches for iPhone build
121
143
cp patch/Python/$(PYTHON_VERSION ) /ModulesSetup src/Python-$(PYTHON_VERSION ) /Modules/Setup.local
122
144
cat patch/Python/$(PYTHON_VERSION ) /ModulesSetup.mobile >> src/Python-$(PYTHON_VERSION ) /Modules/Setup.local
123
145
cp patch/Python/$(PYTHON_VERSION ) /_scproxy.py src/Python-$(PYTHON_VERSION ) /Lib/_scproxy.py
124
- cd src/Python-$(PYTHON_VERSION ) && patch -p1 -N < ../../patch/Python/$(PYTHON_VERSION ) /xcompile.patch
125
- cd src/Python-$(PYTHON_VERSION ) && patch -p1 -N < ../../patch/Python/$(PYTHON_VERSION ) /setuppath.patch
126
- # Configure and build iOS library
127
- cd src/Python-$(PYTHON_VERSION ) && ./configure CC=" $( ARM_CC) " LD=" $( ARM_LD) " CFLAGS=" $( ARM_CFLAGS) -I../../build/ffi.framework/Headers" LDFLAGS=" $( ARM_LDFLAGS) -L../../build/ffi.framework/ -lsqlite3 -undefined dynamic_lookup" --without-pymalloc --disable-toolbox-glue --host=armv7-apple-darwin --prefix=/python --without-doc-strings
128
- cd src/Python-$(PYTHON_VERSION ) && patch -p1 -N < ../../patch/Python/$(PYTHON_VERSION ) /ctypes_duplicate.patch
129
- cd src/Python-$(PYTHON_VERSION ) && patch -p1 -N < ../../patch/Python/$(PYTHON_VERSION ) /pyconfig.patch
130
- cd src/Python-$(PYTHON_VERSION ) && make -j4 libpython$(basename $(PYTHON_VERSION ) ) .a
131
-
132
- build/Python.framework : src/Python-$(PYTHON_VERSION ) /build_iphone
133
- xcrun lipo -create -output build/Python.framework/Versions/Current/libpython.a src/Python-$(PYTHON_VERSION ) /build_simulator/libpython$(basename $(PYTHON_VERSION ) ) .a src/Python-$(PYTHON_VERSION ) /libpython$(basename $(PYTHON_VERSION ) ) .a
134
- cd build/Python.framework && ln -fs Versions/Current/libpython.a
146
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 < ../../patch/Python/$(PYTHON_VERSION ) /xcompile.patch
147
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 < ../../patch/Python/$(PYTHON_VERSION ) /setuppath.patch
148
+ # Configure and build iPhone library
149
+ cd src/Python-$(PYTHON_VERSION ) && ./configure CC=" $( IPHONE_CC) " LD=" $( IPHONE_LD) " CFLAGS=" $( IPHONE_CFLAGS) -I../../build/ffi.framework/Headers" LDFLAGS=" $( IPHONE_LDFLAGS) -L../../build/ffi.framework/ -lsqlite3 -undefined dynamic_lookup" --without-pymalloc --disable-toolbox-glue --host=armv7-apple-darwin --prefix=/python --without-doc-strings
150
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 < ../../patch/Python/$(PYTHON_VERSION ) /ctypes_duplicate.patch
151
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 < ../../patch/Python/$(PYTHON_VERSION ) /pyconfig.patch
152
+ mkdir -p build/python/ios-armv7
153
+ cd src/Python-$(PYTHON_VERSION ) && make altbininstall libinstall inclinstall libainstall HOSTPYTHON=./hostpython CROSS_COMPILE_TARGET=yes prefix=" ../../build/python/ios-armv7"
154
+ # Relocate and rename the libpython binary
155
+ cd build/python/ios-armv7/lib && mv libpython$(basename $(PYTHON_VERSION ) ) .a ../Python
156
+ # Clean out all the build data
157
+ cd src/Python-$(PYTHON_VERSION ) && make distclean
158
+ # Reverse the source patches.
159
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 -R < ../../patch/Python/$(PYTHON_VERSION ) /xcompile.patch
160
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 -R < ../../patch/Python/$(PYTHON_VERSION ) /setuppath.patch
161
+ cd src/Python-$(PYTHON_VERSION ) && patch -p1 -R < ../../patch/Python/$(PYTHON_VERSION ) /ctypes_duplicate.patch
162
+ # cd src/Python-$(PYTHON_VERSION) && patch -p1 -R < ../../patch/Python/$(PYTHON_VERSION)/pyconfig.patch
163
+ # Clean up build directory
164
+ cd build/python/ios-armv7/lib/python2.7 && rm -rf * test* lib* wsgiref bsddb curses idlelib hotshot
165
+ cd build/python/ios-armv7/lib/python2.7 && find . -iname ' *.pyc' | xargs rm
166
+ cd build/python/ios-armv7/lib/python2.7 && find . -iname ' *.py' | xargs rm
167
+ cd build/python/ios-armv7/lib && rm -rf pkgconfig
168
+
169
+ build/Python.framework : build/python/ios-simulator/Python build/python/ios-armv7/Python
170
+ # Create the framework directory from the compiled resrouces
171
+ mkdir -p build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /
172
+ cd build/Python.framework/Versions && ln -fs $(basename $(PYTHON_VERSION ) ) Current
173
+ # Use the include and .pyo files from the simulator build.
174
+ cp -r build/python/ios-simulator/include/python$(basename $(PYTHON_VERSION ) ) build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /Headers
175
+ cd build/Python.framework && ln -fs Versions/Current/Headers
176
+ mkdir -p build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /Resources
177
+ cp -r build/python/ios-simulator/lib build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /Resources/lib
178
+ mkdir -p build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /Resources/include/python2.7
179
+ cp -r build/python/ios-simulator/include/python2.7/pyconfig.h build/Python.framework/Versions/$(basename $(PYTHON_VERSION ) ) /Resources/include/python2.7/pyconfig.h
180
+ cd build/Python.framework && ln -fs Versions/Current/Resources
181
+ # Build a fat library with all targets included.
182
+ xcrun lipo -create -output build/Python.framework/Versions/Current/Python build/python/ios-simulator/Python build/python/ios-armv7/Python
183
+ cd build/Python.framework && ln -fs Versions/Current/Python
135
184
136
185
env :
137
- echo " SDKDESCRIPTION" $(SDKDESCRIPTION )
138
- echo " SDKVER" $(SDKVER )
139
- echo " DEVROOT" $(DEVROOT )
140
- echo " IOSSDKROOT" $(IOSSDKROOT )
141
- echo " OSX_SDK_ROOT" $(OSX_SDK_ROOT )
142
- echo " PYTHON_VERSION" $(PYTHON_VERSION )
143
- echo " FFI_VERSION" $(FFI_VERSION )
144
- echo " ARM_CC" $(ARM_CC )
145
- echo " ARM_AR" $(ARM_AR )
146
- echo " ARM_LD" $(ARM_LD )
147
- echo " ARM_CFLAGS" $(ARM_CFLAGS )
148
- echo " ARM_LDFLAGS" $(ARM_LDFLAGS )
149
-
150
-
151
- # build/Python.framework: src/Python-$(PYTHON_VERSION)/hostpython
186
+ # PYTHON_VERSION $(PYTHON_VERSION)
187
+ # FFI_VERSION $(FFI_VERSION)
188
+ # OSX_SDK_ROOT $(OSX_SDK_ROOT)
189
+ # IPHONE_SDK_ROOT $(IPHONE_SDK_ROOT)
190
+ # IPHONE_CC $(IPHONE_CC)
191
+ # IPHONE_LD $(IPHONE_LD)
192
+ # IPHONE_CFLAGS $(IPHONE_CFLAGS)
193
+ # IPHONE_LDFLAGS $(IPHONE_LDFLAGS)
194
+ # IPHONESIMULATOR_SDK_ROOT $(IPHONESIMULATOR_SDK_ROOT)
195
+ # IPHONESIMULATOR_CC $(IPHONESIMULATOR_CC)
196
+ # IPHONESIMULATOR_LD $(IPHONESIMULATOR_LD)
197
+ # IPHONESIMULATOR_CFLAGS $(IPHONESIMULATOR_CFLAGS)
198
+ # IPHONESIMULATOR_LDFLAGS $(IPHONESIMULATOR_LDFLAGS)
0 commit comments