]> git.saurik.com Git - cycript.git/blame - xcode.mk
Fix issue in 64-bit choose() reported by heardrwt.
[cycript.git] / xcode.mk
CommitLineData
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:
21SHELL := /bin/bash
22
cd0c51c7
JF
23include codesign.mk
24
e9abea04
JF
25lipo := $(shell xcrun --sdk iphoneos -f lipo)
26
3615a2f7
JF
27version := $(shell git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g')
28deb := cycript_$(version)_iphoneos-arm.deb
29
6219596c 30cycript :=
c22e009d
JF
31cycript += Cycript.lib/cycript
32cycript += Cycript.lib/cycript0.9
fb718684
JF
33cycript += Cycript.lib/libcycript.dylib
34cycript += Cycript.lib/libcycript-any.dylib
35cycript += Cycript.lib/libcycript-sys.dylib
36cycript += Cycript.lib/libcycript-sim.dylib
3370d0c0 37
7d894647
JF
38framework :=
39framework += Cycript.framework/Cycript
40framework += Cycript.framework/Headers/Cycript.h
41
c22e009d
JF
42links :=
43links += Cycript.lib/libsubstrate.dylib
44links += Cycript.lib/cycript0.9
45
6219596c 46all: cycript $(cycript) $(framework)
7d894647
JF
47
48cycript.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
53package: 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
66deb: $(deb)
67 ln -sf $< cycript.deb
68
3370d0c0 69clean:
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
75define build_mac
76.PHONY: build-mac-$(1)
77build-mac-$(1):
78 $(MAKE) -C build.mac-$(1)
79build.mac-$(1)/.libs/cycript: build-mac-$(1)
3370d0c0 80 @
abc804fa 81build.mac-$(1)/.libs/libcycript.dylib: build-mac-$(1)
3370d0c0 82 @
abc804fa 83build.mac-$(1)/.libs/libcycript-any.dylib: build-mac-$(1)
3370d0c0 84 @
abc804fa 85endef
3370d0c0 86
abc804fa
JF
87$(foreach arch,i386 x86_64,$(eval $(call build_mac,$(arch))))
88
89define build_ios
90.PHONY: build-ios-$(1)
91build-ios-$(1):
92 $(MAKE) -C build.ios-$(1)
abc804fa 93build.ios-$(1)/.libs/libcycript.a: build-ios-$(1)
3370d0c0 94 @
abc804fa
JF
95endef
96
0ad8029f 97$(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch))))
3370d0c0 98
abc804fa
JF
99define build_sim
100.PHONY: build-sim-$(1)
101build-sim-$(1):
102 $(MAKE) -C build.sim-$(1)
103build.sim-$(1)/.libs/libcycript.dylib: build-sim-$(1)
3370d0c0 104 @
abc804fa 105build.sim-$(1)/.libs/libcycript.a: build-sim-$(1)
3370d0c0 106 @
abc804fa
JF
107endef
108
3615a2f7 109$(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch))))
3370d0c0 110
1510e2d9
JF
111define build_arm
112build.ios-$(1)/.libs/cycript: build-ios-$(1)
113 @
3615a2f7
JF
114endef
115
116$(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
117
118define build_arm
1510e2d9
JF
119build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1)
120 @
1510e2d9
JF
121endef
122
3615a2f7 123$(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch))))
1510e2d9 124
fb718684 125Cycript.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 136Cycript.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 140Cycript.lib/libcycript-sys.dylib:
6219596c 141 @mkdir -p $(dir $@)
3370d0c0
JF
142 ln -sf libcycript.dylib $@
143
fb718684 144Cycript.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 149libcycript-%.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 153libcycript.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 156Cycript.framework/Cycript: libcycript.o
7d894647
JF
157 @mkdir -p $(dir $@)
158 cp -a $< $@
159
160Cycript.framework/Headers/Cycript.h: Cycript.h
161 @mkdir -p $(dir $@)
162 cp -a $< $@
163
c22e009d
JF
164Cycript.lib/cycript0.9:
165 @mkdir -p $(dir $@)
166 ln -s ../modules $@
167
3370d0c0
JF
168cycript: cycript.in
169 cp -af $< $@
170 chmod 755 $@
171
7d894647 172.PHONY: all clean package