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