1 dev := $(shell xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer
3 ioss := $(sort $(patsubst $(sdks)/iPhoneOS%.sdk,%,$(wildcard $(sdks)/iPhoneOS*.sdk)))
4 ios := $(word $(words $(ioss)),$(ioss))
6 # if you can tolerate clang, set this to blank
10 gxx := $(dev)/usr/bin/clang++
12 gxx := $(dev)/usr/bin/g++
19 ifeq (o,O) # gzip is actually better
20 dpkg := /Library/Cydia/bin/dpkg-deb
21 ifeq ($(wildcard $(dpkg)),$(dpkg))
22 dpkg := $(dpkg) -zlzma
24 dpkg := dpkg-deb -zbzip2
30 sdk := $(sdks)/iPhoneOS$(ios).sdk
32 flags += -F$(sdk)/System/Library/PrivateFrameworks
33 flags += -I. -isystem sysroot/usr/include
34 flags += -fmessage-length=0
36 flags += -fvisibility=hidden
41 flags += -Wno-unknown-warning-option
42 flags += -Wno-logical-op-parentheses
44 flags += -fobjc-exceptions
45 flags += -fno-guess-branch-probability
48 flags += -Wno-deprecated-declarations
51 xflags += -fobjc-call-cxx-cdtors
52 xflags += -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 JavaScriptCore
63 libs += -framework QuartzCore
64 libs += -framework SpringBoardServices
65 libs += -framework SystemConfiguration
66 libs += -framework WebCore
67 libs += -framework WebKit
74 uikit += -framework UIKit
77 backrow += -FAppleTV -framework BackRow -framework AppleTV
79 version := $(shell ./version.sh)
81 cycc = $(gxx) -mthumb -arch armv6 -o $@ -miphoneos-version-min=2.0 -isysroot $(sdk) -idirafter /usr/include -F{sysroot,}/Library/Frameworks
82 #cycc = cycc -r4.2 -i$(ios) -o$@
85 cycc += -Xarch_armv6 -mcpu=arm1176jzf-s
88 dirs := Menes CyteKit Cydia SDURLCache
90 code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext))))
91 code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code))
92 code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm
94 source := $(filter %.m,$(code)) $(filter %.mm,$(code))
95 source += $(filter %.c,$(code)) $(filter %.cpp,$(code))
96 header := $(filter %.h,$(code)) $(filter %.hpp,$(code))
99 object := $(object:.c=.o)
100 object := $(object:.cpp=.o)
101 object := $(object:.m=.o)
102 object := $(object:.mm=.o)
103 object := $(object:%=Objects/%)
105 images := $(shell find MobileCydia.app/ -type f -name '*.png')
106 images := $(images:%=Images/%)
108 lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
113 rm -f MobileCydia postinst
114 rm -rf Objects/ Images/
116 Objects/%.o: %.c $(header)
121 Objects/%.o: %.m $(header)
124 @$(cycc) -c $< $(flags)
126 Objects/%.o: %.mm $(header)
129 @$(cycc) -c $< $(flags) $(xflags)
131 Objects/Version.o: Version.h
139 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
143 MobileCydia: sysroot $(object) entitlements.xml
144 @echo "[link] $(object:Objects/%=%)"
145 @$(cycc) $(filter %.o,$^) $(flags) $(link) $(libs) $(uikit)
147 @cp -a $@ bins/$@-$(version)
151 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
153 CydiaAppliance: CydiaAppliance.mm
154 $(cycc) $(filter %.mm,$^) $(flags) $(link) -bundle $(libs) $(backrow)
156 cfversion: cfversion.mm
157 $(cycc) $(filter %.mm,$^) $(flags) -framework CoreFoundation
160 postinst: postinst.mm Sources.mm Sources.h CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h
161 $(cycc) $(filter %.mm,$^) $(flags) $(link) -framework CoreFoundation -framework Foundation -framework UIKit -lpcre
164 debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst cfversion $(images) $(shell find MobileCydia.app) cydia.control Library/firmware.sh Library/startup
166 mkdir -p _/var/lib/cydia
169 cp -a Trusted.gpg _/etc/apt/trusted.gpg.d
170 cp -a Sources.list _/etc/apt/sources.list.d
172 mkdir -p _/usr/libexec
173 cp -a Library _/usr/libexec/cydia
174 cp -a sysroot/usr/bin/du _/usr/libexec/cydia
175 cp -a cfversion _/usr/libexec/cydia
177 mkdir -p _/System/Library
178 cp -a LaunchDaemons _/System/Library/LaunchDaemons
180 mkdir -p _/Applications
181 cp -a MobileCydia.app _/Applications/Cydia.app
182 rm -rf _/Applications/Cydia.app/*.lproj
183 cp -a MobileCydia _/Applications/Cydia.app/MobileCydia
185 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
187 mkdir -p _/Applications/Cydia.app/Sources
188 ln -s /usr/share/bigboss/icons/bigboss.png _/Applications/Cydia.app/Sources/apt.bigboss.us.com.png
189 ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png"
191 #mkdir -p _/Applications/AppleTV.app/Appliances
192 #cp -a Cydia.frappliance _/Applications/AppleTV.app/Appliances
193 #cp -a CydiaAppliance _/Applications/AppleTV.app/Appliances/Cydia.frappliance
195 #mkdir -p _/Applications/Lowtide.app/Appliances
196 #ln -s {/Applications/AppleTV,_/Applications/Lowtide}.app/Appliances/Cydia.frappliance
199 ./control.sh cydia.control _ >_/DEBIAN/control
200 cp -a preinst postinst _/DEBIAN/
202 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
206 sudo chmod 6755 _/Applications/Cydia.app/MobileCydia
209 ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb
210 $(dpkg) -b _ Cydia.deb
211 @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)"
213 $(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
215 mkdir -p __/Applications/Cydia.app
217 cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app
220 ./control.sh cydia-lproj.control __ >__/DEBIAN/control
226 ln -sf debs/cydia-lproj_$(version)_iphoneos-arm.deb Cydia_.deb
227 $(dpkg) -b __ Cydia_.deb
228 @echo "$$(stat -L -f "%z" Cydia_.deb) $$(stat -f "%Y" Cydia_.deb)"
230 package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
232 .PHONY: all clean package