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