]> git.saurik.com Git - cydia.git/blob - makefile
On new Xcode/macOS, /usr/include no longer exists.
[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 mac := $(shell xcodebuild -sdk macosx -version Path)
17
18 cycc += -isysroot $(sdk)
19 cycc += -idirafter $(mac)/usr/include
20 cycc += -F$(sdk)/System/Library/PrivateFrameworks
21
22 cycc += -fmessage-length=0
23 cycc += -gfull -O2
24 cycc += -fvisibility=hidden
25
26 link += -Wl,-dead_strip
27 link += -Wl,-no_dead_strip_inits_and_terms
28
29 iapt :=
30 iapt += -Iapt32
31 iapt += -Iapt32-contrib
32 iapt += -Iapt32-deb
33 iapt += -Iapt-extra
34 iapt += -IObjects/apt32
35
36 flag += $(patsubst %,-Xarch_armv6 %,$(iapt))
37 flag += $(patsubst %,-Xarch_arm64 %,$(subst apt32,apt64,$(iapt)))
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 += -framework CFNetwork
71 libs += -llockdown
72
73 libs += -Xarch_armv6 -Wl,-force_load,Objects/libapt32.a
74 libs += -Xarch_arm64 -Wl,-force_load,Objects/libapt64.a
75
76 libs += -licucore
77
78 uikit :=
79 uikit += -framework UIKit
80
81 link += -Xarch_armv6 -Wl,-segalign,4000
82
83 dirs := Menes CyteKit Cydia SDURLCache
84
85 code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext))))
86 code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code))
87 code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm DiskUsage.cpp
88
89 code += gpgv.cc
90 code += http.cc
91
92 source := $(filter %.m,$(code)) $(filter %.mm,$(code))
93 source += $(filter %.c,$(code)) $(filter %.cpp,$(code)) $(filter %.cc,$(code))
94 header := $(filter %.h,$(code)) $(filter %.hpp,$(code)) $(filter %.hh,$(code))
95
96 object := $(source)
97 object := $(object:.c=.o)
98 object := $(object:.cpp=.o)
99 object := $(object:.cc=.o)
100 object := $(object:.m=.o)
101 object := $(object:.mm=.o)
102 object := $(object:%=Objects/%)
103
104 methods := copy file rred
105
106 libapt32 :=
107 libapt32 += $(wildcard apt32/apt-pkg/*.cc)
108 libapt32 += $(wildcard apt32/apt-pkg/deb/*.cc)
109 libapt32 += $(wildcard apt32/apt-pkg/contrib/*.cc)
110 libapt32 += apt32/methods/gzip.cc
111 libapt32 += $(patsubst %,apt32/methods/%.cc,$(methods))
112 libapt32 := $(patsubst %.cc,Objects/%.o,$(libapt32))
113
114 libapt64 :=
115 libapt64 += $(wildcard apt64/apt-pkg/*.cc)
116 libapt64 += $(wildcard apt64/apt-pkg/deb/*.cc)
117 libapt64 += $(wildcard apt64/apt-pkg/contrib/*.cc)
118 libapt64 += apt64/apt-pkg/tagfile-keys.cc
119 libapt64 += apt64/methods/store.cc
120 libapt64 += $(patsubst %,apt64/methods/%.cc,$(methods))
121 libapt64 := $(filter-out %/srvrec.cc,$(libapt64))
122 libapt64 := $(patsubst %.cc,Objects/%.o,$(libapt64))
123
124 link += -Wl,-liconv
125 link += -Xarch_arm64 -Wl,-lz
126
127 flag += -DAPT_PKG_EXPOSE_STRING_VIEW
128 flag += -Dsighandler_t=sig_t
129
130 flag32 :=
131 flag32 += -arch armv6
132 flag32 += -Xarch_armv6 -miphoneos-version-min=2.0
133 flag32 += -Xarch_armv6 -marm # @synchronized
134 flag32 += -Xarch_armv6 -mcpu=arm1176jzf-s
135 flag32 += -mllvm -arm-reserve-r9
136 link += -Xarch_armv6 -Wl,-lgcc_s.1
137
138 flag64 :=
139 flag64 += -arch arm64
140 flag64 += -Xarch_arm64 -miphoneos-version-min=7.0
141
142 apt32 := $(cycc) $(flag32) $(flag)
143 apt32 += -Wno-deprecated-register
144 apt32 += -Wno-format-security
145 apt32 += -Wno-tautological-compare
146 apt32 += -Wno-uninitialized
147 apt32 += -Wno-unused-private-field
148 apt32 += -Wno-unused-variable
149
150 apt64 := $(cycc) $(flag64) $(flag)
151 apt64 += -include apt.h
152 apt64 += -Wno-deprecated-register
153 apt64 += -Wno-unused-private-field
154 apt64 += -Wno-unused-variable
155
156 eapt := -include apt.h
157 apt64 += $(eapt)
158 eapt += -D'VERSION="0.7.25.3"'
159 apt32 += $(eapt)
160 eapt += -Wno-format
161 eapt += -Wno-logical-op-parentheses
162 iapt += $(eapt)
163
164 cycc += $(flag32)
165 cycc += $(flag64)
166
167 plus += -std=c++11
168
169 images := $(shell find MobileCydia.app/ -type f -name '*.png')
170 images := $(images:%=Images/%)
171
172 lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
173
174 all: MobileCydia
175
176 clean:
177 rm -f MobileCydia postinst
178 rm -rf Objects/ Images/
179
180 Objects/apt64/apt-pkg/tagfile.o: apt64/apt-pkg/tagfile-keys.cc
181 Objects/apt64/apt-pkg/deb/deblistparser.o: apt64/apt-pkg/tagfile-keys.cc
182
183 apt64/apt-pkg/tagfile-keys.cc:
184 mkdir -p apt64
185 mkdir -p Objects/apt64/apt-pkg
186 cd apt64 && ../apt64/triehash/triehash.pl \
187 --ignore-case \
188 --header ../Objects/apt64/apt-pkg/tagfile-keys.h \
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>" \
194 ../apt64/apt-pkg/tagfile-keys.list
195 sed -i -e 's@typedef char static_assert64@//\\0@' $@
196
197 Objects/%.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
202 Objects/apt32/%.o: apt32/%.cc $(header) apt.h apt-extra/*.h
203 @mkdir -p $(dir $@)
204 @echo "[cycc] $<"
205 @$(apt32) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
206
207 Objects/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 $@))
211
212 Objects/%.o: %.c $(header)
213 @mkdir -p $(dir $@)
214 @echo "[cycc] $<"
215 @$(cycc) -c -o $@ -x c $< $(flag)
216
217 Objects/%.o: %.m $(header)
218 @mkdir -p $(dir $@)
219 @echo "[cycc] $<"
220 @$(cycc) -c -o $@ $< $(flag)
221
222 Objects/%.o: %.cpp $(header)
223 @mkdir -p $(dir $@)
224 @echo "[cycc] $<"
225 @$(cycc) $(plus) -c -o $@ $< $(flag)
226
227 Objects/%.o: %.mm $(header)
228 @mkdir -p $(dir $@)
229 @echo "[cycc] $<"
230 @$(cycc) $(plus) -c -o $@ $< $(flag)
231
232 Objects/Version.o: Version.h
233
234 Images/%.png: %.png
235 @mkdir -p $(dir $@)
236 @echo "[pngc] $<"
237 @./pngcrush.sh $< $@
238
239 sysroot: sysroot.sh
240 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
241 @echo 1>&2
242 @exit 1
243
244 Objects/libapt32.a: $(libapt32)
245 @echo "[arch] $@"
246 @ar -rc $@ $^
247
248 Objects/libapt64.a: $(libapt64)
249 @echo "[arch] $@"
250 @ar -rc $@ $^
251
252 MobileCydia: $(object) entitlements.xml Objects/libapt32.a Objects/libapt64.a
253 @echo "[link] $@"
254 @$(cycc) -o $@ $(filter %.o,$^) $(link) $(libs) $(uikit) -Wl,-sdk_version,8.0
255 @mkdir -p bins
256 @cp -a $@ bins/$@-$(version)_$(shell date +%s)
257 @echo "[strp] $@"
258 @grep '~' <<<"$(version)" >/dev/null && echo "skipping..." || strip $@
259 @echo "[uikt] $@"
260 @./uikit.sh $@
261 @echo "[sign] $@"
262 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
263
264 cfversion: cfversion.mm
265 $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation
266 @ldid -T0 -S $@
267
268 setnsfpn: setnsfpn.cpp
269 $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link)
270 @ldid -T0 -S $@
271
272 cydo: cydo.cpp
273 $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings
274 @ldid -T0 -S $@
275
276 postinst: postinst.mm CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h
277 $(cycc) $(plus) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation -framework Foundation -framework UIKit
278 @ldid -T0 -S $@
279
280 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
281 sudo rm -rf _
282 mkdir -p _/var/lib/cydia
283
284 mkdir -p _/etc/apt
285 mkdir _/etc/apt/apt.conf.d
286 mkdir _/etc/apt/preferences.d
287 cp -a Trusted.gpg _/etc/apt/trusted.gpg.d
288 cp -a Sources.list _/etc/apt/sources.list.d
289
290 mkdir -p _/usr/libexec
291 cp -a Library _/usr/libexec/cydia
292 cp -a sysroot/usr/bin/du _/usr/libexec/cydia
293 cp -a cfversion _/usr/libexec/cydia
294 cp -a setnsfpn _/usr/libexec/cydia
295
296 cp -a cydo _/usr/libexec/cydia
297
298 mkdir -p _/Library
299 cp -a LaunchDaemons _/Library/LaunchDaemons
300
301 mkdir -p _/Applications
302 cp -a MobileCydia.app _/Applications/Cydia.app
303 rm -rf _/Applications/Cydia.app/*.lproj
304 cp -a MobileCydia _/Applications/Cydia.app/Cydia
305
306 for meth in bzip2 gzip lzma gpgv http https store $(methods); do ln -s Cydia _/Applications/Cydia.app/"$${meth}"; done
307
308 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
309
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
312 ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png"
313
314 mkdir -p _/DEBIAN
315 ./control.sh cydia.control _ >_/DEBIAN/control
316 cp -a preinst postinst _/DEBIAN/
317
318 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
319
320 sudo chown -R 0 _
321 sudo chgrp -R 0 _
322 sudo chmod 6755 _/usr/libexec/cydia/cydo
323
324 mkdir -p debs
325 ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb
326 $(dpkg) -b _ Cydia.deb
327 @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)"
328
329 $(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
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
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
346 package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
347
348 .PHONY: all clean package