]> git.saurik.com Git - cydia.git/blame - makefile
Remove _clear from Source (future code loses it).
[cydia.git] / makefile
CommitLineData
164e8139 1dev := $(shell xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer
4cc9e99a 2sdks := $(dev)/SDKs
ea958716 3ioss := $(sort $(patsubst $(sdks)/iPhoneOS%.sdk,%,$(wildcard $(sdks)/iPhoneOS*.sdk)))
ea958716 4ios := $(word $(words $(ioss)),$(ioss))
4cc9e99a 5
0f5beb70
JF
6# XXX: as of iOS 6.x armv6 is not supported :(
7ios := 5.1
8
4cc9e99a 9# if you can tolerate clang, set this to blank
670fdb01 10gcc := 4.2
c21004b9 11
4cc9e99a
JF
12ifeq ($(gcc),)
13gxx := $(dev)/usr/bin/clang++
14else
8ba636c7 15gxx := $(dev)/usr/bin/g++
4cc9e99a
JF
16endif
17
c21004b9
JF
18flags :=
19link :=
543e172a 20libs :=
c21004b9 21
d1ba8fd3
JF
22ifeq (o,O) # gzip is actually better
23dpkg := /Library/Cydia/bin/dpkg-deb
24ifeq ($(wildcard $(dpkg)),$(dpkg))
25dpkg := $(dpkg) -zlzma
26else
27dpkg := dpkg-deb -zbzip2
28endif
29else
c21004b9 30dpkg := dpkg-deb
d1ba8fd3 31endif
c21004b9 32
0263db76 33sdk := $(sdks)/iPhoneOS$(ios).sdk
ee4120ad
JF
34
35flags += -F$(sdk)/System/Library/PrivateFrameworks
4cc9e99a 36flags += -I. -isystem sysroot/usr/include
c21004b9
JF
37flags += -fmessage-length=0
38flags += -g0 -O2
4cc9e99a
JF
39flags += -fvisibility=hidden
40
41flags += -Wall
42
43ifeq ($(gcc),)
44flags += -Wno-unknown-warning-option
45flags += -Wno-logical-op-parentheses
46else
7c8912f8 47flags += -fobjc-exceptions
443b9e05 48flags += -fno-guess-branch-probability
4cc9e99a
JF
49endif
50
51flags += -Wno-deprecated-declarations
7c8912f8
JF
52
53xflags :=
54xflags += -fobjc-call-cxx-cdtors
9f9ae81c 55xflags += -fvisibility-inlines-hidden
c21004b9 56
4cc9e99a 57link += -Lsysroot/usr/lib
c21004b9 58link += -multiply_defined suppress
5f6bff8c 59
543e172a
JF
60libs += -framework CoreFoundation
61libs += -framework CoreGraphics
62libs += -framework Foundation
63libs += -framework GraphicsServices
64libs += -framework IOKit
543e172a
JF
65libs += -framework QuartzCore
66libs += -framework SpringBoardServices
67libs += -framework SystemConfiguration
68libs += -framework WebCore
69libs += -framework WebKit
70
71libs += -lapr-1
72libs += -lapt-pkg
73libs += -lpcre
74
e17a8c4f
JF
75uikit :=
76uikit += -framework UIKit
77
78backrow :=
79backrow += -FAppleTV -framework BackRow -framework AppleTV
80
f9ba524a
JF
81version := $(shell ./version.sh)
82
eb40eaca 83cycc = $(gxx) -mthumb -arch armv6 -o $@ -miphoneos-version-min=2.0 -isysroot $(sdk) -idirafter /usr/include -F{sysroot,}/Library/Frameworks
4cc9e99a 84#cycc = cycc -r4.2 -i$(ios) -o$@
ee4120ad 85
eb40eaca
JF
86ifneq ($(gcc),)
87cycc += -Xarch_armv6 -mcpu=arm1176jzf-s
88endif
89
7c8912f8
JF
90dirs := Menes CyteKit Cydia SDURLCache
91
92code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext))))
93code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code))
25c1dafb 94code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm
7c8912f8
JF
95
96source := $(filter %.m,$(code)) $(filter %.mm,$(code))
97source += $(filter %.c,$(code)) $(filter %.cpp,$(code))
98header := $(filter %.h,$(code)) $(filter %.hpp,$(code))
99
100object := $(source)
101object := $(object:.c=.o)
102object := $(object:.cpp=.o)
103object := $(object:.m=.o)
104object := $(object:.mm=.o)
105object := $(object:%=Objects/%)
106
4339c9ef 107images := $(shell find MobileCydia.app/ -type f -name '*.png')
8a4d4662
JF
108images := $(images:%=Images/%)
109
915284a6
JF
110lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
111
e17a8c4f 112all: MobileCydia
dc5812ec 113
5f6bff8c 114clean:
eaa9f122 115 rm -f MobileCydia postinst
8a4d4662 116 rm -rf Objects/ Images/
7c8912f8
JF
117
118Objects/%.o: %.c $(header)
119 @mkdir -p $(dir $@)
120 @echo "[cycc] $<"
4cc9e99a 121 @$(cycc) -c -x c $<
7c8912f8
JF
122
123Objects/%.o: %.m $(header)
124 @mkdir -p $(dir $@)
125 @echo "[cycc] $<"
4cc9e99a 126 @$(cycc) -c $< $(flags)
5f6bff8c 127
7c8912f8
JF
128Objects/%.o: %.mm $(header)
129 @mkdir -p $(dir $@)
130 @echo "[cycc] $<"
4cc9e99a 131 @$(cycc) -c $< $(flags) $(xflags)
e95a1972 132
174327c1 133Objects/Version.o: Version.h
e61d7bfc 134
8a4d4662
JF
135Images/%.png: %.png
136 @mkdir -p $(dir $@)
137 @echo "[pngc] $<"
138 @./pngcrush.sh $< $@
139
0d5393af
JF
140sysroot: sysroot.sh
141 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
8a2c6d14
JF
142 @echo 1>&2
143 @exit 1
144
9c0eddfd 145MobileCydia: sysroot $(object) entitlements.xml
7c8912f8 146 @echo "[link] $(object:Objects/%=%)"
cc31c45d 147 @$(cycc) $(filter %.o,$^) $(flags) $(link) $(libs) $(uikit) -Wl,-sdk_version,7.0
0dbada51 148 @mkdir -p bins
665d1e62 149 @cp -a $@ bins/$@-$(version)
443b9e05
JF
150 @echo "[strp] $@"
151 @strip -no_uuid $@
cc31c45d
JF
152 @echo "[uikt] $@"
153 @./uikit.sh $@
7c8912f8 154 @echo "[sign] $@"
9c0eddfd 155 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
03c0f7a9 156
e17a8c4f 157CydiaAppliance: CydiaAppliance.mm
543e172a 158 $(cycc) $(filter %.mm,$^) $(flags) $(link) -bundle $(libs) $(backrow)
e17a8c4f 159
e967efd5
JF
160cfversion: cfversion.mm
161 $(cycc) $(filter %.mm,$^) $(flags) -framework CoreFoundation
162 @ldid -T0 -S $@
163
eaa9f122 164postinst: postinst.mm Sources.mm Sources.h CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h
543e172a 165 $(cycc) $(filter %.mm,$^) $(flags) $(link) -framework CoreFoundation -framework Foundation -framework UIKit -lpcre
2d46d29e 166 @ldid -T0 -S $@
eaa9f122 167
378a293a 168debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst cfversion $(images) $(shell find MobileCydia.app) cydia.control Library/firmware.sh Library/startup
7e2bd591 169 sudo rm -rf _
03c0f7a9
JF
170 mkdir -p _/var/lib/cydia
171
33e30380
JF
172 mkdir -p _/etc/apt
173 cp -a Trusted.gpg _/etc/apt/trusted.gpg.d
174 cp -a Sources.list _/etc/apt/sources.list.d
175
03c0f7a9 176 mkdir -p _/usr/libexec
c21004b9 177 cp -a Library _/usr/libexec/cydia
7e2bd591 178 cp -a sysroot/usr/bin/du _/usr/libexec/cydia
e967efd5 179 cp -a cfversion _/usr/libexec/cydia
03c0f7a9
JF
180
181 mkdir -p _/System/Library
c21004b9 182 cp -a LaunchDaemons _/System/Library/LaunchDaemons
03c0f7a9
JF
183
184 mkdir -p _/Applications
e17a8c4f 185 cp -a MobileCydia.app _/Applications/Cydia.app
915284a6 186 rm -rf _/Applications/Cydia.app/*.lproj
e17a8c4f
JF
187 cp -a MobileCydia _/Applications/Cydia.app/MobileCydia
188
8a4d4662
JF
189 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
190
4339c9ef
JF
191 mkdir -p _/Applications/Cydia.app/Sources
192 ln -s /usr/share/bigboss/icons/bigboss.png _/Applications/Cydia.app/Sources/apt.bigboss.us.com.png
5ad3e6d9
JF
193 ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png"
194
e2b57be4
JF
195 #mkdir -p _/Applications/AppleTV.app/Appliances
196 #cp -a Cydia.frappliance _/Applications/AppleTV.app/Appliances
197 #cp -a CydiaAppliance _/Applications/AppleTV.app/Appliances/Cydia.frappliance
198
e17a8c4f 199 #mkdir -p _/Applications/Lowtide.app/Appliances
e2b57be4 200 #ln -s {/Applications/AppleTV,_/Applications/Lowtide}.app/Appliances/Cydia.frappliance
03c0f7a9 201
03c0f7a9 202 mkdir -p _/DEBIAN
915284a6 203 ./control.sh cydia.control _ >_/DEBIAN/control
eaa9f122 204 cp -a preinst postinst _/DEBIAN/
03c0f7a9 205
8fec9d25 206 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
7fc02989 207
7e2bd591
JF
208 sudo chown -R 0 _
209 sudo chgrp -R 0 _
e17a8c4f 210 sudo chmod 6755 _/Applications/Cydia.app/MobileCydia
7e2bd591 211
3adcfba7 212 mkdir -p debs
f9ba524a 213 ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb
3adcfba7 214 $(dpkg) -b _ Cydia.deb
ce0372db 215 @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)"
8cc774c5 216
33e30380 217$(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
915284a6
JF
218 sudo rm -rf __
219 mkdir -p __/Applications/Cydia.app
220
221 cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app
222
223 mkdir -p __/DEBIAN
224 ./control.sh cydia-lproj.control __ >__/DEBIAN/control
915284a6
JF
225
226 sudo chown -R 0 __
227 sudo chgrp -R 0 __
228
229 mkdir -p debs
230 ln -sf debs/cydia-lproj_$(version)_iphoneos-arm.deb Cydia_.deb
231 $(dpkg) -b __ Cydia_.deb
232 @echo "$$(stat -L -f "%z" Cydia_.deb) $$(stat -f "%Y" Cydia_.deb)"
233
234package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
aa60b57b 235
10ff7664 236.PHONY: all clean package