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
21 cycc += -Xarch_arm64 -miphoneos-version-min=7.0
23 cycc += -fmessage-length=0
25 cycc += -fvisibility=hidden
27 link += -Wl,-dead_strip
28 link += -Wl,-no_dead_strip_inits_and_terms
30 flag += -Xarch_arm64 -Iapt
31 flag += -Xarch_arm64 -Iapt-contrib
32 flag += -Xarch_arm64 -Iapt-deb
33 flag += -Xarch_arm64 -Iapt-extra
34 flag += -Xarch_arm64 -IObjects/apt
37 flag += -isystem sysroot/usr/include
39 flag += -idirafter icu/icuSources/common
40 flag += -idirafter icu/icuSources/i18n
43 flag += -Wno-dangling-else
44 flag += -Wno-deprecated-declarations
45 flag += -Wno-objc-protocol-method-implementation
46 flag += -Wno-logical-op-parentheses
47 flag += -Wno-shift-op-parentheses
48 flag += -Wno-unknown-pragmas
49 flag += -Wno-unknown-warning-option
51 plus += -fobjc-call-cxx-cdtors
52 plus += -fvisibility-inlines-hidden
54 link += -Lsysroot/usr/lib
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 += -Xarch_armv6 -Wl,-lapt-pkg
69 libs += -Xarch_arm64 -Wl,Objects/libapt64.a
73 uikit += -framework UIKit
75 link += -Xarch_armv6 -Wl,-segalign,4000
77 dirs := Menes CyteKit Cydia SDURLCache
79 code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext))))
80 code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code))
81 code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm DiskUsage.cpp
83 source := $(filter %.m,$(code)) $(filter %.mm,$(code))
84 source += $(filter %.c,$(code)) $(filter %.cpp,$(code))
85 header := $(filter %.h,$(code)) $(filter %.hpp,$(code))
88 object := $(object:.c=.o)
89 object := $(object:.cpp=.o)
90 object := $(object:.m=.o)
91 object := $(object:.mm=.o)
92 object := $(object:%=Objects/%)
95 libapt += $(wildcard apt/apt-pkg/*.cc)
96 libapt += $(wildcard apt/apt-pkg/deb/*.cc)
97 libapt += $(wildcard apt/apt-pkg/contrib/*.cc)
98 libapt += Objects/apt/apt-pkg/tagfile-keys.cc
99 libapt += apt/methods/store.cc
100 libapt := $(filter-out %/srvrec.cc,$(libapt))
101 libapt := $(patsubst %.cc,Objects/%.o,$(libapt))
103 link += -Xarch_arm64 -Wl,-lz,-liconv
105 flag += -DAPT_PKG_EXPOSE_STRING_VIEW
106 flag += -Dsighandler_t=sig_t
108 aptc := $(cycc) $(flag)
109 aptc += -include apt.h
110 aptc += -Wno-deprecated-register
111 aptc += -Wno-unused-private-field
112 aptc += -Wno-unused-variable
115 cycc += -Xarch_armv6 -miphoneos-version-min=2.0
116 flag += -Xarch_armv6 -marm # @synchronized
117 flag += -Xarch_armv6 -mcpu=arm1176jzf-s
118 flag += -mllvm -arm-reserve-r9
119 link += -Xarch_armv6 -Wl,-lgcc_s.1
122 #plus += -Wp,-stdlib=libc++
123 #link += libcxx/lib/libc++.a
125 images := $(shell find MobileCydia.app/ -type f -name '*.png')
126 images := $(images:%=Images/%)
128 lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
133 rm -f MobileCydia postinst
134 rm -rf Objects/ Images/
136 Objects/apt/apt-pkg/tagfile.o: Objects/apt/apt-pkg/tagfile-keys.cc
137 Objects/apt/apt-pkg/deb/deblistparser.o: Objects/apt/apt-pkg/tagfile-keys.cc
139 Objects/apt/apt-pkg/tagfile-keys.cc:
141 cd Objects/apt && ../../apt/triehash/triehash.pl \
143 --header apt-pkg/tagfile-keys.h \
144 --code apt-pkg/tagfile-keys.cc \
146 --enum-name pkgTagSection::Key \
147 --function-name pkgTagHash \
148 --include "<apt-pkg/tagfile.h>" \
149 ../../apt/apt-pkg/tagfile-keys.list
150 sed -i -e 's@typedef char static_assert64@//\\0@' $@
152 Objects/%.o: %.cc $(header) apt.h apt-extra/*.h
155 @$(aptc) $(plus) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
157 Objects/%.o: %.c $(header)
160 @$(cycc) -c -o $@ -x c $< $(flag)
162 Objects/%.o: %.m $(header)
165 @$(cycc) -c -o $@ $< $(flag)
167 Objects/%.o: %.cpp $(header)
170 @$(cycc) $(plus) -c -o $@ $< $(flag)
172 Objects/%.o: %.mm $(header)
175 @$(cycc) $(plus) -c -o $@ $< $(flag)
177 Objects/Version.o: Version.h
185 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
189 Objects/libapt64.a: $(libapt)
193 MobileCydia: sysroot $(object) entitlements.xml Objects/libapt64.a
195 @$(cycc) -o $@ $(filter %.o,$^) $(link) $(libs) $(uikit) -Wl,-sdk_version,8.0
197 @cp -a $@ bins/$@-$(version)_$(shell date +%s)
199 @grep '~' <<<"$(version)" >/dev/null && echo "skipping..." || strip $@
203 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
205 cfversion: cfversion.mm
206 $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation
209 setnsfpn: setnsfpn.cpp
210 $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link)
214 $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings
217 postinst: postinst.mm CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h
218 $(cycc) $(plus) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation -framework Foundation -framework UIKit
221 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
223 mkdir -p _/var/lib/cydia
226 cp -a Trusted.gpg _/etc/apt/trusted.gpg.d
227 cp -a Sources.list _/etc/apt/sources.list.d
229 mkdir -p _/usr/libexec
230 cp -a Library _/usr/libexec/cydia
231 cp -a sysroot/usr/bin/du _/usr/libexec/cydia
232 cp -a cfversion _/usr/libexec/cydia
233 cp -a setnsfpn _/usr/libexec/cydia
235 cp -a cydo _/usr/libexec/cydia
238 cp -a LaunchDaemons _/Library/LaunchDaemons
240 mkdir -p _/Applications
241 cp -a MobileCydia.app _/Applications/Cydia.app
242 rm -rf _/Applications/Cydia.app/*.lproj
243 cp -a MobileCydia _/Applications/Cydia.app/Cydia
244 ln -s Cydia _/Applications/Cydia.app/store
246 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
248 mkdir -p _/Applications/Cydia.app/Sources
249 ln -s /usr/share/bigboss/icons/bigboss.png _/Applications/Cydia.app/Sources/apt.bigboss.us.com.png
250 ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png"
253 ./control.sh cydia.control _ >_/DEBIAN/control
254 cp -a preinst postinst _/DEBIAN/
256 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
260 sudo chmod 6755 _/usr/libexec/cydia/cydo
263 ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb
264 $(dpkg) -b _ Cydia.deb
265 @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)"
267 $(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
269 mkdir -p __/Applications/Cydia.app
271 cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app
274 ./control.sh cydia-lproj.control __ >__/DEBIAN/control
280 ln -sf debs/cydia-lproj_$(version)_iphoneos-arm.deb Cydia_.deb
281 $(dpkg) -b __ Cydia_.deb
282 @echo "$$(stat -L -f "%z" Cydia_.deb) $$(stat -f "%Y" Cydia_.deb)"
284 package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
286 .PHONY: all clean package