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