]> git.saurik.com Git - cycript.git/blame_incremental - apple.mk
Avoid error caused by passing -pthread to libtool.
[cycript.git] / apple.mk
... / ...
CommitLineData
1# Cycript - Optimizing JavaScript Compiler/Runtime
2# Copyright (C) 2009-2014 Jay Freeman (saurik)
3
4# GNU Affero General Public License, Version 3 {{{
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18# }}}
19
20.SECONDARY:
21.DELETE_ON_ERROR:
22SHELL := /bin/bash
23
24include codesign.mk
25
26lipo := $(shell xcrun --sdk iphoneos -f lipo)
27
28monotonic := $(shell git log -1 --pretty=format:%ct)
29version := $(shell git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g')
30
31deb := cycript_$(version)_iphoneos-arm.deb
32zip := cycript_$(version).zip
33
34cycript :=
35cycript += Cycript.lib/cycript
36cycript += Cycript.lib/cycript0.9
37cycript += Cycript.lib/libcycript.dylib
38cycript += Cycript.lib/libcycript-sys.dylib
39cycript += Cycript.lib/libcycript-sim.dylib
40
41framework :=
42framework += Cycript
43framework += Headers/Cycript.h
44
45framework := $(foreach os,ios osx,$(foreach file,$(framework),Cycript.$(os)/Cycript.framework/$(file)))
46
47links :=
48links += Cycript.lib/cynject
49links += Cycript.lib/libsubstrate.dylib
50links += Cycript.lib/cycript0.9
51
52all := cycript $(cycript) $(framework)
53all: $(all)
54
55$(zip): $(all)
56 rm -f $@
57 zip -r9y $@ cycript Cycript.lib Cycript.{ios,osx} $(patsubst %,--exclude %,$(links))
58 zip -r9 $@ $(links)
59
60zip: $(zip)
61 ln -sf $< cycript.zip
62
63$(deb): Cycript.lib/cycript Cycript.lib/libcycript.dylib
64 rm -rf package
65 mkdir -p package/DEBIAN
66 sed -e 's/#/$(version)/' control.in >package/DEBIAN/control
67 mkdir -p package/usr/{bin,lib}
68 cp -a modules package/usr/lib/cycript0.9
69 $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript.lib/cycript
70 $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript.lib/libcycript.dylib
71 ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib
72 dpkg-deb -Zlzma -b package $@
73
74deb: $(deb)
75 ln -sf $< cycript.deb
76
77clean:
78 rm -rf cycript Cycript.lib libcycript*.o
79
80# make stubbornly refuses to believe that these @'s are bugs
81# http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html
82
83define build_any
84.PHONY: build-$(1)-$(2)
85build-$(1)-$(2):
86 $$(MAKE) -C build.$(1)-$(2)
87build.$(1)-$(2)/.libs/libcycript.a: build-$(1)-$(2)
88 @
89endef
90
91define build_lib
92build.$(1)-$(2)/.libs/libcycript.dylib: build-$(1)-$(2)
93 @
94endef
95
96define build_osx
97$(call build_any,osx,$(1))
98$(call build_lib,osx,$(1))
99build.osx-$(1)/.libs/cycript: build-osx-$(1)
100 @
101endef
102
103$(foreach arch,i386 x86_64,$(eval $(call build_osx,$(arch))))
104
105define build_ios
106$(call build_any,ios,$(1))
107endef
108
109$(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch))))
110
111define build_sim
112$(call build_any,sim,$(1))
113$(call build_lib,sim,$(1))
114endef
115
116$(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch))))
117
118define build_arm
119build.ios-$(1)/.libs/cycript: build-ios-$(1)
120 @
121endef
122
123$(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
124
125define build_arm
126$(call build_lib,ios,$(1))
127endef
128
129$(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch))))
130
131Cycript.lib/libcycript.dylib: build.osx-i386/.libs/libcycript.dylib build.osx-x86_64/.libs/libcycript.dylib build.ios-armv6/.libs/libcycript.dylib build.ios-arm64/.libs/libcycript.dylib
132 @mkdir -p $(dir $@)
133 $(lipo) -create -output $@ $^
134 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
135 codesign -s $(codesign) $@
136
137%_: %
138 @cp -af $< $@
139 install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
140 codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@
141
142Cycript.lib/%: build.osx-i386/.libs/%_ build.osx-x86_64/.libs/%_ build.ios-armv6/.libs/%_
143 @mkdir -p $(dir $@)
144 $(lipo) -create -output $@ $^
145
146Cycript.lib/libcycript-sys.dylib:
147 @mkdir -p $(dir $@)
148 ln -sf libcycript.dylib $@
149
150Cycript.lib/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib
151 @mkdir -p $(dir $@)
152 $(lipo) -create -output $@ $^
153 codesign -s $(codesign) $@
154
155libcycript-%.o: build.%/.libs/libcycript.a xcode.map
156 @mkdir -p $(dir $@)
157 ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load -exported_symbols_list xcode.map $< libffi.a
158
159libcycript-ios.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
160 $(lipo) -create -output $@ $^
161
162libcycript-osx.o: libcycript-osx-i386.o libcycript-osx-x86_64.o
163 $(lipo) -create -output $@ $^
164
165Cycript.%/Cycript.framework/Cycript: libcycript-%.o
166 @mkdir -p $(dir $@)
167 cp -a $< $@
168
169Cycript.%/Cycript.framework/Headers/Cycript.h: Cycript.h
170 @mkdir -p $(dir $@)
171 cp -a $< $@
172
173Cycript.lib/cycript0.9:
174 @mkdir -p $(dir $@)
175 ln -s ../modules $@
176
177cycript: cycript.in
178 cp -af $< $@
179 chmod 755 $@
180
181install: Cycript.lib/cycript Cycript.lib/libcycript.dylib Cycript.lib/libcycript-sys.dylib Cycript.lib/libcycript-sim.dylib
182 sudo cp -af $(filter-out %.dylib,$^) /usr/bin
183 sudo cp -af $(filter %.dylib,$^) /usr/lib
184
185
186cast: $(zip)
187 appcast.sh cycript/mac $(monotonic) $(version) $< "$(CYCRIPT_CHANGES)"
188
189.PHONY: all cast clean install zip