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