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_/cycript
32 cycript += Cycript_/libcycript.dylib
33 cycript += Cycript_/libcycript-any.dylib
34 cycript += Cycript_/libcycript-sys.dylib
35 cycript += Cycript_/libcycript-sim.dylib
38 framework += Cycript.framework/Cycript
39 framework += Cycript.framework/Headers/Cycript.h
41 all: cycript $(cycript) $(framework)
45 zip -r9y $@ cycript Cycript_ Cycript.framework
49 $(deb): Cycript_/cycript Cycript_/libcycript.dylib
51 mkdir -p package/DEBIAN
52 sed -e 's/#/$(version)/' control.in >package/DEBIAN/control
53 mkdir -p package/usr/{bin,lib}
54 $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript_/cycript
55 $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript_/libcycript.dylib
56 ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib
57 dpkg-deb -b package $@
63 rm -rf cycript Cycript_ libcycript*.o
65 # make stubbornly refuses to believe that these @'s are bugs
66 # http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html
69 .PHONY: build-mac-$(1)
71 $(MAKE) -C build.mac-$(1)
72 build.mac-$(1)/.libs/cycript: build-mac-$(1)
74 build.mac-$(1)/.libs/libcycript.dylib: build-mac-$(1)
76 build.mac-$(1)/.libs/libcycript-any.dylib: build-mac-$(1)
80 $(foreach arch,i386 x86_64,$(eval $(call build_mac,$(arch))))
83 .PHONY: build-ios-$(1)
85 $(MAKE) -C build.ios-$(1)
86 build.ios-$(1)/.libs/libcycript.a: build-ios-$(1)
90 $(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch))))
93 .PHONY: build-sim-$(1)
95 $(MAKE) -C build.sim-$(1)
96 build.sim-$(1)/.libs/libcycript.dylib: build-sim-$(1)
98 build.sim-$(1)/.libs/libcycript.a: build-sim-$(1)
102 $(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch))))
105 build.ios-$(1)/.libs/cycript: build-ios-$(1)
109 $(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
112 build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1)
116 $(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch))))
118 Cycript_/%.dylib: build.mac-i386/.libs/%.dylib build.mac-x86_64/.libs/%.dylib build.ios-armv6/.libs/%.dylib build.ios-arm64/.libs/%.dylib
120 $(lipo) -create -output $@ $^
121 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
122 codesign -s $(codesign) $@
126 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
127 codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@
129 Cycript_/%: build.mac-i386/.libs/%_ build.mac-x86_64/.libs/%_ build.ios-armv6/.libs/%_
131 $(lipo) -create -output $@ $^
133 Cycript_/libcycript-sys.dylib:
135 ln -sf libcycript.dylib $@
137 Cycript_/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib
140 codesign -s $(codesign) $@
142 libcycript-%.o: build.%/.libs/libcycript.a
144 ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load $< libffi.a
146 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
147 $(lipo) -create -output $@ $^
149 Cycript.framework/Cycript: libcycript.o
153 Cycript.framework/Headers/Cycript.h: Cycript.h
161 .PHONY: all clean package