1 # Cycript - Optimizing JavaScript Compiler/Runtime
2 # Copyright (C) 2009-2013 Jay Freeman (saurik)
4 # GNU General Public License, Version 3 {{{
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.
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.
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/>.
25 lipo := $(shell xcrun --sdk iphoneos -f lipo)
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
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
39 framework += Cycript.framework/Cycript
40 framework += Cycript.framework/Headers/Cycript.h
43 links += Cycript.lib/libsubstrate.dylib
44 links += Cycript.lib/cycript0.9
46 all: cycript $(cycript) $(framework)
50 zip -r9y $@ cycript Cycript.lib Cycript.framework $(patsubst %,--exclude %,$(links))
55 $(deb): Cycript.lib/cycript Cycript.lib/libcycript.dylib
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 $@
70 rm -rf cycript Cycript.lib libcycript*.o
72 # make stubbornly refuses to believe that these @'s are bugs
73 # http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html
76 .PHONY: build-mac-$(1)
78 $(MAKE) -C build.mac-$(1)
79 build.mac-$(1)/.libs/cycript: build-mac-$(1)
81 build.mac-$(1)/.libs/libcycript.dylib: build-mac-$(1)
83 build.mac-$(1)/.libs/libcycript-any.dylib: build-mac-$(1)
87 $(foreach arch,i386 x86_64,$(eval $(call build_mac,$(arch))))
90 .PHONY: build-ios-$(1)
92 $(MAKE) -C build.ios-$(1)
93 build.ios-$(1)/.libs/libcycript.a: build-ios-$(1)
97 $(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch))))
100 .PHONY: build-sim-$(1)
102 $(MAKE) -C build.sim-$(1)
103 build.sim-$(1)/.libs/libcycript.dylib: build-sim-$(1)
105 build.sim-$(1)/.libs/libcycript.a: build-sim-$(1)
109 $(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch))))
112 build.ios-$(1)/.libs/cycript: build-ios-$(1)
116 $(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
119 build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1)
123 $(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch))))
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
127 $(lipo) -create -output $@ $^
128 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
129 codesign -s $(codesign) $@
133 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
134 codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@
136 Cycript.lib/%: build.mac-i386/.libs/%_ build.mac-x86_64/.libs/%_ build.ios-armv6/.libs/%_
138 $(lipo) -create -output $@ $^
140 Cycript.lib/libcycript-sys.dylib:
142 ln -sf libcycript.dylib $@
144 Cycript.lib/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib
146 $(lipo) -create -output $@ $^
147 codesign -s $(codesign) $@
149 libcycript-%.o: build.%/.libs/libcycript.a xcode.map
151 ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load -exported_symbols_list xcode.map $< libffi.a
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 $@ $^
156 Cycript.framework/Cycript: libcycript.o
160 Cycript.framework/Headers/Cycript.h: Cycript.h
164 Cycript.lib/cycript0.9:
172 .PHONY: all clean package