]>
Commit | Line | Data |
---|---|---|
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: | |
21 | SHELL := /bin/bash | |
22 | ||
e9abea04 JF |
23 | lipo := $(shell xcrun --sdk iphoneos -f lipo) |
24 | ||
6219596c | 25 | cycript := |
ee02290f JF |
26 | cycript += Cycript_/cycript |
27 | cycript += Cycript_/libcycript.dylib | |
28 | cycript += Cycript_/libcycript-any.dylib | |
29 | cycript += Cycript_/libcycript-sys.dylib | |
30 | cycript += Cycript_/libcycript-sim.dylib | |
3370d0c0 | 31 | |
7d894647 JF |
32 | framework := |
33 | framework += Cycript.framework/Cycript | |
34 | framework += Cycript.framework/Headers/Cycript.h | |
35 | ||
6219596c | 36 | all: cycript $(cycript) $(framework) |
7d894647 JF |
37 | |
38 | cycript.zip: all | |
39 | rm -f $@ | |
ee02290f | 40 | zip -r9y $@ cycript Cycript_ Cycript.framework |
7d894647 JF |
41 | |
42 | package: cycript.zip | |
3370d0c0 JF |
43 | |
44 | clean: | |
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 |
50 | define build_mac |
51 | .PHONY: build-mac-$(1) | |
52 | build-mac-$(1): | |
53 | $(MAKE) -C build.mac-$(1) | |
54 | build.mac-$(1)/.libs/cycript: build-mac-$(1) | |
3370d0c0 | 55 | @ |
abc804fa | 56 | build.mac-$(1)/.libs/libcycript.dylib: build-mac-$(1) |
3370d0c0 | 57 | @ |
abc804fa | 58 | build.mac-$(1)/.libs/libcycript-any.dylib: build-mac-$(1) |
3370d0c0 | 59 | @ |
abc804fa | 60 | endef |
3370d0c0 | 61 | |
abc804fa JF |
62 | $(foreach arch,i386 x86_64,$(eval $(call build_mac,$(arch)))) |
63 | ||
64 | define build_ios | |
65 | .PHONY: build-ios-$(1) | |
66 | build-ios-$(1): | |
67 | $(MAKE) -C build.ios-$(1) | |
abc804fa | 68 | build.ios-$(1)/.libs/libcycript.a: build-ios-$(1) |
3370d0c0 | 69 | @ |
abc804fa JF |
70 | endef |
71 | ||
e9abea04 | 72 | $(foreach arch,armv6 armv7 armv7s,$(eval $(call build_ios,$(arch)))) |
3370d0c0 | 73 | |
abc804fa JF |
74 | define build_sim |
75 | .PHONY: build-sim-$(1) | |
76 | build-sim-$(1): | |
77 | $(MAKE) -C build.sim-$(1) | |
78 | build.sim-$(1)/.libs/libcycript.dylib: build-sim-$(1) | |
3370d0c0 | 79 | @ |
abc804fa | 80 | build.sim-$(1)/.libs/libcycript.a: build-sim-$(1) |
3370d0c0 | 81 | @ |
abc804fa JF |
82 | endef |
83 | ||
84 | $(foreach arch,i386,$(eval $(call build_sim,$(arch)))) | |
3370d0c0 | 85 | |
1510e2d9 JF |
86 | define build_arm |
87 | build.ios-$(1)/.libs/cycript: build-ios-$(1) | |
88 | @ | |
89 | build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1) | |
90 | @ | |
91 | build.ios-$(1)/.libs/libcycript-any.dylib: build-ios-$(1) | |
92 | @ | |
93 | endef | |
94 | ||
95 | $(foreach arch,armv6,$(eval $(call build_arm,$(arch)))) | |
96 | ||
ee02290f | 97 | Cycript_/%: 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 | 101 | Cycript_/libcycript-sys.dylib: |
6219596c | 102 | @mkdir -p $(dir $@) |
3370d0c0 JF |
103 | ln -sf libcycript.dylib $@ |
104 | ||
ee02290f | 105 | Cycript_/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib |
6219596c | 106 | @mkdir -p $(dir $@) |
3370d0c0 JF |
107 | cp -af $< $@ |
108 | ||
6219596c JF |
109 | libcycript-%.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 | 113 | libcycript.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 | 116 | Cycript.framework/Cycript: libcycript.o |
7d894647 JF |
117 | @mkdir -p $(dir $@) |
118 | cp -a $< $@ | |
119 | ||
120 | Cycript.framework/Headers/Cycript.h: Cycript.h | |
121 | @mkdir -p $(dir $@) | |
122 | cp -a $< $@ | |
123 | ||
3370d0c0 JF |
124 | cycript: cycript.in |
125 | cp -af $< $@ | |
126 | chmod 755 $@ | |
127 | ||
7d894647 | 128 | .PHONY: all clean package |