]> git.saurik.com Git - cycript.git/blame_incremental - apple.mk
Make Pointer/Struct .type compatible with Functor.
[cycript.git] / apple.mk
... / ...
CommitLineData
1# Cycript - Optimizing JavaScript Compiler/Runtime
2# Copyright (C) 2009-2015 Jay Freeman (saurik)
3
4# GNU Affero General Public License, Version 3 {{{
5#
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.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
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/>.
18# }}}
19
20.SECONDARY:
21.DELETE_ON_ERROR:
22SHELL := /bin/bash
23
24include codesign.mk
25
26lipo := $(shell xcrun --sdk iphoneos -f lipo)
27
28monotonic := $(shell git log -1 --pretty=format:%ct)
29version := $(shell git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g')
30
31deb := cycript_$(version)_iphoneos-arm.deb
32zip := cycript_$(version).zip
33
34cycript :=
35cycript += Cycript.lib/cycript
36cycript += Cycript.lib/cycript0.9
37cycript += Cycript.lib/libcycript.dylib
38cycript += Cycript.lib/libcycript-sys.dylib
39cycript += Cycript.lib/libcycript-sim.dylib
40cycript += Cycript.lib/libcycript.cy
41cycript += Cycript.lib/libcycript.db
42
43framework :=
44framework += Cycript
45framework += Headers/Cycript.h
46
47framework := $(foreach os,ios osx,$(foreach file,$(framework),Cycript.$(os)/Cycript.framework/$(file)))
48
49links :=
50links += Cycript.lib/cynject
51links += Cycript.lib/libsubstrate.dylib
52links += Cycript.lib/cycript0.9
53
54all := cycript $(cycript) $(framework)
55all: $(all)
56
57$(zip): $(all)
58 rm -f $@
59 zip -r9y $@ cycript Cycript.lib Cycript.{ios,osx} $(patsubst %,--exclude %,$(links))
60 zip -r9 $@ $(links)
61
62zip: $(zip)
63 ln -sf $< cycript.zip
64
65$(deb): Cycript.lib/cycript Cycript.lib/libcycript.dylib Cycript.lib/libcycript.db
66 rm -rf package
67 mkdir -p package/DEBIAN
68 sed -e 's/#/$(version)/' control.in >package/DEBIAN/control
69 mkdir -p package/usr/{bin,lib}
70 cp -a modules package/usr/lib/cycript0.9
71 $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript.lib/cycript
72 $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript.lib/libcycript.dylib
73 ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib
74 cp -a libcycript.cy package/usr/lib/libcycript.cy
75 cp -a Cycript.lib/libcycript.db package/usr/lib/libcycript.db
76 sqlite3 package/usr/lib/libcycript.db "delete from cache where system & $$(($$(cat build.ios-arm{v6,64}/Makefile | sed -e '/^CY_SYSTEM = \([0-9]*\)$$/{s//\1/;p;};d;' | tr $$'\n' '|') 0)) == 0; vacuum full;"
77 ./dpkg-deb.sh -Zlzma -b package $@
78
79deb: $(deb)
80 ln -sf $< cycript.deb
81
82clean :=
83
84db :=
85
86library := libffi libuv
87
88# make stubbornly refuses to believe that these @'s are bugs
89# http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html
90
91define build_lar
92Cycript.lib/$(1).a: $(1).$(2)/.libs/$(1).a
93endef
94
95define build_any
96.PHONY: build-$(1)-$(2)
97build-$(1)-$(2):
98 $$(MAKE) -C build.$(1)-$(2)
99build.$(1)-$(2)/.libs/libcycript.a: build-$(1)-$(2)
100 @
101clean-$(1)-$(2):
102 $$(MAKE) -C build.$(1)-$(2) clean
103clean += clean-$(1)-$(2)
104db += build.$(1)-$(2)/libcycript.db
105build.$(1)-$(2)/libcycript.db: build-$(1)-$(2)
106 @
107ifneq ($(1),sim)
108$(foreach lib,$(library),
109$(call build_lar,$(lib),$(2))
110)
111endif
112endef
113
114define build_lib
115build.$(1)-$(2)/.libs/libcycript.dylib: build-$(1)-$(2)
116 @
117endef
118
119define build_osx
120$(call build_any,osx,$(1))
121$(call build_lib,osx,$(1))
122build.osx-$(1)/.libs/cycript: build-osx-$(1)
123 @
124endef
125
126$(foreach arch,i386 x86_64,$(eval $(call build_osx,$(arch))))
127
128define build_ios
129$(call build_any,ios,$(1))
130endef
131
132$(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch))))
133
134define build_sim
135$(call build_any,sim,$(1))
136$(call build_lib,sim,$(1))
137endef
138
139$(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch))))
140
141define build_arm
142build.ios-$(1)/.libs/cycript: build-ios-$(1)
143 @
144endef
145
146$(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
147
148define build_arm
149$(call build_lib,ios,$(1))
150endef
151
152$(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch))))
153
154clean: $(clean)
155 rm -rf cycript Cycript.lib libcycript*.o
156
157$(patsubst %,Cycript.lib/%.a,$(library)):
158 @mkdir -p $(dir $@)
159 $(lipo) -create -output $@ $^
160
161Cycript.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
162 @mkdir -p $(dir $@)
163 $(lipo) -create -output $@ $^
164 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
165 codesign -s $(codesign) $@
166
167%_: %
168 @cp -af $< $@
169 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
170 codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@
171
172Cycript.lib/%: build.osx-i386/.libs/%_ build.osx-x86_64/.libs/%_ build.ios-armv6/.libs/%_
173 @mkdir -p $(dir $@)
174 $(lipo) -create -output $@ $^
175
176Cycript.lib/libcycript-sys.dylib:
177 @mkdir -p $(dir $@)
178 ln -sf libcycript.dylib $@
179
180Cycript.lib/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib
181 @mkdir -p $(dir $@)
182 $(lipo) -create -output $@ $^
183 codesign -s $(codesign) $@
184
185libcycript-%.o: build.%/.libs/libcycript.a $(patsubst %,Cycript.lib/%.a,$(library)) xcode.map
186 @mkdir -p $(dir $@)
187 ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load -exported_symbols_list xcode.map -x $(filter %.a,$^)
188
189libcycript-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
190 $(lipo) -create -output $@ $^
191
192libcycript-osx.o: libcycript-osx-i386.o libcycript-osx-x86_64.o
193 $(lipo) -create -output $@ $^
194
195Cycript.%/Cycript.framework/Cycript: libcycript-%.o
196 @mkdir -p $(dir $@)
197 cp -a $< $@
198
199Cycript.%/Cycript.framework/Headers/Cycript.h: Cycript.h
200 @mkdir -p $(dir $@)
201 cp -a $< $@
202
203Cycript.lib/libcycript.cy:
204 @mkdir -p $(dir $@)
205 ln -sf ../libcycript.cy $@
206
207Cycript.lib/libcycript.db: $(db)
208 @mkdir -p $(dir $@)
209 ./libcycript.sh 0 $@
210 ./libcycript.py $@ $^
211
212Cycript.lib/cycript0.9:
213 @mkdir -p $(dir $@)
214 ln -s ../modules $@
215
216cycript: cycript.in
217 cp -af $< $@
218 chmod 755 $@
219
220local := Cycript.lib/cycript Cycript.lib/libcycript.dylib Cycript.lib/libcycript-sys.dylib Cycript.lib/libcycript-sim.dylib
221
222debug: $(local)
223 DYLD_LIBRARY_PATH=Cycript.lib lldb Cycript.lib/cycript
224
225install: $(local)
226 sudo cp -af $(filter-out %.dylib,$^) /usr/bin
227 sudo cp -af $(filter %.dylib,$^) /usr/lib
228
229
230cast: $(zip)
231 appcast.sh cycript/mac $(monotonic) $(version) $< "$(CYCRIPT_CHANGES)"
232
233.PHONY: all cast clean debug install zip