]>
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 | |
7c3b4d9a | 29 | zip := cycript_$(version).zip |
3615a2f7 | 30 | |
6219596c | 31 | cycript := |
c22e009d JF |
32 | cycript += Cycript.lib/cycript |
33 | cycript += Cycript.lib/cycript0.9 | |
fb718684 JF |
34 | cycript += Cycript.lib/libcycript.dylib |
35 | cycript += Cycript.lib/libcycript-any.dylib | |
36 | cycript += Cycript.lib/libcycript-sys.dylib | |
37 | cycript += Cycript.lib/libcycript-sim.dylib | |
3370d0c0 | 38 | |
7d894647 | 39 | framework := |
5da4d29c JF |
40 | framework += Cycript |
41 | framework += Headers/Cycript.h | |
42 | ||
43 | framework := $(foreach os,ios mac,$(foreach file,$(framework),Cycript-$(os).framework/$(file))) | |
7d894647 | 44 | |
c22e009d JF |
45 | links := |
46 | links += Cycript.lib/libsubstrate.dylib | |
47 | links += Cycript.lib/cycript0.9 | |
48 | ||
6219596c | 49 | all: cycript $(cycript) $(framework) |
7d894647 | 50 | |
7c3b4d9a | 51 | $(zip): all |
7d894647 | 52 | rm -f $@ |
5da4d29c | 53 | zip -r9y $@ cycript Cycript.lib Cycript-{ios,mac}.framework $(patsubst %,--exclude %,$(links)) |
c22e009d | 54 | zip -r9 $@ $(links) |
7d894647 | 55 | |
7c3b4d9a JF |
56 | zip: $(zip) |
57 | ln -sf $< cycript.zip | |
3370d0c0 | 58 | |
c22e009d | 59 | $(deb): Cycript.lib/cycript Cycript.lib/libcycript.dylib |
3615a2f7 JF |
60 | rm -rf package |
61 | mkdir -p package/DEBIAN | |
62 | sed -e 's/#/$(version)/' control.in >package/DEBIAN/control | |
63 | mkdir -p package/usr/{bin,lib} | |
c22e009d JF |
64 | cp -a modules package/usr/lib/cycript0.9 |
65 | $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript.lib/cycript | |
fb718684 | 66 | $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript.lib/libcycript.dylib |
3615a2f7 | 67 | ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib |
83646644 | 68 | dpkg-deb -Zlzma -b package $@ |
3615a2f7 JF |
69 | |
70 | deb: $(deb) | |
71 | ln -sf $< cycript.deb | |
72 | ||
3370d0c0 | 73 | clean: |
fb718684 | 74 | rm -rf cycript Cycript.lib libcycript*.o |
3370d0c0 | 75 | |
3370d0c0 JF |
76 | # make stubbornly refuses to believe that these @'s are bugs |
77 | # http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html | |
78 | ||
a412fff4 JF |
79 | define build_any |
80 | .PHONY: build-$(1)-$(2) | |
81 | build-$(1)-$(2): | |
82 | $(MAKE) -C build.$(1)-$(2) | |
83 | build.$(1)-$(2)/.libs/libcycript.a: build-$(1)-$(2) | |
3370d0c0 | 84 | @ |
a412fff4 JF |
85 | endef |
86 | ||
87 | define build_lib | |
88 | build.$(1)-$(2)/.libs/libcycript.dylib: build-$(1)-$(2) | |
3370d0c0 | 89 | @ |
a412fff4 JF |
90 | endef |
91 | ||
92 | define build_mac | |
93 | $(call build_any,mac,$(1)) | |
94 | $(call build_lib,mac,$(1)) | |
95 | build.mac-$(1)/.libs/cycript: build-mac-$(1) | |
3370d0c0 | 96 | @ |
abc804fa | 97 | endef |
3370d0c0 | 98 | |
abc804fa JF |
99 | $(foreach arch,i386 x86_64,$(eval $(call build_mac,$(arch)))) |
100 | ||
101 | define build_ios | |
a412fff4 | 102 | $(call build_any,ios,$(1)) |
abc804fa JF |
103 | endef |
104 | ||
0ad8029f | 105 | $(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch)))) |
3370d0c0 | 106 | |
abc804fa | 107 | define build_sim |
a412fff4 JF |
108 | $(call build_any,sim,$(1)) |
109 | $(call build_lib,sim,$(1)) | |
110 | build.sim-$(1)/.libs/libcycript-any.dylib: build-sim-$(1) | |
3370d0c0 | 111 | @ |
abc804fa JF |
112 | endef |
113 | ||
3615a2f7 | 114 | $(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch)))) |
3370d0c0 | 115 | |
1510e2d9 JF |
116 | define build_arm |
117 | build.ios-$(1)/.libs/cycript: build-ios-$(1) | |
118 | @ | |
3615a2f7 JF |
119 | endef |
120 | ||
121 | $(foreach arch,armv6,$(eval $(call build_arm,$(arch)))) | |
122 | ||
123 | define build_arm | |
a412fff4 | 124 | $(call build_lib,ios,$(1)) |
1510e2d9 JF |
125 | endef |
126 | ||
3615a2f7 | 127 | $(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch)))) |
1510e2d9 | 128 | |
a412fff4 JF |
129 | Cycript.lib/libcycript-any.dylib: build.sim-i386/.libs/libcycript-any.dylib build.sim-x86_64/.libs/libcycript-any.dylib |
130 | @mkdir -p $(dir $@) | |
131 | $(lipo) -create -output $@ $^ | |
132 | codesign -s $(codesign) $@ | |
133 | ||
134 | Cycript.lib/libcycript.dylib: build.mac-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib build.ios-armv6/.libs/libcycript.dylib build.ios-arm64/.libs/libcycript.dylib | |
0ad8029f JF |
135 | @mkdir -p $(dir $@) |
136 | $(lipo) -create -output $@ $^ | |
3615a2f7 JF |
137 | install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@ |
138 | codesign -s $(codesign) $@ | |
0ad8029f | 139 | |
69d4f99a JF |
140 | %_: % |
141 | @cp -af $< $@ | |
3615a2f7 | 142 | install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@ |
69d4f99a JF |
143 | codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@ |
144 | ||
c22e009d | 145 | Cycript.lib/%: build.mac-i386/.libs/%_ build.mac-x86_64/.libs/%_ build.ios-armv6/.libs/%_ |
6219596c | 146 | @mkdir -p $(dir $@) |
e9abea04 | 147 | $(lipo) -create -output $@ $^ |
3370d0c0 | 148 | |
fb718684 | 149 | Cycript.lib/libcycript-sys.dylib: |
6219596c | 150 | @mkdir -p $(dir $@) |
3370d0c0 JF |
151 | ln -sf libcycript.dylib $@ |
152 | ||
fb718684 | 153 | Cycript.lib/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib |
6219596c | 154 | @mkdir -p $(dir $@) |
8ccd2bee | 155 | $(lipo) -create -output $@ $^ |
cd0c51c7 | 156 | codesign -s $(codesign) $@ |
3370d0c0 | 157 | |
ca52e3a3 | 158 | libcycript-%.o: build.%/.libs/libcycript.a xcode.map |
6219596c | 159 | @mkdir -p $(dir $@) |
ca52e3a3 | 160 | ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load -exported_symbols_list xcode.map $< libffi.a |
3370d0c0 | 161 | |
5da4d29c JF |
162 | libcycript-ios.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 |
163 | $(lipo) -create -output $@ $^ | |
164 | ||
165 | libcycript-mac.o: libcycript-mac-i386.o libcycript-mac-x86_64.o | |
e9abea04 | 166 | $(lipo) -create -output $@ $^ |
3370d0c0 | 167 | |
5da4d29c | 168 | Cycript-%.framework/Cycript: libcycript-%.o |
7d894647 JF |
169 | @mkdir -p $(dir $@) |
170 | cp -a $< $@ | |
171 | ||
5da4d29c | 172 | Cycript-%.framework/Headers/Cycript.h: Cycript.h |
7d894647 JF |
173 | @mkdir -p $(dir $@) |
174 | cp -a $< $@ | |
175 | ||
c22e009d JF |
176 | Cycript.lib/cycript0.9: |
177 | @mkdir -p $(dir $@) | |
178 | ln -s ../modules $@ | |
179 | ||
3370d0c0 JF |
180 | cycript: cycript.in |
181 | cp -af $< $@ | |
182 | chmod 755 $@ | |
183 | ||
278e0646 JF |
184 | install: Cycript.lib/cycript Cycript.lib/libcycript.dylib Cycript.lib/libcycript-sys.dylib Cycript.lib/libcycript-any.dylib Cycript.lib/libcycript-sim.dylib |
185 | sudo cp -af $(filter-out %.dylib,$^) /usr/bin | |
186 | sudo cp -af $(filter %.dylib,$^) /usr/lib | |
187 | ||
188 | .PHONY: all clean install package |