]> git.saurik.com Git - cycript.git/blame - xcode.mk
Apparently, __pthread_set_self takes tsd address.
[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 :=
ee02290f
JF
31cycript += Cycript_/cycript
32cycript += Cycript_/libcycript.dylib
33cycript += Cycript_/libcycript-any.dylib
34cycript += Cycript_/libcycript-sys.dylib
35cycript += Cycript_/libcycript-sim.dylib
3370d0c0 36
7d894647
JF
37framework :=
38framework += Cycript.framework/Cycript
39framework += Cycript.framework/Headers/Cycript.h
40
6219596c 41all: cycript $(cycript) $(framework)
7d894647
JF
42
43cycript.zip: all
44 rm -f $@
ee02290f 45 zip -r9y $@ cycript Cycript_ Cycript.framework
7d894647
JF
46
47package: cycript.zip
3370d0c0 48
3615a2f7
JF
49$(deb): Cycript_/cycript Cycript_/libcycript.dylib
50 rm -rf package
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
83646644 57 dpkg-deb -Zlzma -b package $@
3615a2f7
JF
58
59deb: $(deb)
60 ln -sf $< cycript.deb
61
3370d0c0 62clean:
ee02290f 63 rm -rf cycript Cycript_ libcycript*.o
3370d0c0 64
3370d0c0
JF
65# make stubbornly refuses to believe that these @'s are bugs
66# http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html
67
abc804fa
JF
68define build_mac
69.PHONY: build-mac-$(1)
70build-mac-$(1):
71 $(MAKE) -C build.mac-$(1)
72build.mac-$(1)/.libs/cycript: build-mac-$(1)
3370d0c0 73 @
abc804fa 74build.mac-$(1)/.libs/libcycript.dylib: build-mac-$(1)
3370d0c0 75 @
abc804fa 76build.mac-$(1)/.libs/libcycript-any.dylib: build-mac-$(1)
3370d0c0 77 @
abc804fa 78endef
3370d0c0 79
abc804fa
JF
80$(foreach arch,i386 x86_64,$(eval $(call build_mac,$(arch))))
81
82define build_ios
83.PHONY: build-ios-$(1)
84build-ios-$(1):
85 $(MAKE) -C build.ios-$(1)
abc804fa 86build.ios-$(1)/.libs/libcycript.a: build-ios-$(1)
3370d0c0 87 @
abc804fa
JF
88endef
89
0ad8029f 90$(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch))))
3370d0c0 91
abc804fa
JF
92define build_sim
93.PHONY: build-sim-$(1)
94build-sim-$(1):
95 $(MAKE) -C build.sim-$(1)
96build.sim-$(1)/.libs/libcycript.dylib: build-sim-$(1)
3370d0c0 97 @
abc804fa 98build.sim-$(1)/.libs/libcycript.a: build-sim-$(1)
3370d0c0 99 @
abc804fa
JF
100endef
101
3615a2f7 102$(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch))))
3370d0c0 103
1510e2d9
JF
104define build_arm
105build.ios-$(1)/.libs/cycript: build-ios-$(1)
106 @
3615a2f7
JF
107endef
108
109$(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
110
111define build_arm
1510e2d9
JF
112build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1)
113 @
1510e2d9
JF
114endef
115
3615a2f7 116$(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch))))
1510e2d9 117
0ad8029f
JF
118Cycript_/%.dylib: build.mac-i386/.libs/%.dylib build.mac-x86_64/.libs/%.dylib build.ios-armv6/.libs/%.dylib build.ios-arm64/.libs/%.dylib
119 @mkdir -p $(dir $@)
120 $(lipo) -create -output $@ $^
3615a2f7
JF
121 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
122 codesign -s $(codesign) $@
0ad8029f 123
69d4f99a
JF
124%_: %
125 @cp -af $< $@
3615a2f7 126 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
69d4f99a
JF
127 codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@
128
129Cycript_/%: build.mac-i386/.libs/%_ build.mac-x86_64/.libs/%_ build.ios-armv6/.libs/%_
6219596c 130 @mkdir -p $(dir $@)
e9abea04 131 $(lipo) -create -output $@ $^
3370d0c0 132
ee02290f 133Cycript_/libcycript-sys.dylib:
6219596c 134 @mkdir -p $(dir $@)
3370d0c0
JF
135 ln -sf libcycript.dylib $@
136
3615a2f7 137Cycript_/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib
6219596c 138 @mkdir -p $(dir $@)
3370d0c0 139 cp -af $< $@
cd0c51c7 140 codesign -s $(codesign) $@
3370d0c0 141
6219596c
JF
142libcycript-%.o: build.%/.libs/libcycript.a
143 @mkdir -p $(dir $@)
e9abea04 144 ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load $< libffi.a
3370d0c0 145
3615a2f7 146libcycript.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 147 $(lipo) -create -output $@ $^
3370d0c0 148
6219596c 149Cycript.framework/Cycript: libcycript.o
7d894647
JF
150 @mkdir -p $(dir $@)
151 cp -a $< $@
152
153Cycript.framework/Headers/Cycript.h: Cycript.h
154 @mkdir -p $(dir $@)
155 cp -a $< $@
156
3370d0c0
JF
157cycript: cycript.in
158 cp -af $< $@
159 chmod 755 $@
160
7d894647 161.PHONY: all clean package