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