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