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 cycc += -isysroot $(sdk)
17 cycc += -idirafter /usr/include
18 cycc += -F$(sdk)/System/Library/PrivateFrameworks
20 cycc += -fmessage-length=0
22 cycc += -fvisibility=hidden
24 link += -Wl,-dead_strip
25 link += -Wl,-no_dead_strip_inits_and_terms
29 iapt += -Iapt32-contrib
32 iapt += -IObjects/apt32
34 flag += $(patsubst %,-Xarch_armv6 %,$(iapt))
35 flag += $(patsubst %,-Xarch_arm64 %,$(subst apt32,apt64,$(iapt)))
38 flag += -isystem sysroot/usr/include
40 flag += -idirafter icu/icuSources/common
41 flag += -idirafter icu/icuSources/i18n
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
52 plus += -fobjc-call-cxx-cdtors
53 plus += -fvisibility-inlines-hidden
55 link += -multiply_defined suppress
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
68 libs += -framework CFNetwork
71 libs += -Xarch_armv6 -Wl,-force_load,Objects/libapt32.a
72 libs += -Xarch_arm64 -Wl,-force_load,Objects/libapt64.a
77 uikit += -framework UIKit
79 link += -Xarch_armv6 -Wl,-segalign,4000
81 dirs := Menes CyteKit Cydia SDURLCache
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
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))
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/%)
102 methods := copy file rred
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))
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))
123 link += -Xarch_arm64 -Wl,-lz
125 flag += -DAPT_PKG_EXPOSE_STRING_VIEW
126 flag += -Dsighandler_t=sig_t
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
137 flag64 += -arch arm64
138 flag64 += -Xarch_arm64 -miphoneos-version-min=7.0
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
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
154 eapt := -include apt.h
156 eapt += -D'VERSION="0.7.25.3"'
159 eapt += -Wno-logical-op-parentheses
167 images := $(shell find MobileCydia.app/ -type f -name '*.png')
168 images := $(images:%=Images/%)
170 lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
175 rm -f MobileCydia postinst
176 rm -rf Objects/ Images/
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
181 apt64/apt-pkg/tagfile-keys.cc:
183 mkdir -p Objects/apt64/apt-pkg
184 cd apt64 && ../apt64/triehash/triehash.pl \
186 --header ../Objects/apt64/apt-pkg/tagfile-keys.h \
187 --code apt-pkg/tagfile-keys.cc \
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@' $@
195 Objects/%.o: %.cc $(header)
198 @$(cycc) $(plus) -c -o $@ $< $(flag) -Wno-format -include apt.h -Dmain=main_$(basename $(notdir $@))
200 Objects/apt32/%.o: apt32/%.cc $(header) apt.h apt-extra/*.h
203 @$(apt32) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
205 Objects/apt64/%.o: apt64/%.cc $(header) apt.h apt-extra/*.h
208 @$(apt64) $(plus) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
210 Objects/%.o: %.c $(header)
213 @$(cycc) -c -o $@ -x c $< $(flag)
215 Objects/%.o: %.m $(header)
218 @$(cycc) -c -o $@ $< $(flag)
220 Objects/%.o: %.cpp $(header)
223 @$(cycc) $(plus) -c -o $@ $< $(flag)
225 Objects/%.o: %.mm $(header)
228 @$(cycc) $(plus) -c -o $@ $< $(flag)
230 Objects/Version.o: Version.h
238 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
242 Objects/libapt32.a: $(libapt32)
246 Objects/libapt64.a: $(libapt64)
250 MobileCydia: $(object) entitlements.xml Objects/libapt32.a Objects/libapt64.a
252 @$(cycc) -o $@ $(filter %.o,$^) $(link) $(libs) $(uikit) -Wl,-sdk_version,8.0
254 @cp -a $@ bins/$@-$(version)_$(shell date +%s)
256 @grep '~' <<<"$(version)" >/dev/null && echo "skipping..." || strip $@
260 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
262 cfversion: cfversion.mm
263 $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation
266 setnsfpn: setnsfpn.cpp
267 $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link)
271 $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings
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
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
280 mkdir -p _/var/lib/cydia
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
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
294 cp -a cydo _/usr/libexec/cydia
297 cp -a LaunchDaemons _/Library/LaunchDaemons
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
304 for meth in bzip2 gzip lzma gpgv http https store $(methods); do ln -s Cydia _/Applications/Cydia.app/"$${meth}"; done
306 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
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"
313 ./control.sh cydia.control _ >_/DEBIAN/control
314 cp -a preinst postinst _/DEBIAN/
316 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
320 sudo chmod 6755 _/usr/libexec/cydia/cydo
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)"
327 $(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
329 mkdir -p __/Applications/Cydia.app
331 cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app
334 ./control.sh cydia-lproj.control __ >__/DEBIAN/control
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)"
344 package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
346 .PHONY: all clean package