]>
Commit | Line | Data |
---|---|---|
3370d0c0 JF |
1 | # Cycript - Optimizing JavaScript Compiler/Runtime |
2 | # Copyright (C) 2009-2013 Jay Freeman (saurik) | |
3 | ||
4 | # GNU General Public License, Version 3 {{{ | |
5 | # | |
6 | # Cycript is free software: you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published | |
8 | # by the Free Software Foundation, either version 3 of the License, | |
9 | # or (at your option) any later version. | |
10 | # | |
11 | # Cycript is distributed in the hope that it will be useful, but | |
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with Cycript. If not, see <http://www.gnu.org/licenses/>. | |
18 | # }}} | |
19 | ||
20 | .DELETE_ON_ERROR: | |
21 | SHELL := /bin/bash | |
22 | ||
cd0c51c7 JF |
23 | include codesign.mk |
24 | ||
e9abea04 JF |
25 | lipo := $(shell xcrun --sdk iphoneos -f lipo) |
26 | ||
3615a2f7 JF |
27 | version := $(shell git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g') |
28 | deb := cycript_$(version)_iphoneos-arm.deb | |
29 | ||
6219596c | 30 | cycript := |
c22e009d JF |
31 | cycript += Cycript.lib/cycript |
32 | cycript += Cycript.lib/cycript0.9 | |
fb718684 JF |
33 | cycript += Cycript.lib/libcycript.dylib |
34 | cycript += Cycript.lib/libcycript-any.dylib | |
35 | cycript += Cycript.lib/libcycript-sys.dylib | |
36 | cycript += Cycript.lib/libcycript-sim.dylib | |
3370d0c0 | 37 | |
7d894647 JF |
38 | framework := |
39 | framework += Cycript.framework/Cycript | |
40 | framework += Cycript.framework/Headers/Cycript.h | |
41 | ||
c22e009d JF |
42 | links := |
43 | links += Cycript.lib/libsubstrate.dylib | |
44 | links += Cycript.lib/cycript0.9 | |
45 | ||
6219596c | 46 | all: cycript $(cycript) $(framework) |
7d894647 JF |
47 | |
48 | cycript.zip: all | |
49 | rm -f $@ | |
c22e009d JF |
50 | zip -r9y $@ cycript Cycript.lib Cycript.framework $(patsubst %,--exclude %,$(links)) |
51 | zip -r9 $@ $(links) | |
7d894647 JF |
52 | |
53 | package: cycript.zip | |
3370d0c0 | 54 | |
c22e009d | 55 | $(deb): Cycript.lib/cycript Cycript.lib/libcycript.dylib |
3615a2f7 JF |
56 | rm -rf package |
57 | mkdir -p package/DEBIAN | |
58 | sed -e 's/#/$(version)/' control.in >package/DEBIAN/control | |
59 | mkdir -p package/usr/{bin,lib} | |
c22e009d JF |
60 | cp -a modules package/usr/lib/cycript0.9 |
61 | $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript.lib/cycript | |
fb718684 | 62 | $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript.lib/libcycript.dylib |
3615a2f7 | 63 | ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib |
83646644 | 64 | dpkg-deb -Zlzma -b package $@ |
3615a2f7 JF |
65 | |
66 | deb: $(deb) | |
67 | ln -sf $< cycript.deb | |
68 | ||
3370d0c0 | 69 | clean: |
fb718684 | 70 | rm -rf cycript Cycript.lib libcycript*.o |
3370d0c0 | 71 | |
3370d0c0 JF |
72 | # make stubbornly refuses to believe that these @'s are bugs |
73 | # http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html | |
74 | ||
abc804fa JF |
75 | define build_mac |
76 | .PHONY: build-mac-$(1) | |
77 | build-mac-$(1): | |
78 | $(MAKE) -C build.mac-$(1) | |
79 | build.mac-$(1)/.libs/cycript: build-mac-$(1) | |
3370d0c0 | 80 | @ |
abc804fa | 81 | build.mac-$(1)/.libs/libcycript.dylib: build-mac-$(1) |
3370d0c0 | 82 | @ |
abc804fa | 83 | build.mac-$(1)/.libs/libcycript-any.dylib: build-mac-$(1) |
3370d0c0 | 84 | @ |
abc804fa | 85 | endef |
3370d0c0 | 86 | |
abc804fa JF |
87 | $(foreach arch,i386 x86_64,$(eval $(call build_mac,$(arch)))) |
88 | ||
89 | define build_ios | |
90 | .PHONY: build-ios-$(1) | |
91 | build-ios-$(1): | |
92 | $(MAKE) -C build.ios-$(1) | |
abc804fa | 93 | build.ios-$(1)/.libs/libcycript.a: build-ios-$(1) |
3370d0c0 | 94 | @ |
abc804fa JF |
95 | endef |
96 | ||
0ad8029f | 97 | $(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch)))) |
3370d0c0 | 98 | |
abc804fa JF |
99 | define build_sim |
100 | .PHONY: build-sim-$(1) | |
101 | build-sim-$(1): | |
102 | $(MAKE) -C build.sim-$(1) | |
103 | build.sim-$(1)/.libs/libcycript.dylib: build-sim-$(1) | |
3370d0c0 | 104 | @ |
abc804fa | 105 | build.sim-$(1)/.libs/libcycript.a: build-sim-$(1) |
3370d0c0 | 106 | @ |
abc804fa JF |
107 | endef |
108 | ||
3615a2f7 | 109 | $(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch)))) |
3370d0c0 | 110 | |
1510e2d9 JF |
111 | define build_arm |
112 | build.ios-$(1)/.libs/cycript: build-ios-$(1) | |
113 | @ | |
3615a2f7 JF |
114 | endef |
115 | ||
116 | $(foreach arch,armv6,$(eval $(call build_arm,$(arch)))) | |
117 | ||
118 | define build_arm | |
1510e2d9 JF |
119 | build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1) |
120 | @ | |
1510e2d9 JF |
121 | endef |
122 | ||
3615a2f7 | 123 | $(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch)))) |
1510e2d9 | 124 | |
fb718684 | 125 | Cycript.lib/%.dylib: build.mac-i386/.libs/%.dylib build.mac-x86_64/.libs/%.dylib build.ios-armv6/.libs/%.dylib build.ios-arm64/.libs/%.dylib |
0ad8029f JF |
126 | @mkdir -p $(dir $@) |
127 | $(lipo) -create -output $@ $^ | |
3615a2f7 JF |
128 | install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@ |
129 | codesign -s $(codesign) $@ | |
0ad8029f | 130 | |
69d4f99a JF |
131 | %_: % |
132 | @cp -af $< $@ | |
3615a2f7 | 133 | install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@ |
69d4f99a JF |
134 | codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@ |
135 | ||
c22e009d | 136 | Cycript.lib/%: build.mac-i386/.libs/%_ build.mac-x86_64/.libs/%_ build.ios-armv6/.libs/%_ |
6219596c | 137 | @mkdir -p $(dir $@) |
e9abea04 | 138 | $(lipo) -create -output $@ $^ |
3370d0c0 | 139 | |
fb718684 | 140 | Cycript.lib/libcycript-sys.dylib: |
6219596c | 141 | @mkdir -p $(dir $@) |
3370d0c0 JF |
142 | ln -sf libcycript.dylib $@ |
143 | ||
fb718684 | 144 | Cycript.lib/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib |
6219596c | 145 | @mkdir -p $(dir $@) |
8ccd2bee | 146 | $(lipo) -create -output $@ $^ |
cd0c51c7 | 147 | codesign -s $(codesign) $@ |
3370d0c0 | 148 | |
ca52e3a3 | 149 | libcycript-%.o: build.%/.libs/libcycript.a xcode.map |
6219596c | 150 | @mkdir -p $(dir $@) |
ca52e3a3 | 151 | ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load -exported_symbols_list xcode.map $< libffi.a |
3370d0c0 | 152 | |
3615a2f7 | 153 | libcycript.o: libcycript-ios-armv6.o libcycript-ios-armv7.o libcycript-ios-armv7s.o libcycript-ios-arm64.o libcycript-sim-i386.o libcycript-sim-x86_64.o |
e9abea04 | 154 | $(lipo) -create -output $@ $^ |
3370d0c0 | 155 | |
6219596c | 156 | Cycript.framework/Cycript: libcycript.o |
7d894647 JF |
157 | @mkdir -p $(dir $@) |
158 | cp -a $< $@ | |
159 | ||
160 | Cycript.framework/Headers/Cycript.h: Cycript.h | |
161 | @mkdir -p $(dir $@) | |
162 | cp -a $< $@ | |
163 | ||
c22e009d JF |
164 | Cycript.lib/cycript0.9: |
165 | @mkdir -p $(dir $@) | |
166 | ln -s ../modules $@ | |
167 | ||
3370d0c0 JF |
168 | cycript: cycript.in |
169 | cp -af $< $@ | |
170 | chmod 755 $@ | |
171 | ||
7d894647 | 172 | .PHONY: all clean package |