Commit | Line | Data |
---|---|---|
61d76999 | 1 | $(LD) ?= $(CC) |
dab0c363 | 2 | TARGET ?= picodrive |
3a770905 | 3 | ASAN ?= 0 |
079bc1bf | 4 | DEBUG ?= 0 |
6ef4af06 | 5 | CFLAGS += -I. |
61d76999 | 6 | CYCLONE_CC ?= gcc |
7 | CYCLONE_CXX ?= g++ | |
c1d15f73 | 8 | |
d4d62665 | 9 | all: config.mak target_ |
10 | ||
11 | ifndef NO_CONFIG_MAK | |
12 | ifneq ($(wildcard config.mak),) | |
13 | config.mak: ./configure | |
14 | @echo $@ is out-of-date, running configure | |
15 | @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh | |
16 | include config.mak | |
17 | else | |
18 | config.mak: | |
19 | @echo "Please run ./configure before running make!" | |
20 | @exit 1 | |
21 | endif | |
22 | else # NO_CONFIG_MAK | |
23 | config.mak: | |
24 | endif | |
25 | ||
3901ab97 | 26 | # This is actually needed, believe me - one bit is used as a flag in some tables |
0198149a | 27 | # If you really have to disable this, set NO_ALIGN_FUNCTIONS elsewhere. |
28 | ifndef NO_ALIGN_FUNCTIONS | |
29 | CFLAGS += -falign-functions=2 | |
30 | endif | |
0198149a | 31 | |
32 | # profiling | |
33 | pprof ?= 0 | |
34 | gperf ?= 0 | |
35 | ||
36 | ifneq ("$(PLATFORM)", "libretro") | |
37 | CFLAGS += -Wall -g | |
cdc6aac4 | 38 | ifneq ("$(PLATFORM)", "psp") |
9511ffd1 | 39 | ifneq ($(findstring gcc,$(shell $(CC) -v 2>&1)),) |
0198149a | 40 | CFLAGS += -ffunction-sections -fdata-sections |
41 | LDFLAGS += -Wl,--gc-sections | |
42 | endif | |
cdc6aac4 | 43 | endif |
9511ffd1 | 44 | |
3a770905 | 45 | ifeq "$(ASAN)" "1" |
46 | CFLAGS += -fsanitize=address -fsanitize=leak -fsanitize=bounds -fno-omit-frame-pointer -fno-common -O1 -g | |
47 | LDLIBS += -fsanitize=address -fsanitize=leak -fsanitize=bounds -static-libasan | |
48 | else | |
0198149a | 49 | ifeq "$(DEBUG)" "0" |
50 | CFLAGS += -O3 -DNDEBUG | |
7401f700 | 51 | else |
52 | CFLAGS += -O1 | |
3a770905 | 53 | endif |
0198149a | 54 | endif |
61d76999 | 55 | LD = $(CC) |
56 | OBJOUT ?= -o | |
57 | LINKOUT ?= -o | |
0198149a | 58 | endif |
59 | ||
3a770905 | 60 | |
61 | chkCCflag = $(shell n=/dev/null; echo $(1) | tr " " "\n" | while read f; do \ | |
62 | $(CC) $$f -x c -c $$n -o $$n 2>$$n && echo "_$$f" | tr -d _; done) | |
63 | ||
250c8ffb | 64 | ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","gp2x" "opendingux" "rpi1")) |
fe344bd3 | 65 | # very small caches, avoid optimization options making the binary much bigger |
8013663e | 66 | CFLAGS += -fno-common -finline-limit=42 -fno-unroll-loops -ffast-math |
67 | CFLAGS += $(call chkCCflag, -fno-stack-protector) | |
3a770905 | 68 | ifneq ($(call chkCCflag, -fipa-ra),) # gcc >= 5 |
69 | CFLAGS += $(call chkCCflag, -flto -fipa-pta -fipa-ra) | |
70 | else | |
71 | # these improve execution speed on 32bit arm/mips with gcc pre-5 toolchains | |
58fc34b1 | 72 | CFLAGS += $(call chkCCflag, -fno-caller-saves -fno-guess-branch-probability -fno-regmove) |
3a770905 | 73 | # very old gcc toolchains may not have these options |
8013663e | 74 | CFLAGS += $(call chkCCflag, -fno-tree-loop-if-convert -fipa-pta -fno-ipa-cp) |
3a770905 | 75 | endif |
b5d8374c | 76 | else |
5f9901e0 | 77 | ifneq ($(STATIC_LINKING), 1) |
b5d8374c | 78 | CFLAGS += $(call chkCCflag, -flto) |
3a770905 | 79 | endif |
5f9901e0 | 80 | endif |
3a770905 | 81 | |
82 | # revision info from repository if this not a tagged release | |
83 | ifeq "$(shell git describe --tags --exact-match HEAD 2>/dev/null)" "" | |
12d506ba | 84 | GIT_REVISION ?= -$(shell git rev-parse --short HEAD || echo unknown) |
fe344bd3 | 85 | endif |
ab43a4b2 | 86 | CFLAGS += -DREVISION=\"$(GIT_REVISION)\" |
fe344bd3 | 87 | |
d4d62665 | 88 | # default settings |
4bb0b70e | 89 | use_libchdr ?= 1 |
d4d62665 | 90 | ifeq "$(ARCH)" "arm" |
91 | use_cyclone ?= 1 | |
92 | use_drz80 ?= 1 | |
93 | use_sh2drc ?= 1 | |
0a91c6e9 | 94 | use_svpdrc ?= 1 |
d4d62665 | 95 | |
0a91c6e9 | 96 | asm_memory ?= 1 |
97 | asm_render ?= 1 | |
98 | asm_ym2612 ?= 1 | |
99 | asm_misc ?= 1 | |
0a91c6e9 | 100 | asm_cdmemory ?= 1 |
101 | asm_mix ?= 1 | |
23eef37f | 102 | asm_32xdraw ?= 1 |
0495df5d | 103 | asm_32xmemory ?= 1 |
03d5f510 | 104 | else |
8bb48947 | 105 | use_fame ?= 1 |
106 | use_cz80 ?= 1 | |
68e50296 | 107 | ifneq (,$(filter x86% i386% i686% mips% aarch% riscv% powerpc% ppc%, $(ARCH))) |
8bb48947 | 108 | use_sh2drc ?= 1 |
d4d62665 | 109 | endif |
03d5f510 | 110 | endif |
e743be20 | 111 | |
e743be20 | 112 | -include Makefile.local |
113 | ||
45d0add2 | 114 | # TODO this should somehow go to the platform directory? |
115 | ifeq "$(PLATFORM)" "generic" | |
dab0c363 | 116 | PicoDrive.zip: $(TARGET) |
45d0add2 | 117 | $(RM) -rf .od_data |
118 | mkdir .od_data | |
119 | cp -r platform/linux/skin .od_data | |
120 | cp platform/game_def.cfg .od_data | |
89319e49 | 121 | $(STRIP) $< -o .od_data/picodrive |
45d0add2 | 122 | cd .od_data && zip -9 -r ../$@ * |
dab0c363 | 123 | all: PicoDrive.zip |
45d0add2 | 124 | endif |
d4bea61c | 125 | |
1909e86c | 126 | ifeq "$(PLATFORM)" "win32" |
127 | PicoDrive.zip: $(TARGET) | |
128 | $(RM) -rf .od_data | |
129 | mkdir .od_data | |
130 | cp -r platform/linux/skin .od_data | |
131 | cp platform/game_def.cfg .od_data | |
132 | $(STRIP) $< -o .od_data/PicoDrive.exe | |
133 | cd .od_data && zip -9 -r ../$@ * | |
134 | all: PicoDrive.zip | |
135 | endif | |
136 | ||
45d0add2 | 137 | ifeq "$(PLATFORM)" "opendingux" |
3901ab97 | 138 | .od_data: $(TARGET) |
139 | $(RM) -rf .od_data | |
45d0add2 | 140 | mkdir .od_data |
40a7d177 | 141 | cp -r platform/opendingux/data/. .od_data |
142 | cp platform/game_def.cfg .od_data | |
89319e49 | 143 | $(STRIP) $< -o .od_data/picodrive |
40a7d177 | 144 | .PHONY: .od_data |
3901ab97 | 145 | |
5d3b7ae2 | 146 | ifneq (,$(filter %__DINGUX__, $(CFLAGS))) |
147 | # "legacy" dingux without opk support | |
dab0c363 | 148 | PicoDrive-dge.zip: .od_data |
3901ab97 | 149 | rm -f .od_data/default.*.desktop |
150 | cd .od_data && zip -9 -r ../$@ * | |
dab0c363 | 151 | all: PicoDrive-dge.zip |
5d3b7ae2 | 152 | CFLAGS += -DSDL_SURFACE_SW # some legacy dinguces had bugs in HWSURFACE |
3901ab97 | 153 | else |
250c8ffb | 154 | ifneq (,$(filter %__MIYOO__, $(CFLAGS))) |
e3fa3ee2 | 155 | PicoDrive-miyoo.ipk: .od_data |
250c8ffb | 156 | rm -f .od_data/default.*.desktop .od_data/PicoDrive.dge |
e3fa3ee2 A |
157 | gm2xpkg -i platform/miyoo/pkg.cfg |
158 | mv picodrive.ipk $@ | |
159 | @gm2xpkg -c platform/miyoo/pkg.cfg >/dev/null 2>&1 | |
160 | all: PicoDrive-miyoo.ipk | |
250c8ffb | 161 | else |
dab0c363 | 162 | PicoDrive.opk: .od_data |
3901ab97 | 163 | rm -f .od_data/PicoDrive.dge |
164 | mksquashfs .od_data $@ -all-root -noappend -no-exports -no-xattrs | |
dab0c363 | 165 | all: PicoDrive.opk |
3901ab97 | 166 | endif |
250c8ffb | 167 | endif |
d4bea61c | 168 | |
3901ab97 | 169 | OBJS += platform/opendingux/inputmap.o |
b437951a | 170 | use_inputmap ?= 1 |
3901ab97 | 171 | |
d4bea61c PC |
172 | # OpenDingux is a generic platform, really. |
173 | PLATFORM := generic | |
174 | endif | |
8450a2f5 C |
175 | ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","rpi1" "rpi2")) |
176 | CFLAGS += -DHAVE_GLES -DRASPBERRY | |
177 | CFLAGS += -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux/ | |
9c0ac970 C |
178 | LDFLAGS += -ldl -lbcm_host -L/opt/vc/lib |
179 | # Stupid renaming occured in latest raspbian... | |
180 | ifneq (,$(wildcard /opt/vc/lib/libbrcmGLESv2.so)) | |
181 | LDFLAGS += -lbrcmEGL -lbrcmGLESv2 | |
182 | else | |
6c5784f0 | 183 | LDFLAGS += -lEGL -lGLESv2 # on raspi GLESv1_CM is included in GLESv2 |
9c0ac970 | 184 | endif |
8450a2f5 | 185 | OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME |
d80cb20b | 186 | OBJS += platform/common/plat_sdl.o platform/common/inputmap_kbd.o |
8450a2f5 | 187 | OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o |
58fc34b1 | 188 | OBJS += platform/libpicofe/linux/plat.o |
8450a2f5 C |
189 | USE_FRONTEND = 1 |
190 | endif | |
2446536b | 191 | ifeq "$(PLATFORM)" "generic" |
23e47196 | 192 | #ifeq (y,$(shell echo "\#include <GLES/gl.h>" | $(CC) -E -xc - >/dev/null 2>&1 && echo y)) |
193 | ifeq "$(HAVE_GLES)" "1" | |
54f74b81 | 194 | CFLAGS += -DHAVE_GLES |
23e47196 | 195 | LDFLAGS += -lEGL -lGLESv1_CM |
196 | endif | |
54f74b81 | 197 | CFLAGS += -DSDL_OVERLAY_2X -DSDL_BUFFER_3X -DSDL_REDRAW_EVT |
2446536b | 198 | OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME |
b437951a | 199 | ifeq "$(use_inputmap)" "1" |
200 | OBJS += platform/common/plat_sdl.o platform/opendingux/inputmap.o | |
201 | else | |
202 | OBJS += platform/common/plat_sdl.o platform/common/inputmap_kbd.o | |
203 | endif | |
2446536b | 204 | OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o |
58fc34b1 | 205 | OBJS += platform/libpicofe/linux/plat.o |
2446536b | 206 | USE_FRONTEND = 1 |
207 | endif | |
208 | ifeq "$(PLATFORM)" "pandora" | |
209 | platform/common/menu_pico.o: CFLAGS += -DPANDORA | |
fcdf2aff | 210 | platform/libpicofe/linux/plat.o: CFLAGS += -DPANDORA |
2446536b | 211 | OBJS += platform/pandora/plat.o |
212 | OBJS += platform/pandora/asm_utils.o | |
213 | OBJS += platform/common/arm_utils.o | |
95a46e3f | 214 | OBJS += platform/libpicofe/linux/in_evdev.o |
2446536b | 215 | OBJS += platform/libpicofe/linux/fbdev.o |
216 | OBJS += platform/libpicofe/linux/xenv.o | |
6c5784f0 | 217 | OBJS += platform/libpicofe/linux/plat.o |
2446536b | 218 | OBJS += platform/libpicofe/pandora/plat.o |
219 | USE_FRONTEND = 1 | |
220 | endif | |
75a30842 | 221 | ifeq "$(PLATFORM)" "gp2x" |
222 | OBJS += platform/common/arm_utils.o | |
95a46e3f | 223 | OBJS += platform/libpicofe/linux/in_evdev.o |
6c5784f0 | 224 | OBJS += platform/libpicofe/linux/plat.o |
75a30842 | 225 | OBJS += platform/libpicofe/gp2x/in_gp2x.o |
226 | OBJS += platform/libpicofe/gp2x/soc.o | |
227 | OBJS += platform/libpicofe/gp2x/soc_mmsp2.o | |
228 | OBJS += platform/libpicofe/gp2x/soc_pollux.o | |
229 | OBJS += platform/libpicofe/gp2x/plat.o | |
230 | OBJS += platform/libpicofe/gp2x/pollux_set.o | |
231 | OBJS += platform/gp2x/940ctl.o | |
232 | OBJS += platform/gp2x/plat.o | |
233 | OBJS += platform/gp2x/emu.o | |
234 | OBJS += platform/gp2x/vid_mmsp2.o | |
235 | OBJS += platform/gp2x/vid_pollux.o | |
236 | OBJS += platform/gp2x/warm.o | |
237 | USE_FRONTEND = 1 | |
3167aa9a | 238 | PLATFORM_MP3 ?= 1 |
75a30842 | 239 | endif |
cdc6aac4 | 240 | ifeq "$(PLATFORM)" "psp" |
f55fb314 | 241 | CFLAGS += -DUSE_BGR565 -G8 # -DLPRINTF_STDIO -DFW15 |
bfd66623 | 242 | LDLIBS += -lpspgu -lpspge -lpsppower -lpspaudio -lpspdisplay -lpspaudiocodec |
a20af2f9 | 243 | LDLIBS += -lpspctrl |
cdc6aac4 | 244 | platform/common/main.o: CFLAGS += -Dmain=pico_main |
245 | OBJS += platform/psp/plat.o | |
246 | OBJS += platform/psp/emu.o | |
247 | OBJS += platform/psp/in_psp.o | |
248 | OBJS += platform/psp/psp.o | |
cdc6aac4 | 249 | OBJS += platform/psp/asm_utils.o |
250 | OBJS += platform/psp/mp3.o | |
cdc6aac4 | 251 | USE_FRONTEND = 1 |
252 | endif | |
cb774958 FJTM |
253 | ifeq "$(PLATFORM)" "ps2" |
254 | CFLAGS += -DUSE_BGR555 # -DLOG_TO_FILE | |
255 | LDLIBS += -lpatches -lgskit -ldmakit -lps2_drivers | |
256 | OBJS += platform/ps2/plat.o | |
e22b24b8 FJTM |
257 | OBJS += platform/ps2/emu.o |
258 | OBJS += platform/ps2/in_ps2.o | |
cb774958 FJTM |
259 | USE_FRONTEND = 1 |
260 | endif | |
1909e86c | 261 | ifeq "$(PLATFORM)" "win32" |
262 | CFLAGS += -DSDL_OVERLAY_2X -DSDL_BUFFER_3X -DSDL_REDRAW_EVT | |
263 | OBJS += platform/win32/plat.o | |
264 | OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME | |
265 | OBJS += platform/common/plat_sdl.o platform/common/inputmap_kbd.o | |
266 | OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o | |
267 | USE_FRONTEND = 1 | |
268 | endif | |
2446536b | 269 | ifeq "$(PLATFORM)" "libretro" |
7612bf90 | 270 | OBJS += platform/libretro/libretro.o |
a5085db3 | 271 | ifneq ($(STATIC_LINKING), 1) |
15cc45c0 | 272 | CFLAGS += -DHAVE_ZLIB |
273 | OBJS += platform/libretro/libretro-common/formats/png/rpng.o | |
274 | OBJS += platform/libretro/libretro-common/streams/trans_stream.o | |
275 | OBJS += platform/libretro/libretro-common/streams/trans_stream_pipe.o | |
276 | OBJS += platform/libretro/libretro-common/streams/trans_stream_zlib.o | |
277 | OBJS += platform/libretro/libretro-common/file/file_path_io.o | |
278 | OBJS += platform/libretro/libretro-common/file/file_path.o | |
279 | OBJS += platform/libretro/libretro-common/vfs/vfs_implementation.o | |
280 | OBJS += platform/libretro/libretro-common/time/rtime.o | |
281 | OBJS += platform/libretro/libretro-common/string/stdstring.o | |
b4e7cd1b | 282 | OBJS += platform/libretro/libretro-common/compat/compat_strcasestr.o |
15cc45c0 | 283 | OBJS += platform/libretro/libretro-common/encodings/encoding_utf.o |
284 | OBJS += platform/libretro/libretro-common/compat/compat_strl.o | |
a5085db3 | 285 | ifeq "$(USE_LIBRETRO_VFS)" "1" |
61d76999 | 286 | OBJS += platform/libretro/libretro-common/compat/compat_posix_string.o |
61d76999 | 287 | OBJS += platform/libretro/libretro-common/compat/fopen_utf8.o |
61d76999 | 288 | OBJS += platform/libretro/libretro-common/streams/file_stream.o |
289 | OBJS += platform/libretro/libretro-common/streams/file_stream_transforms.o | |
61d76999 | 290 | endif |
a5085db3 | 291 | endif |
292 | ifeq "$(USE_LIBRETRO_VFS)" "1" | |
293 | OBJS += platform/libretro/libretro-common/memmap/memmap.o | |
294 | endif | |
2446536b | 295 | endif |
296 | ||
297 | ifeq "$(USE_FRONTEND)" "1" | |
298 | ||
e743be20 | 299 | # common |
d5d17782 | 300 | OBJS += platform/common/main.o platform/common/emu.o platform/common/upscale.o \ |
bac44b18 | 301 | platform/common/menu_pico.o platform/common/keyboard.o platform/common/config_file.o |
e743be20 | 302 | |
303 | # libpicofe | |
304 | OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \ | |
6c5784f0 | 305 | platform/libpicofe/fonts.o |
23e47196 | 306 | ifneq (,$(filter %HAVE_GLES, $(CFLAGS))) |
307 | OBJS += platform/libpicofe/gl.o platform/libpicofe/gl_platform.o | |
308 | endif | |
e743be20 | 309 | |
d4d62665 | 310 | # libpicofe - sound |
311 | OBJS += platform/libpicofe/sndout.o | |
312 | ifneq ($(findstring oss,$(SOUND_DRIVERS)),) | |
313 | platform/libpicofe/sndout.o: CFLAGS += -DHAVE_OSS | |
314 | OBJS += platform/libpicofe/linux/sndout_oss.o | |
315 | endif | |
316 | ifneq ($(findstring alsa,$(SOUND_DRIVERS)),) | |
317 | platform/libpicofe/sndout.o: CFLAGS += -DHAVE_ALSA | |
318 | OBJS += platform/libpicofe/linux/sndout_alsa.o | |
319 | endif | |
320 | ifneq ($(findstring sdl,$(SOUND_DRIVERS)),) | |
321 | platform/libpicofe/sndout.o: CFLAGS += -DHAVE_SDL | |
322 | OBJS += platform/libpicofe/sndout_sdl.o | |
323 | endif | |
e743be20 | 324 | |
e743be20 | 325 | ifeq "$(ARCH)" "arm" |
d4d62665 | 326 | OBJS += platform/libpicofe/arm_linux.o |
d4d62665 | 327 | endif |
e743be20 | 328 | |
2446536b | 329 | endif # USE_FRONTEND |
330 | ||
cdc6aac4 | 331 | ifneq "$(PLATFORM)" "psp" |
340e528f | 332 | OBJS += platform/common/mp3.o platform/common/mp3_sync.o |
75a30842 | 333 | ifeq "$(PLATFORM_MP3)" "1" |
340e528f | 334 | OBJS += platform/common/mp3_helix.o |
75a30842 | 335 | else ifeq "$(HAVE_LIBAVCODEC)" "1" |
fc11dd05 | 336 | OBJS += platform/common/mp3_libavcodec.o |
337 | else | |
eba93964 | 338 | #OBJS += platform/common/mp3_minimp3.o |
339 | OBJS += platform/common/mp3_drmp3.o | |
fc11dd05 | 340 | endif |
cdc6aac4 | 341 | endif |
2446536b | 342 | |
4bb0b70e | 343 | ifeq (1,$(use_libchdr)) |
e1b91654 | 344 | CFLAGS += -DUSE_LIBCHDR |
4bb0b70e | 345 | |
346 | # chdr | |
e1b91654 | 347 | CHDR = pico/cd/libchdr |
4bb0b70e | 348 | CHDR_OBJS += $(CHDR)/src/libchdr_chd.o $(CHDR)/src/libchdr_cdrom.o |
349 | CHDR_OBJS += $(CHDR)/src/libchdr_flac.o | |
350 | CHDR_OBJS += $(CHDR)/src/libchdr_bitstream.o $(CHDR)/src/libchdr_huffman.o | |
351 | ||
cc1174c9 | 352 | LZMA = $(CHDR)/deps/lzma-24.05 |
4bb0b70e | 353 | LZMA_OBJS += $(LZMA)/src/CpuArch.o $(LZMA)/src/Alloc.o $(LZMA)/src/LzmaEnc.o |
354 | LZMA_OBJS += $(LZMA)/src/Sort.o $(LZMA)/src/LzmaDec.o $(LZMA)/src/LzFind.o | |
355 | LZMA_OBJS += $(LZMA)/src/Delta.o | |
cc1174c9 | 356 | $(LZMA_OBJS): CFLAGS += -DZ7_ST -Wno-unused |
357 | ||
358 | ZSTD = $(CHDR)/deps/zstd-1.5.6/lib | |
359 | ZSTD_OBJS += $(ZSTD)/common/entropy_common.o $(ZSTD)/common/error_private.o | |
360 | ZSTD_OBJS += $(ZSTD)/common/fse_decompress.o $(ZSTD)/common/xxhash.o | |
361 | ZSTD_OBJS += $(ZSTD)/common/zstd_common.o | |
362 | ZSTD_OBJS += $(ZSTD)/decompress/huf_decompress.o | |
e8ca1082 | 363 | ifneq (,$(filter x86%, $(ARCH))) |
cc1174c9 | 364 | ZSTD_OBJS += $(ZSTD)/decompress/huf_decompress_amd64.o |
e8ca1082 | 365 | endif |
cc1174c9 | 366 | ZSTD_OBJS += $(ZSTD)/decompress/zstd_ddict.o |
367 | ZSTD_OBJS += $(ZSTD)/decompress/zstd_decompress_block.o | |
368 | ZSTD_OBJS += $(ZSTD)/decompress/zstd_decompress.o | |
369 | $(ZSTD_OBJS) $(CHDR_OBJS): CFLAGS += -I$(ZSTD) -Wno-unused | |
4bb0b70e | 370 | |
a43c77c0 | 371 | OBJS += $(CHDR_OBJS) $(ZSTD_OBJS) |
a5085db3 | 372 | ifneq ($(STATIC_LINKING), 1) |
a43c77c0 | 373 | OBJS += $(LZMA_OBJS) |
a5085db3 | 374 | endif |
e1b91654 | 375 | # ouf... prepend includes to overload headers available in the toolchain |
376 | CFLAGS := -I$(LZMA)/include -I$(CHDR)/include $(CFLAGS) | |
15ca7152 | 377 | endif |
378 | ||
c79d0bb9 | 379 | ifeq "$(PLATFORM_ZLIB)" "1" |
e743be20 | 380 | # zlib |
381 | OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \ | |
382 | zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o | |
325ee167 | 383 | CFLAGS += -Izlib |
384 | endif | |
e743be20 | 385 | # unzip |
b4c2331e | 386 | OBJS += unzip/unzip.o |
e743be20 | 387 | |
d4d62665 | 388 | |
e743be20 | 389 | include platform/common/common.mak |
390 | ||
98dbc3ab | 391 | OBJS += $(OBJS_COMMON) |
392 | CFLAGS += $(addprefix -D,$(DEFINES)) | |
393 | ||
1f49b750 | 394 | ifneq (,$(findstring sdl,$(OBJS))) |
395 | CFLAGS += -DUSE_SDL | |
396 | endif | |
397 | ||
9aee8770 | 398 | ifneq ($(findstring gcc,$(CC)),) |
61d76999 | 399 | ifneq ($(findstring SunOS,$(shell uname -a)),SunOS) |
4b24b6b7 | 400 | ifneq ($(findstring clang,$(shell $(CC) -v 2>&1)),) |
512898fe | 401 | LDFLAGS += -Wl,-map,$(TARGET).map |
402 | else | |
9aee8770 | 403 | LDFLAGS += -Wl,-Map=$(TARGET).map |
404 | endif | |
61d76999 | 405 | endif |
512898fe | 406 | endif |
9aee8770 | 407 | |
18538b2c | 408 | target_: $(TARGET) |
e743be20 | 409 | |
410 | clean: | |
d40a5af4 | 411 | $(RM) $(TARGET) $(OBJS) pico/pico_int_offs.h |
5fce11a3 | 412 | $(MAKE) -C cpu/cyclone clean |
413 | $(MAKE) -C cpu/musashi clean | |
3167aa9a | 414 | $(MAKE) -C tools clean |
3901ab97 | 415 | $(RM) -r .od_data |
e743be20 | 416 | |
d4d62665 | 417 | $(TARGET): $(OBJS) |
61d76999 | 418 | |
a5085db3 | 419 | ifeq ($(STATIC_LINKING_LINK), 1) |
7612bf90 | 420 | $(AR) rcs $@ $^ |
421 | else | |
0004aa7c | 422 | $(LD) $(LINKOUT)$@ $^ $(CFLAGS) $(LDFLAGS) $(LDLIBS) |
7612bf90 | 423 | endif |
e743be20 | 424 | |
cdc6aac4 | 425 | ifeq "$(PLATFORM)" "psp" |
6c5784f0 | 426 | PSPSDK ?= $(shell psp-config --pspsdk-path) |
427 | TARGET = PicoDrive | |
cdc6aac4 | 428 | PSP_EBOOT_TITLE = PicoDrive |
6c5784f0 | 429 | PSP_EBOOT_ICON = platform/psp/data/icon.png |
cdc6aac4 | 430 | LIBS += -lpng -lm -lz -lpspgu -lpsppower -lpspaudio -lpsprtc -lpspaudiocodec |
431 | EXTRA_TARGETS = EBOOT.PBP | |
6c5784f0 | 432 | include $(PSPSDK)/lib/build.mak |
cdc6aac4 | 433 | # TODO image generation |
434 | endif | |
435 | ||
e743be20 | 436 | pprof: platform/linux/pprof.c |
c1d15f73 | 437 | $(CC) $(CFLAGS) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ $(LDFLAGS) $(LDLIBS) |
d4d62665 | 438 | |
a6c0ab7d | 439 | pico/pico_int_offs.h: tools/mkoffsets.sh |
a5085db3 | 440 | make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS) -UUSE_LIBRETRO_VFS" XPLATFORM="$(platform)" |
98dbc3ab | 441 | |
61d76999 | 442 | %.o: %.c |
443 | $(CC) -c $(OBJOUT)$@ $< $(CFLAGS) | |
444 | ||
98dbc3ab | 445 | .s.o: |
446 | $(CC) $(CFLAGS) -c $< -o $@ | |
447 | ||
ae7830aa | 448 | .S.o: |
449 | $(CC) $(CFLAGS) -c $< -o $@ | |
450 | ||
895d1512 | 451 | # special flags - perhaps fix this someday instead? |
452 | pico/draw.o: CFLAGS += -fno-strict-aliasing | |
453 | pico/draw2.o: CFLAGS += -fno-strict-aliasing | |
454 | pico/mode4.o: CFLAGS += -fno-strict-aliasing | |
455 | pico/cd/memory.o: CFLAGS += -fno-strict-aliasing | |
456 | pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing | |
457 | pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing | |
458 | pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing | |
459 | pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing | |
8284ab71 | 460 | ifeq (1,$(use_sh2drc)) |
461 | ifneq (,$(findstring -flto,$(CFLAGS))) | |
0f7a30ed | 462 | # if using the DRC, memory and sh2soc directly use the DRC register for SH2 SR |
463 | # to avoid saving and reloading it. However, this collides with the use of LTO. | |
8284ab71 | 464 | pico/32x/memory.o: CFLAGS += -fno-lto |
465 | pico/32x/sh2soc.o: CFLAGS += -fno-lto | |
b5d8374c | 466 | cpu/sh2/compiler.o: CFLAGS += -fno-lto |
467 | endif | |
468 | ifneq (,$(filter mips64%, $(ARCH))$(filter %mips32r2, $(CFLAGS))) | |
469 | CFLAGS += -DMIPS_USE_SYNCI # mips32r2 clear_cache uses SYNCI instead of a syscall | |
8284ab71 | 470 | endif |
471 | endif | |
895d1512 | 472 | |
0bc48495 | 473 | # fame needs ~2GB of RAM to compile on gcc 4.8 |
474 | # on x86, this is reduced by ~300MB when debug info is off (but not on ARM) | |
0270424f | 475 | # not using O3 and -fno-expensive-optimizations seems to also help, but you may |
476 | # want to remove this stuff for better performance if your compiler can handle it | |
c7397eda | 477 | ifeq "$(DEBUG)" "0" |
61d76999 | 478 | ifeq (,$(findstring msvc,$(platform))) |
0270424f | 479 | cpu/fame/famec.o: CFLAGS += -g0 -O2 -fno-expensive-optimizations |
61d76999 | 480 | else |
481 | cpu/fame/famec.o: CFLAGS += -Od | |
482 | endif | |
c6e1e977 | 483 | endif |
0bc48495 | 484 | |
3167aa9a | 485 | tools/make_carthw_c: |
486 | make -C tools make_carthw_c | |
487 | pico/carthw_cfg.c: pico/carthw.cfg tools/make_carthw_c | |
40d22a8e | 488 | tools/make_carthw_c $< $@ |
489 | ||
03718e62 | 490 | # preprocessed asm files most probably include the offsets file |
491 | $(filter %.S,$(SRCS_COMMON)): pico/pico_int_offs.h | |
492 | ||
110a49ed | 493 | # random deps - TODO remove this and compute dependcies automatically |
898d51a7 | 494 | pico/carthw/svp/compiler.o : cpu/drc/emit_arm.c |
8bb48947 | 495 | cpu/sh2/compiler.o : cpu/drc/emit_arm.c cpu/drc/emit_arm64.c cpu/drc/emit_ppc.c |
e7ee5010 | 496 | cpu/sh2/compiler.o : cpu/drc/emit_x86.c cpu/drc/emit_mips.c cpu/drc/emit_riscv.c |
98dbc3ab | 497 | cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c |
110a49ed | 498 | pico/pico.o pico/cd/mcd.o pico/32x/32x.o : pico/pico_cmn.c |
499 | pico/memory.o pico/cd/memory.o pico/32x/memory.o : pico/memory.h | |
500 | $(shell grep -rl pico_int.h pico) : pico/pico_int.h | |
6e05b76b | 501 | # pico/cart.o : pico/carthw_cfg.c |
98dbc3ab | 502 | cpu/fame/famec.o: cpu/fame/famec.c cpu/fame/famec_opcodes.h |
f2554438 | 503 | platform/common/menu_pico.o: platform/libpicofe/menu.c |