]> git.saurik.com Git - cydia.git/blame - makefile
Provide more guarantees against merge catastrophe.
[cydia.git] / makefile
CommitLineData
0209cce5
JF
1.DELETE_ON_ERROR:
2.SECONDARY:
3
4dpkg := dpkg-deb -Zlzma
5version := $(shell ./version.sh)
4cc9e99a 6
0209cce5
JF
7flag :=
8plus :=
c21004b9 9link :=
543e172a 10libs :=
c21004b9 11
0209cce5
JF
12gxx := $(shell xcrun --sdk iphoneos -f g++)
13cycc := $(gxx)
14
15sdk := $(shell xcodebuild -sdk iphoneos -version Path)
16cycc += -isysroot $(sdk)
17cycc += -idirafter /usr/include
18cycc += -F$(sdk)/System/Library/PrivateFrameworks
19
20cycc += -arch arm64
21cycc += -Xarch_arm64 -miphoneos-version-min=7.0
22
23cycc += -fmessage-length=0
24cycc += -gfull -O2
25cycc += -fvisibility=hidden
ee4120ad 26
0209cce5
JF
27link += -Wl,-dead_strip
28link += -Wl,-no_dead_strip_inits_and_terms
29link += -Wl,-s
4cc9e99a 30
0209cce5
JF
31flag += -Xarch_arm64 -Iapt
32flag += -Xarch_arm64 -Iapt-contrib
33flag += -Xarch_arm64 -Iapt-deb
34flag += -Xarch_arm64 -Iapt-extra
35flag += -Xarch_arm64 -Iapt-tag
8e57d50b 36
0209cce5
JF
37flag += -I.
38flag += -isystem sysroot/usr/include
4cc9e99a 39
0209cce5
JF
40flag += -idirafter icu/icuSources/common
41flag += -idirafter icu/icuSources/i18n
7c8912f8 42
0209cce5
JF
43flag += -Wall
44flag += -Wno-dangling-else
45flag += -Wno-deprecated-declarations
46flag += -Wno-objc-protocol-method-implementation
47flag += -Wno-logical-op-parentheses
48flag += -Wno-shift-op-parentheses
49flag += -Wno-unknown-pragmas
50flag += -Wno-unknown-warning-option
51
52plus += -fobjc-call-cxx-cdtors
53plus += -fvisibility-inlines-hidden
c21004b9 54
4cc9e99a 55link += -Lsysroot/usr/lib
c21004b9 56link += -multiply_defined suppress
5f6bff8c 57
543e172a
JF
58libs += -framework CoreFoundation
59libs += -framework CoreGraphics
60libs += -framework Foundation
61libs += -framework GraphicsServices
62libs += -framework IOKit
543e172a
JF
63libs += -framework QuartzCore
64libs += -framework SpringBoardServices
65libs += -framework SystemConfiguration
66libs += -framework WebCore
67libs += -framework WebKit
68
0209cce5
JF
69libs += -Xarch_armv6 -Wl,-lapt-pkg
70libs += -Xarch_arm64 -Wl,Objects/libapt64.a
8e57d50b 71libs += -licucore
543e172a 72
e17a8c4f
JF
73uikit :=
74uikit += -framework UIKit
75
0209cce5 76link += -Wl,-segalign,4000
eb40eaca 77
7c8912f8
JF
78dirs := Menes CyteKit Cydia SDURLCache
79
80code := $(foreach dir,$(dirs),$(wildcard $(foreach ext,h hpp c cpp m mm,$(dir)/*.$(ext))))
81code := $(filter-out SDURLCache/SDURLCacheTests.m,$(code))
e40620ab 82code += MobileCydia.mm Version.mm iPhonePrivate.h Cytore.hpp lookup3.c Sources.h Sources.mm DiskUsage.cpp
7c8912f8
JF
83
84source := $(filter %.m,$(code)) $(filter %.mm,$(code))
85source += $(filter %.c,$(code)) $(filter %.cpp,$(code))
86header := $(filter %.h,$(code)) $(filter %.hpp,$(code))
87
88object := $(source)
89object := $(object:.c=.o)
90object := $(object:.cpp=.o)
91object := $(object:.m=.o)
92object := $(object:.mm=.o)
93object := $(object:%=Objects/%)
94
0209cce5
JF
95libapt :=
96libapt += $(wildcard apt/apt-pkg/*.cc)
97libapt += $(wildcard apt/apt-pkg/deb/*.cc)
98libapt += $(wildcard apt/apt-pkg/contrib/*.cc)
99libapt += apt-tag/apt-pkg/tagfile-keys.cc
100libapt += apt/methods/store.cc
101libapt := $(filter-out %/srvrec.cc,$(libapt))
102libapt := $(patsubst %.cc,Objects/%.o,$(libapt))
103
104link += -Xarch_arm64 -Wl,-lz,-liconv
105
106flag += -DAPT_PKG_EXPOSE_STRING_VIEW
107flag += -Dsighandler_t=sig_t
108
109aptc := $(cycc) $(flag)
110aptc += -include apt.h
111aptc += -Wno-deprecated-register
112aptc += -Wno-unused-private-field
113aptc += -Wno-unused-variable
114
115cycc += -arch armv6
116cycc += -Xarch_armv6 -miphoneos-version-min=2.0
117flag += -Xarch_armv6 -marm # @synchronized
118flag += -Xarch_armv6 -mcpu=arm1176jzf-s
119flag += -mllvm -arm-reserve-r9
120link += -Xarch_armv6 -Wl,-lgcc_s.1
121
122plus += -std=c++11
123#plus += -Wp,-stdlib=libc++
124#link += libcxx/lib/libc++.a
125
4339c9ef 126images := $(shell find MobileCydia.app/ -type f -name '*.png')
8a4d4662
JF
127images := $(images:%=Images/%)
128
915284a6
JF
129lproj_deb := debs/cydia-lproj_$(version)_iphoneos-arm.deb
130
e17a8c4f 131all: MobileCydia
dc5812ec 132
5f6bff8c 133clean:
eaa9f122 134 rm -f MobileCydia postinst
8a4d4662 135 rm -rf Objects/ Images/
7c8912f8 136
0209cce5
JF
137Objects/%.o: %.cc $(header) apt.h apt-extra/*.h
138 @mkdir -p $(dir $@)
139 @echo "[cycc] $<"
140 @$(aptc) $(plus) -c -o $@ $< -Dmain=main_$(basename $(notdir $@))
141
7c8912f8
JF
142Objects/%.o: %.c $(header)
143 @mkdir -p $(dir $@)
144 @echo "[cycc] $<"
0209cce5 145 @$(cycc) -c -o $@ -x c $< $(flag)
7c8912f8
JF
146
147Objects/%.o: %.m $(header)
148 @mkdir -p $(dir $@)
149 @echo "[cycc] $<"
0209cce5 150 @$(cycc) -c -o $@ $< $(flag)
5f6bff8c 151
e40620ab
JF
152Objects/%.o: %.cpp $(header)
153 @mkdir -p $(dir $@)
154 @echo "[cycc] $<"
0209cce5 155 @$(cycc) $(plus) -c -o $@ $< $(flag)
e40620ab 156
7c8912f8
JF
157Objects/%.o: %.mm $(header)
158 @mkdir -p $(dir $@)
159 @echo "[cycc] $<"
0209cce5 160 @$(cycc) $(plus) -c -o $@ $< $(flag)
e95a1972 161
174327c1 162Objects/Version.o: Version.h
e61d7bfc 163
8a4d4662
JF
164Images/%.png: %.png
165 @mkdir -p $(dir $@)
166 @echo "[pngc] $<"
167 @./pngcrush.sh $< $@
168
0d5393af
JF
169sysroot: sysroot.sh
170 @echo "Your ./sysroot/ is either missing or out of date. Please read compiling.txt for help." 1>&2
8a2c6d14
JF
171 @echo 1>&2
172 @exit 1
173
0209cce5
JF
174Objects/libapt64.a: $(libapt)
175 @echo "[arch] $@"
176 @ar -rc $@ $^
177
178MobileCydia: sysroot $(object) entitlements.xml Objects/libapt64.a
179 @echo "[link] $@"
180 @$(cycc) -o $@ $(filter %.o,$^) $(link) $(libs) $(uikit) -Wl,-sdk_version,8.0
0dbada51 181 @mkdir -p bins
665d1e62 182 @cp -a $@ bins/$@-$(version)
443b9e05 183 @echo "[strp] $@"
c158ffc8 184 @strip $@
cc31c45d
JF
185 @echo "[uikt] $@"
186 @./uikit.sh $@
7c8912f8 187 @echo "[sign] $@"
9c0eddfd 188 @ldid -T0 -Sentitlements.xml $@ || { rm -f $@ && false; }
03c0f7a9 189
e967efd5 190cfversion: cfversion.mm
0209cce5 191 $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation
e967efd5
JF
192 @ldid -T0 -S $@
193
82e370b3 194setnsfpn: setnsfpn.cpp
0209cce5 195 $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link)
82e370b3
JF
196 @ldid -T0 -S $@
197
232b396b 198cydo: cydo.cpp
0209cce5 199 $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings
232b396b
JF
200 @ldid -T0 -S $@
201
f6b68b2c 202postinst: postinst.mm CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h
0209cce5 203 $(cycc) $(plus) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation -framework Foundation -framework UIKit
2d46d29e 204 @ldid -T0 -S $@
eaa9f122 205
232b396b 206debs/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
7e2bd591 207 sudo rm -rf _
03c0f7a9
JF
208 mkdir -p _/var/lib/cydia
209
33e30380
JF
210 mkdir -p _/etc/apt
211 cp -a Trusted.gpg _/etc/apt/trusted.gpg.d
212 cp -a Sources.list _/etc/apt/sources.list.d
213
03c0f7a9 214 mkdir -p _/usr/libexec
c21004b9 215 cp -a Library _/usr/libexec/cydia
d3b5a983 216 cp -a sysroot/usr/bin/du _/usr/libexec/cydia
e967efd5 217 cp -a cfversion _/usr/libexec/cydia
82e370b3 218 cp -a setnsfpn _/usr/libexec/cydia
03c0f7a9 219
232b396b 220 cp -a cydo _/usr/libexec/cydia
232b396b 221
2eef6631
JF
222 mkdir -p _/Library
223 cp -a LaunchDaemons _/Library/LaunchDaemons
03c0f7a9
JF
224
225 mkdir -p _/Applications
e17a8c4f 226 cp -a MobileCydia.app _/Applications/Cydia.app
915284a6 227 rm -rf _/Applications/Cydia.app/*.lproj
f7f32d9a 228 cp -a MobileCydia _/Applications/Cydia.app/Cydia
0209cce5 229 ln -s Cydia _/Applications/Cydia.app/store
e17a8c4f 230
8a4d4662
JF
231 cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';'
232
4339c9ef
JF
233 mkdir -p _/Applications/Cydia.app/Sources
234 ln -s /usr/share/bigboss/icons/bigboss.png _/Applications/Cydia.app/Sources/apt.bigboss.us.com.png
5ad3e6d9
JF
235 ln -s /usr/share/bigboss/icons/planetiphones.png _/Applications/Cydia.app/Sections/"Planet-iPhones Mods.png"
236
03c0f7a9 237 mkdir -p _/DEBIAN
915284a6 238 ./control.sh cydia.control _ >_/DEBIAN/control
eaa9f122 239 cp -a preinst postinst _/DEBIAN/
03c0f7a9 240
8fec9d25 241 find _ -exec touch -t "$$(date -j -f "%s" +"%Y%m%d%H%M.%S" "$$(git show --format='format:%ct' | head -n 1)")" {} ';'
7fc02989 242
7e2bd591
JF
243 sudo chown -R 0 _
244 sudo chgrp -R 0 _
0209cce5 245 sudo chmod 6755 _/usr/libexec/cydia/cydo
7e2bd591 246
3adcfba7 247 mkdir -p debs
f9ba524a 248 ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb
3adcfba7 249 $(dpkg) -b _ Cydia.deb
ce0372db 250 @echo "$$(stat -L -f "%z" Cydia.deb) $$(stat -f "%Y" Cydia.deb)"
8cc774c5 251
33e30380 252$(lproj_deb): $(shell find MobileCydia.app -name '*.strings') cydia-lproj.control
915284a6
JF
253 sudo rm -rf __
254 mkdir -p __/Applications/Cydia.app
255
256 cp -a MobileCydia.app/*.lproj __/Applications/Cydia.app
257
258 mkdir -p __/DEBIAN
259 ./control.sh cydia-lproj.control __ >__/DEBIAN/control
915284a6
JF
260
261 sudo chown -R 0 __
262 sudo chgrp -R 0 __
263
264 mkdir -p debs
265 ln -sf debs/cydia-lproj_$(version)_iphoneos-arm.deb Cydia_.deb
266 $(dpkg) -b __ Cydia_.deb
267 @echo "$$(stat -L -f "%z" Cydia_.deb) $$(stat -f "%Y" Cydia_.deb)"
268
269package: debs/cydia_$(version)_iphoneos-arm.deb $(lproj_deb)
aa60b57b 270
10ff7664 271.PHONY: all clean package