]> git.saurik.com Git - cydia.git/blame_incremental - makefile
Objective-C seriously didn't notice my mistake :/.
[cydia.git] / makefile
... / ...
CommitLineData
1.DELETE_ON_ERROR:
2.SECONDARY:
3
4dpkg := dpkg-deb -Zlzma
5version := $(shell ./version.sh)
6
7flag :=
8plus :=
9link :=
10libs :=
11lapt :=
12
13ifeq ($(doIA),yes)
14kind := iphonesimulator
15arch := x86_64
16else
17kind := iphoneos
18arch := arm64
19endif
20
21gxx := $(shell xcrun --sdk $(kind) -f g++)
22cycc := $(gxx)
23
24sdk := $(shell xcodebuild -sdk $(kind) -version Path)
25mac := $(shell xcodebuild -sdk macosx -version Path)
26
27cycc += -isysroot $(sdk)
28cycc += -idirafter $(mac)/usr/include
29cycc += -F$(sdk)/System/Library/PrivateFrameworks
30
31ifeq ($(doIA),yes)
32cycc += -Xarch_x86_64 -F$(sdk)/../../../../iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks
33endif
34
35cycc += -include system.h
36
37cycc += -fmessage-length=0
38cycc += -gfull -O2
39cycc += -fvisibility=hidden
40
41link += -Wl,-dead_strip
42link += -Wl,-no_dead_strip_inits_and_terms
43
44iapt :=
45iapt += -Iapt32
46iapt += -Iapt32-contrib
47iapt += -Iapt32-deb
48iapt += -Iapt-extra
49iapt += -IObjects/apt32
50
51ifeq ($(do32),yes)
52flag += $(patsubst %,-Xarch_armv6 %,$(iapt))
53endif
54
55flag += $(patsubst %,-Xarch_$(arch) %,$(subst apt32,apt64,$(iapt)))
56
57flag += -I.
58flag += -isystem sysroot/usr/include
59
60flag += -idirafter icu/icuSources/common
61flag += -idirafter icu/icuSources/i18n
62
63flag += -Wall
64flag += -Wno-dangling-else
65flag += -Wno-deprecated-declarations
66flag += -Wno-objc-protocol-method-implementation
67flag += -Wno-logical-op-parentheses
68flag += -Wno-shift-op-parentheses
69flag += -Wno-unknown-pragmas
70flag += -Wno-unknown-warning-option
71
72plus += -fobjc-call-cxx-cdtors
73plus += -fvisibility-inlines-hidden
74
75link += -multiply_defined suppress
76
77libs += -framework CoreFoundation
78libs += -framework CoreGraphics
79libs += -framework Foundation
80libs += -framework GraphicsServices
81libs += -framework IOKit
82libs += -framework QuartzCore
83libs += -framework SpringBoardServices
84libs += -framework SystemConfiguration
85libs += -framework WebKit
86
87libs += -framework CFNetwork
88
89ifeq ($(do32),yes)
90libs += -framework WebCore
91libs += -llockdown
92libs += -Xarch_armv6 -Wl,-force_load,Objects/libapt32.a
93lapt += Objects/libapt32.a
94endif
95
96libs += -Xarch_$(arch) -Wl,-force_load,Objects/libapt64.a
97lapt += Objects/libapt64.a
98
99libs += -licucore
100
101uikit :=
102uikit += -framework UIKit
103
104dirs := Menes CyteKit Cydia SDURLCache
105
106code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext))))
107code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code))
108code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm DiskUsage.cpp
109
110code += gpgv.cc
111code += http.cc
112
113source := $(filter %.m,$(code)) $(filter %.mm,$(code))
114source += $(filter %.c,$(code)) $(filter %.cpp,$(code)) $(filter %.cc,$(code))
115header := $(filter %.h,$(code)) $(filter %.hpp,$(code)) $(filter %.hh,$(code))
116
117object := $(source)
118object := $(object:.c=.o)
119object := $(object:.cpp=.o)
120object := $(object:.cc=.o)
121object := $(object:.m=.o)
122object := $(object:.mm=.o)
123object := $(object:%=Objects/%)
124
125methods := copy file rred
126
127libapt32 :=
128libapt32 += $(wildcard apt32/apt-pkg/*.cc)
129libapt32 += $(wildcard apt32/apt-pkg/deb/*.cc)
130libapt32 += $(wildcard apt32/apt-pkg/contrib/*.cc)
131libapt32 += apt32/methods/gzip.cc
132libapt32 += $(patsubst %,apt32/methods/%.cc,$(methods))
133libapt32 := $(patsubst %.cc,Objects/%.o,$(libapt32))
134
135libapt64 :=
136libapt64 += $(wildcard apt64/apt-pkg/*.cc)
137libapt64 += $(wildcard apt64/apt-pkg/deb/*.cc)
138libapt64 += $(wildcard apt64/apt-pkg/contrib/*.cc)
139libapt64 += apt64/apt-pkg/tagfile-keys.cc
140libapt64 += apt64/methods/store.cc
141libapt64 += $(patsubst %,apt64/methods/%.cc,$(methods))
142libapt64 := $(filter-out %/srvrec.cc,$(libapt64))
143libapt64 := $(patsubst %.cc,Objects/%.o,$(libapt64))
144
145link += -Wl,-liconv
146link += -Xarch_$(arch) -Wl,-lz
147
148flag += -DAPT_PKG_EXPOSE_STRING_VIEW
149flag += -Dsighandler_t=sig_t
150
151ifeq ($(do32),yes)
152flag32 :=
153flag32 += -arch armv6
154flag32 += -Xarch_armv6 -miphoneos-version-min=2.0
155flag32 += -Xarch_armv6 -marm # @synchronized
156flag32 += -Xarch_armv6 -mcpu=arm1176jzf-s
157flag32 += -mllvm -arm-reserve-r9
158
159link += -Xarch_armv6 -Wl,-lgcc_s.1
160link += -Xarch_armv6 -Wl,-segalign,4000
161
162apt32 := $(cycc) $(flag32) $(flag)
163apt32 += -Wno-deprecated-register
164apt32 += -Wno-format-security
165apt32 += -Wno-tautological-compare
166apt32 += -Wno-uninitialized
167apt32 += -Wno-unused-private-field
168apt32 += -Wno-unused-variable
169endif
170
171flag64 :=
172flag64 += -arch $(arch)
173flag64 += -Xarch_$(arch) -m$(kind)-version-min=7.0
174
175apt64 := $(cycc) $(flag64) $(flag)
176apt64 += -include apt.h
177apt64 += -Wno-deprecated-register
178apt64 += -Wno-unused-private-field
179apt64 += -Wno-unused-variable
180
181eapt := -include apt.h
182apt64 += $(eapt)
183eapt += -D'VERSION="0.7.25.3"'
184apt32 += $(eapt)
185eapt += -Wno-format
186eapt += -Wno-logical-op-parentheses
187iapt += $(eapt)
188
189ifeq ($(do32),yes)
190cycc += $(flag32)
191endif
192
193cycc += $(flag64)
194
195plus += -std=c++11
196
197images := $(shell find MobileCydia.app/ -type f -name '*.png')
198images := $(images:%=Images/%)
199
200lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
201
202all: MobileCydia
203
204clean:
205 rm -f MobileCydia postinst
206 rm -rf Objects/ Images/
207
208Objects/apt64/apt-pkg/tagfile.o: Objects/apt64/apt-pkg/tagfile-keys.h
209Objects/apt64/apt-pkg/deb/deblistparser.o: Objects/apt64/apt-pkg/tagfile-keys.h
210
211Objects/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
225Objects/%.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
230Objects/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
235Objects/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
240Objects/%.o: %.c $(header)
241 @mkdir -p $(dir $@)
242 @echo "[cycc] $<"
243 @$(cycc) -c -o $@ -x c $< $(flag)
244
245Objects/%.o: %.m $(header)
246 @mkdir -p $(dir $@)
247 @echo "[cycc] $<"
248 @$(cycc) -c -o $@ $< $(flag)
249
250Objects/%.o: %.cpp $(header)
251 @mkdir -p $(dir $@)
252 @echo "[cycc] $<"
253 @$(cycc) $(plus) -c -o $@ $< $(flag)
254
255Objects/%.o: %.mm $(header)
256 @mkdir -p $(dir $@)
257 @echo "[cycc] $<"
258 @$(cycc) $(plus) -c -o $@ $< $(flag)
259
260Objects/Version.o: Version.h
261
262Images/%.png: %.png
263 @mkdir -p $(dir $@)
264 @echo "[pngc] $<"
265 @./pngcrush.sh $< $@
266 @touch $@
267
268sysroot: 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
273Objects/libapt32.a: $(libapt32)
274 @echo "[arch] $@"
275 @ar -rc $@ $^
276
277Objects/libapt64.a: $(libapt64)
278 @echo "[arch] $@"
279 @ar -rc $@ $^
280
281MobileCydia: $(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
293cfversion: cfversion.mm
294 $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation
295 @ldid -T0 -S $@
296
297setnsfpn: setnsfpn.cpp
298 $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link)
299 @ldid -T0 -S $@
300
301cydo: cydo.cpp
302 $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings
303 @ldid -T0 -S $@
304
305postinst: 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
309debs/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
375package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
376
377.PHONY: all clean package