]>
Commit | Line | Data |
---|---|---|
1 | .DELETE_ON_ERROR: | |
2 | .SECONDARY: | |
3 | ||
4 | dpkg := dpkg-deb -Zlzma | |
5 | version := $(shell ./version.sh) | |
6 | ||
7 | flag := | |
8 | plus := | |
9 | link := | |
10 | libs := | |
11 | ||
12 | gxx := $(shell xcrun --sdk iphoneos -f g++) | |
13 | cycc := $(gxx) | |
14 | ||
15 | sdk := $(shell xcodebuild -sdk iphoneos -version Path) | |
16 | cycc += -isysroot $(sdk) | |
17 | cycc += -idirafter /usr/include | |
18 | cycc += -F$(sdk)/System/Library/PrivateFrameworks | |
19 | ||
20 | cycc += -arch arm64 | |
21 | cycc += -Xarch_arm64 -miphoneos-version-min=7.0 | |
22 | ||
23 | cycc += -fmessage-length=0 | |
24 | cycc += -gfull -O2 | |
25 | cycc += -fvisibility=hidden | |
26 | ||
27 | link += -Wl,-dead_strip | |
28 | link += -Wl,-no_dead_strip_inits_and_terms | |
29 | link += -Wl,-s | |
30 | ||
31 | flag += -Xarch_arm64 -Iapt | |
32 | flag += -Xarch_arm64 -Iapt-contrib | |
33 | flag += -Xarch_arm64 -Iapt-deb | |
34 | flag += -Xarch_arm64 -Iapt-extra | |
35 | flag += -Xarch_arm64 -Iapt-tag | |
36 | ||
37 | flag += -I. | |
38 | flag += -isystem sysroot/usr/include | |
39 | ||
40 | flag += -idirafter icu/icuSources/common | |
41 | flag += -idirafter icu/icuSources/i18n | |
42 | ||
43 | flag += -Wall | |
44 | flag += -Wno-dangling-else | |
45 | flag += -Wno-deprecated-declarations | |
46 | flag += -Wno-objc-protocol-method-implementation | |
47 | flag += -Wno-logical-op-parentheses | |
48 | flag += -Wno-shift-op-parentheses | |
49 | flag += -Wno-unknown-pragmas | |
50 | flag += -Wno-unknown-warning-option | |
51 | ||
52 | plus += -fobjc-call-cxx-cdtors | |
53 | plus += -fvisibility-inlines-hidden | |
54 | ||
55 | link += -Lsysroot/usr/lib | |
56 | link += -multiply_defined suppress | |
57 | ||
58 | libs += -framework CoreFoundation | |
59 | libs += -framework CoreGraphics | |
60 | libs += -framework Foundation | |
61 | libs += -framework GraphicsServices | |
62 | libs += -framework IOKit | |
63 | libs += -framework QuartzCore | |
64 | libs += -framework SpringBoardServices | |
65 | libs += -framework SystemConfiguration | |
66 | libs += -framework WebCore | |
67 | libs += -framework WebKit | |
68 | ||
69 | libs += -Xarch_armv6 -Wl,-lapt-pkg | |
70 | libs += -Xarch_arm64 -Wl,Objects/libapt64.a | |
71 | libs += -licucore | |
72 | ||
73 | uikit := | |
74 | uikit += -framework UIKit | |
75 | ||
76 | link += -Wl,-segalign,4000 | |
77 | ||
78 | dirs := Menes CyteKit Cydia SDURLCache | |
79 | ||
80 | code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext)))) | |
81 | code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code)) | |
82 | code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm DiskUsage.cpp | |
83 | ||
84 | source := $(filter %.m,$(code)) $(filter %.mm,$(code)) | |
85 | source += $(filter %.c,$(code)) $(filter %.cpp,$(code)) | |
86 | header := $(filter %.h,$(code)) $(filter %.hpp,$(code)) | |
87 | ||
88 | object := $(source) | |
89 | object := $(object:.c=.o) | |
90 | object := $(object:.cpp=.o) | |
91 | object := $(object:.m=.o) | |
92 | object := $(object:.mm=.o) | |
93 | object := $(object:%=Objects/%) | |
94 | ||
95 | libapt := | |
96 | libapt += $(wildcard apt/apt-pkg/*.cc) | |
97 | libapt += $(wildcard apt/apt-pkg/deb/*.cc) | |
98 | libapt += $(wildcard apt/apt-pkg/contrib/*.cc) | |
99 | libapt += apt-tag/apt-pkg/tagfile-keys.cc | |
100 | libapt += apt/methods/store.cc | |
101 | libapt := $(filter-out %/srvrec.cc,$(libapt)) | |
102 | libapt := $(patsubst %.cc,Objects/%.o,$(libapt)) | |
103 | ||
104 | link += -Xarch_arm64 -Wl,-lz,-liconv | |
105 | ||
106 | flag += -DAPT_PKG_EXPOSE_STRING_VIEW | |
107 | flag += -Dsighandler_t=sig_t | |
108 | ||
109 | aptc := $(cycc) $(flag) | |
110 | aptc += -include apt.h | |
111 | aptc += -Wno-deprecated-register | |
112 | aptc += -Wno-unused-private-field | |
113 | aptc += -Wno-unused-variable | |
114 | ||
115 | cycc += -arch armv6 | |
116 | cycc += -Xarch_armv6 -miphoneos-version-min=2.0 | |
117 | flag += -Xarch_armv6 -marm # @synchronized | |
118 | flag += -Xarch_armv6 -mcpu=arm1176jzf-s | |
119 | flag += -mllvm -arm-reserve-r9 | |
120 | link += -Xarch_armv6 -Wl,-lgcc_s.1 | |
121 | ||
122 | plus += -std=c++11 | |
123 | #plus += -Wp,-stdlib=libc++ | |
124 | #link += libcxx/lib/libc++.a | |
125 | ||
126 | images := $(shell find MobileCydia.app/ -type f -name '*.png') | |
127 | images := $(images:%=Images/%) | |
128 | ||
129 | lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb | |
130 | ||
131 | all: MobileCydia | |
132 | ||
133 | clean: | |
134 | rm -f MobileCydia postinst | |
135 | rm -rf Objects/ Images/ | |
136 | ||
137 | Objects/%.o: %.cc $(header) apt.h apt-extra/*.h | |
138 | @mkdir -p $(dir $@) | |
139 | @echo "[cycc] $<" | |
140 | @$(aptc) $(plus) -c -o $@ $< -Dmain=main_$(basename $(notdir $@)) | |
141 | ||
142 | Objects/%.o: %.c $(header) | |
143 | @mkdir -p $(dir $@) | |
144 | @echo "[cycc] $<" | |
145 | @$(cycc) -c -o $@ -x c $< $(flag) | |
146 | ||
147 | Objects/%.o: %.m $(header) | |
148 | @mkdir -p $(dir $@) | |
149 | @echo "[cycc] $<" | |
150 | @$(cycc) -c -o $@ $< $(flag) | |
151 | ||
152 | Objects/%.o: %.cpp $(header) | |
153 | @mkdir -p $(dir $@) | |
154 | @echo "[cycc] $<" | |
155 | @$(cycc) $(plus) -c -o $@ $< $(flag) | |
156 | ||
157 | Objects/%.o: %.mm $(header) | |
158 | @mkdir -p $(dir $@) | |
159 | @echo "[cycc] $<" | |
160 | @$(cycc) $(plus) -c -o $@ $< $(flag) | |
161 | ||
162 | Objects/Version.o: Version.h | |
163 | ||
164 | Images/%.png: %.png | |
165 | @mkdir -p $(dir $@) | |
166 | @echo "[pngc] $<" | |
167 | @./pngcrush.sh $< $@ | |
168 | ||
169 | sysroot: sysroot.sh | |
170 | @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2 | |
171 | @echo 1>&2 | |
172 | @exit 1 | |
173 | ||
174 | Objects/libapt64.a: $(libapt) | |
175 | @echo "[arch] $@" | |
176 | @ar -rc $@ $^ | |
177 | ||
178 | MobileCydia: sysroot $(object) entitlements.xml Objects/libapt64.a | |
179 | @echo "[link] $@" | |
180 | @$(cycc) -o $@ $(filter %.o,$^) $(link) $(libs) $(uikit) -Wl,-sdk_version,8.0 | |
181 | @mkdir -p bins | |
182 | @cp -a $@ bins/$@-$(version) | |
183 | @echo "[strp] $@" | |
184 | @strip $@ | |
185 | @echo "[uikt] $@" | |
186 | @./uikit.sh $@ | |
187 | @echo "[sign] $@" | |
188 | @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; } | |
189 | ||
190 | cfversion: cfversion.mm | |
191 | $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation | |
192 | @ldid -T0 -S $@ | |
193 | ||
194 | setnsfpn: setnsfpn.cpp | |
195 | $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link) | |
196 | @ldid -T0 -S $@ | |
197 | ||
198 | cydo: cydo.cpp | |
199 | $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings | |
200 | @ldid -T0 -S $@ | |
201 | ||
202 | postinst: postinst.mm CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h | |
203 | $(cycc) $(plus) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation -framework Foundation -framework UIKit | |
204 | @ldid -T0 -S $@ | |
205 | ||
206 | debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst cfversion setnsfpn cydo $(images) $(shell find MobileCydia.app) cydia.control Library/firmware.sh Library/move.sh Library/startup | |
207 | sudo rm -rf _ | |
208 | mkdir -p _/var/lib/cydia | |
209 | ||
210 | mkdir -p _/etc/apt | |
211 | cp -a Trusted.gpg _/etc/apt/trusted.gpg.d | |
212 | cp -a Sources.list _/etc/apt/sources.list.d | |
213 | ||
214 | mkdir -p _/usr/libexec | |
215 | cp -a Library _/usr/libexec/cydia | |
216 | cp -a sysroot/usr/bin/du _/usr/libexec/cydia | |
217 | cp -a cfversion _/usr/libexec/cydia | |
218 | cp -a setnsfpn _/usr/libexec/cydia | |
219 | ||
220 | cp -a cydo _/usr/libexec/cydia | |
221 | ||
222 | mkdir -p _/Library | |
223 | cp -a LaunchDaemons _/Library/LaunchDaemons | |
224 | ||
225 | mkdir -p _/Applications | |
226 | cp -a MobileCydia.app _/Applications/Cydia.app | |
227 | rm -rf _/Applications/Cydia.app/*.lproj | |
228 | cp -a MobileCydia _/Applications/Cydia.app/Cydia | |
229 | ln -s Cydia _/Applications/Cydia.app/store | |
230 | ||
231 | cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';' | |
232 | ||
233 | mkdir -p _/Applications/Cydia.app/Sources | |
234 | ln -s /usr/share/bigboss/icons/bigboss.png _/Applications/Cydia.app/Sources/apt.bigboss.us.com.png | |
235 | ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png" | |
236 | ||
237 | mkdir -p _/DEBIAN | |
238 | ./control.sh cydia.control _ >_/DEBIAN/control | |
239 | cp -a preinst postinst _/DEBIAN/ | |
240 | ||
241 | find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';' | |
242 | ||
243 | sudo chown -R 0 _ | |
244 | sudo chgrp -R 0 _ | |
245 | sudo chmod 6755 _/usr/libexec/cydia/cydo | |
246 | ||
247 | mkdir -p debs | |
248 | ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb | |
249 | $(dpkg) -b _ Cydia.deb | |
250 | @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)" | |
251 | ||
252 | $(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control | |
253 | sudo rm -rf __ | |
254 | mkdir -p __/Applications/Cydia.app | |
255 | ||
256 | cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app | |
257 | ||
258 | mkdir -p __/DEBIAN | |
259 | ./control.sh cydia-lproj.control __ >__/DEBIAN/control | |
260 | ||
261 | sudo chown -R 0 __ | |
262 | sudo chgrp -R 0 __ | |
263 | ||
264 | mkdir -p debs | |
265 | ln -sf debs/cydia-lproj_$(version)_iphoneos-arm.deb Cydia_.deb | |
266 | $(dpkg) -b __ Cydia_.deb | |
267 | @echo "$$(stat -L -f "%z" Cydia_.deb) $$(stat -f "%Y" Cydia_.deb)" | |
268 | ||
269 | package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb) | |
270 | ||
271 | .PHONY: all clean package |