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