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