]>
Commit | Line | Data |
---|---|---|
1 | sdks := /Developer/Platforms/iPhoneOS.platform/Developer/SDKs | |
2 | ioss := $(sort $(patsubst $(sdks)/iPhoneOS%.sdk,%,$(wildcard $(sdks)/iPhoneOS*.sdk))) | |
3 | ||
4 | ios := $(word $(words $(ioss)),$(ioss)) | |
5 | gcc := 4.2 | |
6 | ||
7 | flags := | |
8 | link := | |
9 | ||
10 | ifeq (o,O) # gzip is actually better | |
11 | dpkg := /Library/Cydia/bin/dpkg-deb | |
12 | ifeq ($(wildcard $(dpkg)),$(dpkg)) | |
13 | dpkg := $(dpkg) -zlzma | |
14 | else | |
15 | dpkg := dpkg-deb -zbzip2 | |
16 | endif | |
17 | else | |
18 | dpkg := dpkg-deb | |
19 | endif | |
20 | ||
21 | sdk := $(sdks)/iPhoneOS$(ios).sdk | |
22 | ||
23 | flags += -F$(sdk)/System/Library/PrivateFrameworks | |
24 | flags += -I. -isystem sysroot/usr/include -Lsysroot/usr/lib | |
25 | flags += -Wall -Werror -Wno-deprecated-declarations | |
26 | flags += -fmessage-length=0 | |
27 | flags += -g0 -O2 | |
28 | flags += -fobjc-exceptions | |
29 | flags += -fno-guess-branch-probability | |
30 | flags += -fvisibility=hidden | |
31 | ||
32 | xflags := | |
33 | xflags += -fobjc-call-cxx-cdtors | |
34 | xflags += -fvisibility-inlines-hidden | |
35 | ||
36 | link += -framework CoreFoundation | |
37 | link += -framework CoreGraphics | |
38 | link += -framework Foundation | |
39 | link += -framework GraphicsServices | |
40 | link += -framework IOKit | |
41 | link += -framework JavaScriptCore | |
42 | link += -framework QuartzCore | |
43 | link += -framework SpringBoardServices | |
44 | link += -framework SystemConfiguration | |
45 | link += -framework WebCore | |
46 | link += -framework WebKit | |
47 | ||
48 | link += -lapr-1 | |
49 | link += -lapt-pkg | |
50 | link += -lpcre | |
51 | ||
52 | link += -multiply_defined suppress | |
53 | ||
54 | uikit := | |
55 | uikit += -framework UIKit | |
56 | ||
57 | backrow := | |
58 | backrow += -FAppleTV -framework BackRow -framework AppleTV | |
59 | ||
60 | version := $(shell ./version.sh) | |
61 | ||
62 | #cycc = cycc -r4.2 -i$(ios) -o$@ | |
63 | gxx := /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-$(gcc) | |
64 | cycc = $(gxx) -mthumb -arch armv6 -o $@ -mcpu=arm1176jzf-s -miphoneos-version-min=2.0 -isysroot $(sdk) -idirafter /usr/include -F{sysroot,}/Library/Frameworks | |
65 | ||
66 | dirs := Menes CyteKit Cydia SDURLCache | |
67 | ||
68 | code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext)))) | |
69 | code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code)) | |
70 | code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm | |
71 | ||
72 | source := $(filter %.m,$(code)) $(filter %.mm,$(code)) | |
73 | source += $(filter %.c,$(code)) $(filter %.cpp,$(code)) | |
74 | header := $(filter %.h,$(code)) $(filter %.hpp,$(code)) | |
75 | ||
76 | object := $(source) | |
77 | object := $(object:.c=.o) | |
78 | object := $(object:.cpp=.o) | |
79 | object := $(object:.m=.o) | |
80 | object := $(object:.mm=.o) | |
81 | object := $(object:%=Objects/%) | |
82 | ||
83 | images := $(shell find MobileCydia.app/ -type f -name '*.png') | |
84 | images := $(images:%=Images/%) | |
85 | ||
86 | lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb | |
87 | ||
88 | all: MobileCydia | |
89 | ||
90 | clean: | |
91 | rm -f MobileCydia postinst | |
92 | rm -rf Objects/ Images/ | |
93 | ||
94 | Objects/%.o: %.c $(header) | |
95 | @mkdir -p $(dir $@) | |
96 | @echo "[cycc] $<" | |
97 | @$(cycc) -c -o $@ -x c $< | |
98 | ||
99 | Objects/%.o: %.m $(header) | |
100 | @mkdir -p $(dir $@) | |
101 | @echo "[cycc] $<" | |
102 | @$(cycc) -c -o $@ $< $(flags) | |
103 | ||
104 | Objects/%.o: %.mm $(header) | |
105 | @mkdir -p $(dir $@) | |
106 | @echo "[cycc] $<" | |
107 | @$(cycc) -c -o $@ $< $(flags) $(xflags) | |
108 | ||
109 | Objects/Version.o: version.h | |
110 | ||
111 | Images/%.png: %.png | |
112 | @mkdir -p $(dir $@) | |
113 | @echo "[pngc] $<" | |
114 | @./pngcrush.sh $< $@ | |
115 | ||
116 | sysroot: sysroot.sh | |
117 | @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2 | |
118 | @echo 1>&2 | |
119 | @exit 1 | |
120 | ||
121 | MobileCydia: sysroot $(object) | |
122 | @echo "[link] $(object:Objects/%=%)" | |
123 | @$(cycc) $(filter %.o,$^) $(flags) $(link) $(uikit) | |
124 | @cp -a $@ $@-$(version) | |
125 | @echo "[strp] $@" | |
126 | @strip -no_uuid $@ | |
127 | @echo "[sign] $@" | |
128 | @ldid -T0 -Slaunch.xml $@ || { rm -f $@ && false; } | |
129 | ||
130 | CydiaAppliance: CydiaAppliance.mm | |
131 | $(cycc) $(filter %.mm,$^) $(flags) -bundle $(link) $(backrow) | |
132 | ||
133 | postinst: postinst.mm Sources.mm Sources.h CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h | |
134 | $(cycc) $(filter %.mm,$^) $(flags) -framework CoreFoundation -framework Foundation -framework UIKit -lpcre | |
135 | @ldid -T0 -S $@ | |
136 | ||
137 | debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst $(images) $(shell find MobileCydia.app) cydia.control | |
138 | sudo rm -rf _ | |
139 | mkdir -p _/var/lib/cydia | |
140 | ||
141 | mkdir -p _/etc/apt | |
142 | cp -a Trusted.gpg _/etc/apt/trusted.gpg.d | |
143 | cp -a Sources.list _/etc/apt/sources.list.d | |
144 | ||
145 | mkdir -p _/usr/libexec | |
146 | cp -a Library _/usr/libexec/cydia | |
147 | cp -a sysroot/usr/bin/du _/usr/libexec/cydia | |
148 | ||
149 | mkdir -p _/System/Library | |
150 | cp -a LaunchDaemons _/System/Library/LaunchDaemons | |
151 | ||
152 | mkdir -p _/Applications | |
153 | cp -a MobileCydia.app _/Applications/Cydia.app | |
154 | rm -rf _/Applications/Cydia.app/*.lproj | |
155 | cp -a MobileCydia _/Applications/Cydia.app/MobileCydia | |
156 | ||
157 | cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';' | |
158 | ||
159 | mkdir -p _/Applications/Cydia.app/Sources | |
160 | ln -s /usr/share/bigboss/icons/bigboss.png _/Applications/Cydia.app/Sources/apt.bigboss.us.com.png | |
161 | ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png" | |
162 | ||
163 | #mkdir -p _/Applications/AppleTV.app/Appliances | |
164 | #cp -a Cydia.frappliance _/Applications/AppleTV.app/Appliances | |
165 | #cp -a CydiaAppliance _/Applications/AppleTV.app/Appliances/Cydia.frappliance | |
166 | ||
167 | #mkdir -p _/Applications/Lowtide.app/Appliances | |
168 | #ln -s {/Applications/AppleTV,_/Applications/Lowtide}.app/Appliances/Cydia.frappliance | |
169 | ||
170 | mkdir -p _/DEBIAN | |
171 | ./control.sh cydia.control _ >_/DEBIAN/control | |
172 | cp -a preinst postinst _/DEBIAN/ | |
173 | ||
174 | find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';' | |
175 | ||
176 | sudo chown -R 0 _ | |
177 | sudo chgrp -R 0 _ | |
178 | sudo chmod 6755 _/Applications/Cydia.app/MobileCydia | |
179 | ||
180 | mkdir -p debs | |
181 | ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb | |
182 | $(dpkg) -b _ Cydia.deb | |
183 | @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)" | |
184 | ||
185 | $(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control | |
186 | sudo rm -rf __ | |
187 | mkdir -p __/Applications/Cydia.app | |
188 | ||
189 | cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app | |
190 | ||
191 | mkdir -p __/DEBIAN | |
192 | ./control.sh cydia-lproj.control __ >__/DEBIAN/control | |
193 | ||
194 | sudo chown -R 0 __ | |
195 | sudo chgrp -R 0 __ | |
196 | ||
197 | mkdir -p debs | |
198 | ln -sf debs/cydia-lproj_$(version)_iphoneos-arm.deb Cydia_.deb | |
199 | $(dpkg) -b __ Cydia_.deb | |
200 | @echo "$$(stat -L -f "%z" Cydia_.deb) $$(stat -f "%Y" Cydia_.deb)" | |
201 | ||
202 | package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb) | |
203 | ||
204 | .PHONY: all clean package |