4 dpkg := dpkg-deb -Zlzma
5 version := $(shell ./version.sh)
12 gxx := $(shell xcrun --sdk iphoneos -f g++)
15 sdk := $(shell xcodebuild -sdk iphoneos -version Path)
16 mac := $(shell xcodebuild -sdk macosx -version Path)
18 cycc += -isysroot $(sdk)
19 cycc += -idirafter $(mac)/usr/include
20 cycc += -F$(sdk)/System/Library/PrivateFrameworks
22 cycc += -fmessage-length=0
24 cycc += -fvisibility=hidden
26 link += -Wl,-dead_strip
27 link += -Wl,-no_dead_strip_inits_and_terms
31 iapt += -Iapt32-contrib
34 iapt += -IObjects/apt32
36 flag += $(patsubst %,-Xarch_armv6 %,$(iapt))
37 flag += $(patsubst %,-Xarch_arm64 %,$(subst apt32,apt64,$(iapt)))
40 flag += -isystem sysroot/usr/include
42 flag += -idirafter icu/icuSources/common
43 flag += -idirafter icu/icuSources/i18n
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
54 plus += -fobjc-call-cxx-cdtors
55 plus += -fvisibility-inlines-hidden
57 link += -multiply_defined suppress
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
70 libs += -framework CFNetwork
73 libs += -Xarch_armv6 -Wl,-force_load,Objects/libapt32.a
74 libs += -Xarch_arm64 -Wl,-force_load,Objects/libapt64.a
79 uikit += -framework UIKit
81 link += -Xarch_armv6 -Wl,-segalign,4000
83 dirs := Menes CyteKit Cydia SDURLCache
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
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))
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/%)
104 methods := copy file rred
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))
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))
125 link += -Xarch_arm64 -Wl,-lz
127 flag += -DAPT_PKG_EXPOSE_STRING_VIEW
128 flag += -Dsighandler_t=sig_t
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
139 flag64 += -arch arm64
140 flag64 += -Xarch_arm64 -miphoneos-version-min=7.0
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
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
156 eapt := -include apt.h
158 eapt += -D'VERSION="0.7.25.3"'
161 eapt += -Wno-logical-op-parentheses
169 images := $(shell find MobileCydia.app/ -type f -name '*.png')
170 images := $(images:%=Images/%)
172 lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
177 rm -f MobileCydia postinst
178 rm -rf Objects/ Images/
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
183 apt64/apt-pkg/tagfile-keys.cc:
185 mkdir -p Objects/apt64/apt-pkg
186 cd apt64 && ../apt64/triehash/triehash.pl \
188 --header ../Objects/apt64/apt-pkg/tagfile-keys.h \
189 --code apt-pkg/tagfile-keys.cc \
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@' $@
197 Objects/%.o: %.cc $(header)
200 @$(cycc) $(plus) -c -o $@ $< $(flag) -Wno-format -include apt.h -Dmain=main_$(basename $(notdir $@))
202 Objects/apt32/%.o: apt32/%.cc $(header) apt.h apt-extra/*.h
205 @$(apt32) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
207 Objects/apt64/%.o: apt64/%.cc $(header) apt.h apt-extra/*.h
210 @$(apt64) $(plus) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
212 Objects/%.o: %.c $(header)
215 @$(cycc) -c -o $@ -x c $< $(flag)
217 Objects/%.o: %.m $(header)
220 @$(cycc) -c -o $@ $< $(flag)
222 Objects/%.o: %.cpp $(header)
225 @$(cycc) $(plus) -c -o $@ $< $(flag)
227 Objects/%.o: %.mm $(header)
230 @$(cycc) $(plus) -c -o $@ $< $(flag)
232 Objects/Version.o: Version.h
240 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
244 Objects/libapt32.a: $(libapt32)
248 Objects/libapt64.a: $(libapt64)
252 MobileCydia: $(object) entitlements.xml Objects/libapt32.a Objects/libapt64.a
254 @$(cycc) -o $@ $(filter %.o,$^) $(link) $(libs) $(uikit) -Wl,-sdk_version,8.0
256 @cp -a $@ bins/$@-$(version)_$(shell date +%s)
258 @grep '~' <<<"$(version)" >/dev/null && echo "skipping..." || strip $@
262 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
264 cfversion: cfversion.mm
265 $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation
268 setnsfpn: setnsfpn.cpp
269 $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link)
273 $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings
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
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
282 mkdir -p _/var/lib/cydia
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
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
296 cp -a cydo _/usr/libexec/cydia
299 cp -a LaunchDaemons _/Library/LaunchDaemons
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
306 for meth in bzip2 gzip lzma gpgv http https store $(methods); do ln -s Cydia _/Applications/Cydia.app/"$${meth}"; done
308 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
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"
315 ./control.sh cydia.control _ >_/DEBIAN/control
316 cp -a preinst postinst _/DEBIAN/
318 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
322 sudo chmod 6755 _/usr/libexec/cydia/cydo
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)"
329 $(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
331 mkdir -p __/Applications/Cydia.app
333 cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app
336 ./control.sh cydia-lproj.control __ >__/DEBIAN/control
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)"
346 package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
348 .PHONY: all clean package