]>
Commit | Line | Data |
---|---|---|
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 | ||
23 | include codesign.mk | |
24 | ||
25 | lipo := $(shell xcrun --sdk iphoneos -f lipo) | |
26 | ||
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 | ||
30 | cycript := | |
31 | cycript += Cycript.lib/cycript | |
32 | cycript += Cycript.lib/cycript0.9 | |
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 | |
37 | ||
38 | framework := | |
39 | framework += Cycript.framework/Cycript | |
40 | framework += Cycript.framework/Headers/Cycript.h | |
41 | ||
42 | links := | |
43 | links += Cycript.lib/libsubstrate.dylib | |
44 | links += Cycript.lib/cycript0.9 | |
45 | ||
46 | all: cycript $(cycript) $(framework) | |
47 | ||
48 | cycript.zip: all | |
49 | rm -f $@ | |
50 | zip -r9y $@ cycript Cycript.lib Cycript.framework $(patsubst %,--exclude %,$(links)) | |
51 | zip -r9 $@ $(links) | |
52 | ||
53 | package: cycript.zip | |
54 | ||
55 | $(deb): Cycript.lib/cycript Cycript.lib/libcycript.dylib | |
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} | |
60 | cp -a modules package/usr/lib/cycript0.9 | |
61 | $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript.lib/cycript | |
62 | $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript.lib/libcycript.dylib | |
63 | ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib | |
64 | dpkg-deb -Zlzma -b package $@ | |
65 | ||
66 | deb: $(deb) | |
67 | ln -sf $< cycript.deb | |
68 | ||
69 | clean: | |
70 | rm -rf cycript Cycript.lib libcycript*.o | |
71 | ||
72 | # make stubbornly refuses to believe that these @'s are bugs | |
73 | # http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html | |
74 | ||
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) | |
80 | @ | |
81 | build.mac-$(1)/.libs/libcycript.dylib: build-mac-$(1) | |
82 | @ | |
83 | build.mac-$(1)/.libs/libcycript-any.dylib: build-mac-$(1) | |
84 | @ | |
85 | endef | |
86 | ||
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) | |
93 | build.ios-$(1)/.libs/libcycript.a: build-ios-$(1) | |
94 | @ | |
95 | endef | |
96 | ||
97 | $(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch)))) | |
98 | ||
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) | |
104 | @ | |
105 | build.sim-$(1)/.libs/libcycript.a: build-sim-$(1) | |
106 | @ | |
107 | endef | |
108 | ||
109 | $(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch)))) | |
110 | ||
111 | define build_arm | |
112 | build.ios-$(1)/.libs/cycript: build-ios-$(1) | |
113 | @ | |
114 | endef | |
115 | ||
116 | $(foreach arch,armv6,$(eval $(call build_arm,$(arch)))) | |
117 | ||
118 | define build_arm | |
119 | build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1) | |
120 | @ | |
121 | endef | |
122 | ||
123 | $(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch)))) | |
124 | ||
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 | |
126 | @mkdir -p $(dir $@) | |
127 | $(lipo) -create -output $@ $^ | |
128 | install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@ | |
129 | codesign -s $(codesign) $@ | |
130 | ||
131 | %_: % | |
132 | @cp -af $< $@ | |
133 | install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@ | |
134 | codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@ | |
135 | ||
136 | Cycript.lib/%: build.mac-i386/.libs/%_ build.mac-x86_64/.libs/%_ build.ios-armv6/.libs/%_ | |
137 | @mkdir -p $(dir $@) | |
138 | $(lipo) -create -output $@ $^ | |
139 | ||
140 | Cycript.lib/libcycript-sys.dylib: | |
141 | @mkdir -p $(dir $@) | |
142 | ln -sf libcycript.dylib $@ | |
143 | ||
144 | Cycript.lib/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib | |
145 | @mkdir -p $(dir $@) | |
146 | $(lipo) -create -output $@ $^ | |
147 | codesign -s $(codesign) $@ | |
148 | ||
149 | libcycript-%.o: build.%/.libs/libcycript.a xcode.map | |
150 | @mkdir -p $(dir $@) | |
151 | ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load -exported_symbols_list xcode.map $< libffi.a | |
152 | ||
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 | |
154 | $(lipo) -create -output $@ $^ | |
155 | ||
156 | Cycript.framework/Cycript: libcycript.o | |
157 | @mkdir -p $(dir $@) | |
158 | cp -a $< $@ | |
159 | ||
160 | Cycript.framework/Headers/Cycript.h: Cycript.h | |
161 | @mkdir -p $(dir $@) | |
162 | cp -a $< $@ | |
163 | ||
164 | Cycript.lib/cycript0.9: | |
165 | @mkdir -p $(dir $@) | |
166 | ln -s ../modules $@ | |
167 | ||
168 | cycript: cycript.in | |
169 | cp -af $< $@ | |
170 | chmod 755 $@ | |
171 | ||
172 | .PHONY: all clean package |