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