]> git.saurik.com Git - cydia.git/blame - makefile
Fix awkward build cycling from using new pngcrush.
[cydia.git] / makefile
CommitLineData
0209cce5
JF
1.DELETE_ON_ERROR:
2.SECONDARY:
3
4dpkg := dpkg-deb -Zlzma
5version := $(shell ./version.sh)
4cc9e99a 6
0209cce5
JF
7flag :=
8plus :=
c21004b9 9link :=
543e172a 10libs :=
533d9675 11lapt :=
c21004b9 12
136cc0a2
JF
13ifeq ($(doIA),yes)
14kind := iphonesimulator
15arch := x86_64
16else
17kind := iphoneos
18arch := arm64
19endif
20
21gxx := $(shell xcrun --sdk $(kind) -f g++)
0209cce5
JF
22cycc := $(gxx)
23
136cc0a2 24sdk := $(shell xcodebuild -sdk $(kind) -version Path)
c935a078
JF
25mac := $(shell xcodebuild -sdk macosx -version Path)
26
0209cce5 27cycc += -isysroot $(sdk)
c935a078 28cycc += -idirafter $(mac)/usr/include
0209cce5
JF
29cycc += -F$(sdk)/System/Library/PrivateFrameworks
30
136cc0a2
JF
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
533d9675
JF
35cycc += -include system.h
36
0209cce5
JF
37cycc += -fmessage-length=0
38cycc += -gfull -O2
39cycc += -fvisibility=hidden
ee4120ad 40
0209cce5
JF
41link += -Wl,-dead_strip
42link += -Wl,-no_dead_strip_inits_and_terms
4cc9e99a 43
2d7ece6e
JF
44iapt :=
45iapt += -Iapt32
46iapt += -Iapt32-contrib
47iapt += -Iapt32-deb
48iapt += -Iapt-extra
49iapt += -IObjects/apt32
50
533d9675 51ifeq ($(do32),yes)
2d7ece6e 52flag += $(patsubst %,-Xarch_armv6 %,$(iapt))
533d9675
JF
53endif
54
136cc0a2 55flag += $(patsubst %,-Xarch_$(arch) %,$(subst apt32,apt64,$(iapt)))
8e57d50b 56
0209cce5
JF
57flag += -I.
58flag += -isystem sysroot/usr/include
4cc9e99a 59
0209cce5
JF
60flag += -idirafter icu/icuSources/common
61flag += -idirafter icu/icuSources/i18n
7c8912f8 62
0209cce5
JF
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
c21004b9 74
c21004b9 75link += -multiply_defined suppress
5f6bff8c 76
543e172a
JF
77libs += -framework CoreFoundation
78libs += -framework CoreGraphics
79libs += -framework Foundation
80libs += -framework GraphicsServices
81libs += -framework IOKit
543e172a
JF
82libs += -framework QuartzCore
83libs += -framework SpringBoardServices
84libs += -framework SystemConfiguration
543e172a
JF
85libs += -framework WebKit
86
2d7ece6e 87libs += -framework CFNetwork
2d7ece6e 88
533d9675 89ifeq ($(do32),yes)
136cc0a2
JF
90libs += -framework WebCore
91libs += -llockdown
429e511d 92libs += -Xarch_armv6 -Wl,-force_load,Objects/libapt32.a
533d9675
JF
93lapt += Objects/libapt32.a
94endif
95
136cc0a2 96libs += -Xarch_$(arch) -Wl,-force_load,Objects/libapt64.a
533d9675 97lapt += Objects/libapt64.a
429e511d 98
8e57d50b 99libs += -licucore
543e172a 100
e17a8c4f
JF
101uikit :=
102uikit += -framework UIKit
103
7c8912f8
JF
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))
e40620ab 108code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm DiskUsage.cpp
7c8912f8 109
2d7ece6e
JF
110code += gpgv.cc
111code += http.cc
112
7c8912f8 113source := $(filter %.m,$(code)) $(filter %.mm,$(code))
2d7ece6e
JF
114source += $(filter %.c,$(code)) $(filter %.cpp,$(code)) $(filter %.cc,$(code))
115header := $(filter %.h,$(code)) $(filter %.hpp,$(code)) $(filter %.hh,$(code))
7c8912f8
JF
116
117object := $(source)
118object := $(object:.c=.o)
119object := $(object:.cpp=.o)
2d7ece6e 120object := $(object:.cc=.o)
7c8912f8
JF
121object := $(object:.m=.o)
122object := $(object:.mm=.o)
123object := $(object:%=Objects/%)
124
2d7ece6e
JF
125methods := copy file rred
126
429e511d
JF
127libapt32 :=
128libapt32 += $(wildcard apt32/apt-pkg/*.cc)
129libapt32 += $(wildcard apt32/apt-pkg/deb/*.cc)
130libapt32 += $(wildcard apt32/apt-pkg/contrib/*.cc)
2d7ece6e
JF
131libapt32 += apt32/methods/gzip.cc
132libapt32 += $(patsubst %,apt32/methods/%.cc,$(methods))
429e511d 133libapt32 := $(patsubst %.cc,Objects/%.o,$(libapt32))
0209cce5 134
429e511d
JF
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
2d7ece6e 141libapt64 += $(patsubst %,apt64/methods/%.cc,$(methods))
429e511d
JF
142libapt64 := $(filter-out %/srvrec.cc,$(libapt64))
143libapt64 := $(patsubst %.cc,Objects/%.o,$(libapt64))
144
145link += -Wl,-liconv
136cc0a2 146link += -Xarch_$(arch) -Wl,-lz
0209cce5
JF
147
148flag += -DAPT_PKG_EXPOSE_STRING_VIEW
149flag += -Dsighandler_t=sig_t
150
533d9675 151ifeq ($(do32),yes)
429e511d
JF
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
0209cce5 158
533d9675
JF
159link += -Xarch_armv6 -Wl,-lgcc_s.1
160link += -Xarch_armv6 -Wl,-segalign,4000
429e511d
JF
161
162apt32 := $(cycc) $(flag32) $(flag)
429e511d
JF
163apt32 += -Wno-deprecated-register
164apt32 += -Wno-format-security
165apt32 += -Wno-tautological-compare
166apt32 += -Wno-uninitialized
167apt32 += -Wno-unused-private-field
168apt32 += -Wno-unused-variable
533d9675
JF
169endif
170
171flag64 :=
136cc0a2
JF
172flag64 += -arch $(arch)
173flag64 += -Xarch_$(arch) -m$(kind)-version-min=7.0
429e511d
JF
174
175apt64 := $(cycc) $(flag64) $(flag)
176apt64 += -include apt.h
177apt64 += -Wno-deprecated-register
178apt64 += -Wno-unused-private-field
179apt64 += -Wno-unused-variable
180
2d7ece6e
JF
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
533d9675 189ifeq ($(do32),yes)
429e511d 190cycc += $(flag32)
533d9675
JF
191endif
192
429e511d
JF
193cycc += $(flag64)
194
0209cce5 195plus += -std=c++11
0209cce5 196
4339c9ef 197images := $(shell find MobileCydia.app/ -type f -name '*.png')
8a4d4662
JF
198images := $(images:%=Images/%)
199
915284a6
JF
200lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
201
e17a8c4f 202all: MobileCydia
dc5812ec 203
5f6bff8c 204clean:
eaa9f122 205 rm -f MobileCydia postinst
8a4d4662 206 rm -rf Objects/ Images/
7c8912f8 207
34424c32
JF
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
a3c544a5 210
34424c32 211Objects/apt64/apt-pkg/tagfile-keys%h apt64/apt-pkg/tagfile-keys%cc:
429e511d
JF
212 mkdir -p apt64
213 mkdir -p Objects/apt64/apt-pkg
214 cd apt64 && ../apt64/triehash/triehash.pl \
a3c544a5 215 --ignore-case \
429e511d 216 --header ../Objects/apt64/apt-pkg/tagfile-keys.h \
a3c544a5
JF
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>" \
429e511d 222 ../apt64/apt-pkg/tagfile-keys.list
34424c32 223 sed -i -e 's@typedef char static_assert64@//\\0@' apt64/apt-pkg/tagfile-keys.cc
a3c544a5 224
2d7ece6e
JF
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
429e511d 230Objects/apt32/%.o: apt32/%.cc $(header) apt.h apt-extra/*.h
0209cce5
JF
231 @mkdir -p $(dir $@)
232 @echo "[cycc] $<"
429e511d
JF
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 $@))
0209cce5 239
7c8912f8
JF
240Objects/%.o: %.c $(header)
241 @mkdir -p $(dir $@)
242 @echo "[cycc] $<"
0209cce5 243 @$(cycc) -c -o $@ -x c $< $(flag)
7c8912f8
JF
244
245Objects/%.o: %.m $(header)
246 @mkdir -p $(dir $@)
247 @echo "[cycc] $<"
0209cce5 248 @$(cycc) -c -o $@ $< $(flag)
5f6bff8c 249
e40620ab
JF
250Objects/%.o: %.cpp $(header)
251 @mkdir -p $(dir $@)
252 @echo "[cycc] $<"
0209cce5 253 @$(cycc) $(plus) -c -o $@ $< $(flag)
e40620ab 254
7c8912f8
JF
255Objects/%.o: %.mm $(header)
256 @mkdir -p $(dir $@)
257 @echo "[cycc] $<"
0209cce5 258 @$(cycc) $(plus) -c -o $@ $< $(flag)
e95a1972 259
174327c1 260Objects/Version.o: Version.h
e61d7bfc 261
8a4d4662
JF
262Images/%.png: %.png
263 @mkdir -p $(dir $@)
264 @echo "[pngc] $<"
265 @./pngcrush.sh $< $@
5735c325 266 @touch $@
8a4d4662 267
0d5393af
JF
268sysroot: sysroot.sh
269 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
8a2c6d14
JF
270 @echo 1>&2
271 @exit 1
272
429e511d
JF
273Objects/libapt32.a: $(libapt32)
274 @echo "[arch] $@"
275 @ar -rc $@ $^
276
277Objects/libapt64.a: $(libapt64)
0209cce5
JF
278 @echo "[arch] $@"
279 @ar -rc $@ $^
280
533d9675 281MobileCydia: $(object) entitlements.xml $(lapt)
0209cce5
JF
282 @echo "[link] $@"
283 @$(cycc) -o $@ $(filter %.o,$^) $(link) $(libs) $(uikit) -Wl,-sdk_version,8.0
0dbada51 284 @mkdir -p bins
e7783492 285 @cp -a $@ bins/$@-$(version)_$(shell date +%s)
443b9e05 286 @echo "[strp] $@"
01c1b94c 287 @grep '~' <<<"$(version)" >/dev/null && echo "skipping..." || strip $@
cc31c45d
JF
288 @echo "[uikt] $@"
289 @./uikit.sh $@
7c8912f8 290 @echo "[sign] $@"
9c0eddfd 291 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
03c0f7a9 292
e967efd5 293cfversion: cfversion.mm
0209cce5 294 $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation
e967efd5
JF
295 @ldid -T0 -S $@
296
82e370b3 297setnsfpn: setnsfpn.cpp
0209cce5 298 $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link)
82e370b3
JF
299 @ldid -T0 -S $@
300
232b396b 301cydo: cydo.cpp
0209cce5 302 $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings
232b396b
JF
303 @ldid -T0 -S $@
304
2e362598 305postinst: postinst.mm CyteKit/stringWith.mm CyteKit/stringWith.h CyteKit/UCPlatform.h
0209cce5 306 $(cycc) $(plus) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation -framework Foundation -framework UIKit
2d46d29e 307 @ldid -T0 -S $@
eaa9f122 308
232b396b 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
7e2bd591 310 sudo rm -rf _
03c0f7a9
JF
311 mkdir -p _/var/lib/cydia
312
33e30380 313 mkdir -p _/etc/apt
e79e7ac0
JF
314 mkdir _/etc/apt/apt.conf.d
315 mkdir _/etc/apt/preferences.d
33e30380
JF
316 cp -a Trusted.gpg _/etc/apt/trusted.gpg.d
317 cp -a Sources.list _/etc/apt/sources.list.d
318
03c0f7a9 319 mkdir -p _/usr/libexec
c21004b9 320 cp -a Library _/usr/libexec/cydia
d3b5a983 321 cp -a sysroot/usr/bin/du _/usr/libexec/cydia
e967efd5 322 cp -a cfversion _/usr/libexec/cydia
82e370b3 323 cp -a setnsfpn _/usr/libexec/cydia
03c0f7a9 324
232b396b 325 cp -a cydo _/usr/libexec/cydia
232b396b 326
2eef6631
JF
327 mkdir -p _/Library
328 cp -a LaunchDaemons _/Library/LaunchDaemons
03c0f7a9
JF
329
330 mkdir -p _/Applications
e17a8c4f 331 cp -a MobileCydia.app _/Applications/Cydia.app
915284a6 332 rm -rf _/Applications/Cydia.app/*.lproj
f7f32d9a 333 cp -a MobileCydia _/Applications/Cydia.app/Cydia
2d7ece6e
JF
334
335 for meth in bzip2 gzip lzma gpgv http https store $(methods); do ln -s Cydia _/Applications/Cydia.app/"$${meth}"; done
e17a8c4f 336
8a4d4662
JF
337 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
338
4339c9ef
JF
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
5ad3e6d9
JF
341 ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png"
342
03c0f7a9 343 mkdir -p _/DEBIAN
915284a6 344 ./control.sh cydia.control _ >_/DEBIAN/control
eaa9f122 345 cp -a preinst postinst _/DEBIAN/
03c0f7a9 346
8fec9d25 347 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
7fc02989 348
7e2bd591
JF
349 sudo chown -R 0 _
350 sudo chgrp -R 0 _
0209cce5 351 sudo chmod 6755 _/usr/libexec/cydia/cydo
7e2bd591 352
3adcfba7 353 mkdir -p debs
f9ba524a 354 ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb
3adcfba7 355 $(dpkg) -b _ Cydia.deb
ce0372db 356 @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)"
8cc774c5 357
33e30380 358$(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
915284a6
JF
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
915284a6
JF
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)
aa60b57b 376
10ff7664 377.PHONY: all clean package