]> git.saurik.com Git - cydia.git/blob - makefile
Fix awkward build cycling from using new pngcrush.
[cydia.git] / makefile
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 lapt :=
12
13 ifeq ($(doIA),yes)
14 kind := iphonesimulator
15 arch := x86_64
16 else
17 kind := iphoneos
18 arch := arm64
19 endif
20
21 gxx := $(shell xcrun --sdk $(kind) -f g++)
22 cycc := $(gxx)
23
24 sdk := $(shell xcodebuild -sdk $(kind) -version Path)
25 mac := $(shell xcodebuild -sdk macosx -version Path)
26
27 cycc += -isysroot $(sdk)
28 cycc += -idirafter $(mac)/usr/include
29 cycc += -F$(sdk)/System/Library/PrivateFrameworks
30
31 ifeq ($(doIA),yes)
32 cycc += -Xarch_x86_64 -F$(sdk)/../../../../iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks
33 endif
34
35 cycc += -include system.h
36
37 cycc += -fmessage-length=0
38 cycc += -gfull -O2
39 cycc += -fvisibility=hidden
40
41 link += -Wl,-dead_strip
42 link += -Wl,-no_dead_strip_inits_and_terms
43
44 iapt :=
45 iapt += -Iapt32
46 iapt += -Iapt32-contrib
47 iapt += -Iapt32-deb
48 iapt += -Iapt-extra
49 iapt += -IObjects/apt32
50
51 ifeq ($(do32),yes)
52 flag += $(patsubst %,-Xarch_armv6 %,$(iapt))
53 endif
54
55 flag += $(patsubst %,-Xarch_$(arch) %,$(subst apt32,apt64,$(iapt)))
56
57 flag += -I.
58 flag += -isystem sysroot/usr/include
59
60 flag += -idirafter icu/icuSources/common
61 flag += -idirafter icu/icuSources/i18n
62
63 flag += -Wall
64 flag += -Wno-dangling-else
65 flag += -Wno-deprecated-declarations
66 flag += -Wno-objc-protocol-method-implementation
67 flag += -Wno-logical-op-parentheses
68 flag += -Wno-shift-op-parentheses
69 flag += -Wno-unknown-pragmas
70 flag += -Wno-unknown-warning-option
71
72 plus += -fobjc-call-cxx-cdtors
73 plus += -fvisibility-inlines-hidden
74
75 link += -multiply_defined suppress
76
77 libs += -framework CoreFoundation
78 libs += -framework CoreGraphics
79 libs += -framework Foundation
80 libs += -framework GraphicsServices
81 libs += -framework IOKit
82 libs += -framework QuartzCore
83 libs += -framework SpringBoardServices
84 libs += -framework SystemConfiguration
85 libs += -framework WebKit
86
87 libs += -framework CFNetwork
88
89 ifeq ($(do32),yes)
90 libs += -framework WebCore
91 libs += -llockdown
92 libs += -Xarch_armv6 -Wl,-force_load,Objects/libapt32.a
93 lapt += Objects/libapt32.a
94 endif
95
96 libs += -Xarch_$(arch) -Wl,-force_load,Objects/libapt64.a
97 lapt += Objects/libapt64.a
98
99 libs += -licucore
100
101 uikit :=
102 uikit += -framework UIKit
103
104 dirs := Menes CyteKit Cydia SDURLCache
105
106 code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext))))
107 code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code))
108 code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm DiskUsage.cpp
109
110 code += gpgv.cc
111 code += http.cc
112
113 source := $(filter %.m,$(code)) $(filter %.mm,$(code))
114 source += $(filter %.c,$(code)) $(filter %.cpp,$(code)) $(filter %.cc,$(code))
115 header := $(filter %.h,$(code)) $(filter %.hpp,$(code)) $(filter %.hh,$(code))
116
117 object := $(source)
118 object := $(object:.c=.o)
119 object := $(object:.cpp=.o)
120 object := $(object:.cc=.o)
121 object := $(object:.m=.o)
122 object := $(object:.mm=.o)
123 object := $(object:%=Objects/%)
124
125 methods := copy file rred
126
127 libapt32 :=
128 libapt32 += $(wildcard apt32/apt-pkg/*.cc)
129 libapt32 += $(wildcard apt32/apt-pkg/deb/*.cc)
130 libapt32 += $(wildcard apt32/apt-pkg/contrib/*.cc)
131 libapt32 += apt32/methods/gzip.cc
132 libapt32 += $(patsubst %,apt32/methods/%.cc,$(methods))
133 libapt32 := $(patsubst %.cc,Objects/%.o,$(libapt32))
134
135 libapt64 :=
136 libapt64 += $(wildcard apt64/apt-pkg/*.cc)
137 libapt64 += $(wildcard apt64/apt-pkg/deb/*.cc)
138 libapt64 += $(wildcard apt64/apt-pkg/contrib/*.cc)
139 libapt64 += apt64/apt-pkg/tagfile-keys.cc
140 libapt64 += apt64/methods/store.cc
141 libapt64 += $(patsubst %,apt64/methods/%.cc,$(methods))
142 libapt64 := $(filter-out %/srvrec.cc,$(libapt64))
143 libapt64 := $(patsubst %.cc,Objects/%.o,$(libapt64))
144
145 link += -Wl,-liconv
146 link += -Xarch_$(arch) -Wl,-lz
147
148 flag += -DAPT_PKG_EXPOSE_STRING_VIEW
149 flag += -Dsighandler_t=sig_t
150
151 ifeq ($(do32),yes)
152 flag32 :=
153 flag32 += -arch armv6
154 flag32 += -Xarch_armv6 -miphoneos-version-min=2.0
155 flag32 += -Xarch_armv6 -marm # @synchronized
156 flag32 += -Xarch_armv6 -mcpu=arm1176jzf-s
157 flag32 += -mllvm -arm-reserve-r9
158
159 link += -Xarch_armv6 -Wl,-lgcc_s.1
160 link += -Xarch_armv6 -Wl,-segalign,4000
161
162 apt32 := $(cycc) $(flag32) $(flag)
163 apt32 += -Wno-deprecated-register
164 apt32 += -Wno-format-security
165 apt32 += -Wno-tautological-compare
166 apt32 += -Wno-uninitialized
167 apt32 += -Wno-unused-private-field
168 apt32 += -Wno-unused-variable
169 endif
170
171 flag64 :=
172 flag64 += -arch $(arch)
173 flag64 += -Xarch_$(arch) -m$(kind)-version-min=7.0
174
175 apt64 := $(cycc) $(flag64) $(flag)
176 apt64 += -include apt.h
177 apt64 += -Wno-deprecated-register
178 apt64 += -Wno-unused-private-field
179 apt64 += -Wno-unused-variable
180
181 eapt := -include apt.h
182 apt64 += $(eapt)
183 eapt += -D'VERSION="0.7.25.3"'
184 apt32 += $(eapt)
185 eapt += -Wno-format
186 eapt += -Wno-logical-op-parentheses
187 iapt += $(eapt)
188
189 ifeq ($(do32),yes)
190 cycc += $(flag32)
191 endif
192
193 cycc += $(flag64)
194
195 plus += -std=c++11
196
197 images := $(shell find MobileCydia.app/ -type f -name '*.png')
198 images := $(images:%=Images/%)
199
200 lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
201
202 all: MobileCydia
203
204 clean:
205 rm -f MobileCydia postinst
206 rm -rf Objects/ Images/
207
208 Objects/apt64/apt-pkg/tagfile.o: Objects/apt64/apt-pkg/tagfile-keys.h
209 Objects/apt64/apt-pkg/deb/deblistparser.o: Objects/apt64/apt-pkg/tagfile-keys.h
210
211 Objects/apt64/apt-pkg/tagfile-keys%h apt64/apt-pkg/tagfile-keys%cc:
212 mkdir -p apt64
213 mkdir -p Objects/apt64/apt-pkg
214 cd apt64 && ../apt64/triehash/triehash.pl \
215 --ignore-case \
216 --header ../Objects/apt64/apt-pkg/tagfile-keys.h \
217 --code apt-pkg/tagfile-keys.cc \
218 --enum-class \
219 --enum-name pkgTagSection::Key \
220 --function-name pkgTagHash \
221 --include "<apt-pkg/tagfile.h>" \
222 ../apt64/apt-pkg/tagfile-keys.list
223 sed -i -e 's@typedef char static_assert64@//\\0@' apt64/apt-pkg/tagfile-keys.cc
224
225 Objects/%.o: %.cc $(header)
226 @mkdir -p $(dir $@)
227 @echo "[cycc] $<"
228 @$(cycc) $(plus) -c -o $@ $< $(flag) -Wno-format -include apt.h -Dmain=main_$(basename $(notdir $@))
229
230 Objects/apt32/%.o: apt32/%.cc $(header) apt.h apt-extra/*.h
231 @mkdir -p $(dir $@)
232 @echo "[cycc] $<"
233 @$(apt32) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
234
235 Objects/apt64/%.o: apt64/%.cc $(header) apt.h apt-extra/*.h
236 @mkdir -p $(dir $@)
237 @echo "[cycc] $<"
238 @$(apt64) $(plus) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
239
240 Objects/%.o: %.c $(header)
241 @mkdir -p $(dir $@)
242 @echo "[cycc] $<"
243 @$(cycc) -c -o $@ -x c $< $(flag)
244
245 Objects/%.o: %.m $(header)
246 @mkdir -p $(dir $@)
247 @echo "[cycc] $<"
248 @$(cycc) -c -o $@ $< $(flag)
249
250 Objects/%.o: %.cpp $(header)
251 @mkdir -p $(dir $@)
252 @echo "[cycc] $<"
253 @$(cycc) $(plus) -c -o $@ $< $(flag)
254
255 Objects/%.o: %.mm $(header)
256 @mkdir -p $(dir $@)
257 @echo "[cycc] $<"
258 @$(cycc) $(plus) -c -o $@ $< $(flag)
259
260 Objects/Version.o: Version.h
261
262 Images/%.png: %.png
263 @mkdir -p $(dir $@)
264 @echo "[pngc] $<"
265 @./pngcrush.sh $< $@
266 @touch $@
267
268 sysroot: sysroot.sh
269 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
270 @echo 1>&2
271 @exit 1
272
273 Objects/libapt32.a: $(libapt32)
274 @echo "[arch] $@"
275 @ar -rc $@ $^
276
277 Objects/libapt64.a: $(libapt64)
278 @echo "[arch] $@"
279 @ar -rc $@ $^
280
281 MobileCydia: $(object) entitlements.xml $(lapt)
282 @echo "[link] $@"
283 @$(cycc) -o $@ $(filter %.o,$^) $(link) $(libs) $(uikit) -Wl,-sdk_version,8.0
284 @mkdir -p bins
285 @cp -a $@ bins/$@-$(version)_$(shell date +%s)
286 @echo "[strp] $@"
287 @grep '~' <<<"$(version)" >/dev/null && echo "skipping..." || strip $@
288 @echo "[uikt] $@"
289 @./uikit.sh $@
290 @echo "[sign] $@"
291 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
292
293 cfversion: cfversion.mm
294 $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation
295 @ldid -T0 -S $@
296
297 setnsfpn: setnsfpn.cpp
298 $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link)
299 @ldid -T0 -S $@
300
301 cydo: cydo.cpp
302 $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings
303 @ldid -T0 -S $@
304
305 postinst: postinst.mm CyteKit/stringWith.mm CyteKit/stringWith.h CyteKit/UCPlatform.h
306 $(cycc) $(plus) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation -framework Foundation -framework UIKit
307 @ldid -T0 -S $@
308
309 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
310 sudo rm -rf _
311 mkdir -p _/var/lib/cydia
312
313 mkdir -p _/etc/apt
314 mkdir _/etc/apt/apt.conf.d
315 mkdir _/etc/apt/preferences.d
316 cp -a Trusted.gpg _/etc/apt/trusted.gpg.d
317 cp -a Sources.list _/etc/apt/sources.list.d
318
319 mkdir -p _/usr/libexec
320 cp -a Library _/usr/libexec/cydia
321 cp -a sysroot/usr/bin/du _/usr/libexec/cydia
322 cp -a cfversion _/usr/libexec/cydia
323 cp -a setnsfpn _/usr/libexec/cydia
324
325 cp -a cydo _/usr/libexec/cydia
326
327 mkdir -p _/Library
328 cp -a LaunchDaemons _/Library/LaunchDaemons
329
330 mkdir -p _/Applications
331 cp -a MobileCydia.app _/Applications/Cydia.app
332 rm -rf _/Applications/Cydia.app/*.lproj
333 cp -a MobileCydia _/Applications/Cydia.app/Cydia
334
335 for meth in bzip2 gzip lzma gpgv http https store $(methods); do ln -s Cydia _/Applications/Cydia.app/"$${meth}"; done
336
337 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
338
339 mkdir -p _/Applications/Cydia.app/Sources
340 ln -s /usr/share/bigboss/icons/bigboss.png _/Applications/Cydia.app/Sources/apt.bigboss.us.com.png
341 ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png"
342
343 mkdir -p _/DEBIAN
344 ./control.sh cydia.control _ >_/DEBIAN/control
345 cp -a preinst postinst _/DEBIAN/
346
347 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
348
349 sudo chown -R 0 _
350 sudo chgrp -R 0 _
351 sudo chmod 6755 _/usr/libexec/cydia/cydo
352
353 mkdir -p debs
354 ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb
355 $(dpkg) -b _ Cydia.deb
356 @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)"
357
358 $(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
359 sudo rm -rf __
360 mkdir -p __/Applications/Cydia.app
361
362 cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app
363
364 mkdir -p __/DEBIAN
365 ./control.sh cydia-lproj.control __ >__/DEBIAN/control
366
367 sudo chown -R 0 __
368 sudo chgrp -R 0 __
369
370 mkdir -p debs
371 ln -sf debs/cydia-lproj_$(version)_iphoneos-arm.deb Cydia_.deb
372 $(dpkg) -b __ Cydia_.deb
373 @echo "$$(stat -L -f "%z" Cydia_.deb) $$(stat -f "%Y" Cydia_.deb)"
374
375 package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
376
377 .PHONY: all clean package