]> git.saurik.com Git - cycript.git/blame - xcode.mk
Slightly clean up the Xcode build definitions.
[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
e9abea04
JF
23lipo := $(shell xcrun --sdk iphoneos -f lipo)
24
3370d0c0
JF
25libs :=
26libs += .libs/cycript
27libs += .libs/libcycript.dylib
28libs += .libs/libcycript-any.dylib
29libs += .libs/libcycript-sys.dylib
30libs += .libs/libcycript-sim.dylib
31libs += .libs/libcycript.o
32
33all: cycript $(libs)
34
35clean:
36 rm -rf cycript .libs
37
3370d0c0
JF
38# make stubbornly refuses to believe that these @'s are bugs
39# http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html
40
abc804fa
JF
41define build_mac
42.PHONY: build-mac-$(1)
43build-mac-$(1):
44 $(MAKE) -C build.mac-$(1)
45build.mac-$(1)/.libs/cycript: build-mac-$(1)
3370d0c0 46 @
abc804fa 47build.mac-$(1)/.libs/libcycript.dylib: build-mac-$(1)
3370d0c0 48 @
abc804fa 49build.mac-$(1)/.libs/libcycript-any.dylib: build-mac-$(1)
3370d0c0 50 @
abc804fa 51endef
3370d0c0 52
abc804fa
JF
53$(foreach arch,i386 x86_64,$(eval $(call build_mac,$(arch))))
54
55define build_ios
56.PHONY: build-ios-$(1)
57build-ios-$(1):
58 $(MAKE) -C build.ios-$(1)
abc804fa 59build.ios-$(1)/.libs/libcycript.a: build-ios-$(1)
3370d0c0 60 @
abc804fa
JF
61endef
62
e9abea04 63$(foreach arch,armv6 armv7 armv7s,$(eval $(call build_ios,$(arch))))
3370d0c0 64
abc804fa
JF
65define build_sim
66.PHONY: build-sim-$(1)
67build-sim-$(1):
68 $(MAKE) -C build.sim-$(1)
69build.sim-$(1)/.libs/libcycript.dylib: build-sim-$(1)
3370d0c0 70 @
abc804fa 71build.sim-$(1)/.libs/libcycript.a: build-sim-$(1)
3370d0c0 72 @
abc804fa
JF
73endef
74
75$(foreach arch,i386,$(eval $(call build_sim,$(arch))))
3370d0c0 76
1510e2d9
JF
77define build_arm
78build.ios-$(1)/.libs/cycript: build-ios-$(1)
79 @
80build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1)
81 @
82build.ios-$(1)/.libs/libcycript-any.dylib: build-ios-$(1)
83 @
84endef
85
86$(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
87
abc804fa 88.libs/%: build.mac-i386/.libs/% build.mac-x86_64/.libs/% build.ios-armv6/.libs/%
3370d0c0 89 @mkdir -p .libs
e9abea04 90 $(lipo) -create -output $@ $^
3370d0c0
JF
91
92.libs/libcycript-sys.dylib:
93 @mkdir -p .libs
94 ln -sf libcycript.dylib $@
95
abc804fa 96.libs/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib
3370d0c0
JF
97 @mkdir -p .libs
98 cp -af $< $@
99
100.libs/libcycript-%.o: build.%/.libs/libcycript.a
101 @mkdir -p .libs
e9abea04 102 ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load $< libffi.a
3370d0c0 103
e9abea04
JF
104.libs/libcycript.o: .libs/libcycript-ios-armv6.o .libs/libcycript-ios-armv7.o .libs/libcycript-ios-armv7s.o .libs/libcycript-sim-i386.o
105 $(lipo) -create -output $@ $^
3370d0c0
JF
106
107cycript: cycript.in
108 cp -af $< $@
109 chmod 755 $@
110
abc804fa 111.PHONY: all clean