forked from notaz/picodrive
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
299 lines (262 loc) · 9.3 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
TARGET ?= PicoDrive
DEBUG ?= 0
CFLAGS += -Wall -ggdb -ffunction-sections -fdata-sections
CFLAGS += -I.
ifeq "$(DEBUG)" "0"
CFLAGS += -O2 -DNDEBUG
endif
# This is actually needed, believe me.
# If you really have to disable this, set NO_ALIGN_FUNCTIONS elsewhere.
ifndef NO_ALIGN_FUNCTIONS
CFLAGS += -falign-functions=2
endif
LDFLAGS += -Wl,--gc-sections
# profiling
pprof ?= 0
gperf ?= 0
all: config.mak target_
ifndef NO_CONFIG_MAK
ifneq ($(wildcard config.mak),)
config.mak: ./configure
@echo $@ is out-of-date, running configure
@sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
include config.mak
else
config.mak:
@echo "Please run ./configure before running make!"
@exit 1
endif
else # NO_CONFIG_MAK
config.mak:
endif
ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","gp2x" "opendingux" "rpi1"))
# very small caches, avoid optimization options making the binary much bigger
CFLAGS += -finline-limit=42 -fno-unroll-loops -fno-ipa-cp -ffast-math
# this gets you about 20% better execution speed on 32bit arm/mips
CFLAGS += -fno-common -fno-stack-protector -fno-guess-branch-probability -fno-caller-saves -fno-tree-loop-if-convert -fno-regmove
endif
#OBJS += align.o
# default settings
ifeq "$(ARCH)" "arm"
use_cyclone ?= 1
use_drz80 ?= 1
use_sh2drc ?= 1
use_svpdrc ?= 1
asm_memory ?= 1
asm_render ?= 1
asm_ym2612 ?= 1
asm_misc ?= 1
asm_cdmemory ?= 1
asm_mix ?= 1
asm_32xdraw ?= 1
asm_32xmemory ?= 1
else ifneq (,$(findstring 86,$(ARCH)))
use_fame ?= 1
use_cz80 ?= 1
use_sh2drc ?= 1
else ifneq (,$(findstring mips,$(ARCH)))
use_fame ?= 1
use_cz80 ?= 1
use_sh2drc ?= 1
else ifneq (,$(findstring aarch64,$(ARCH)))
use_fame ?= 1
use_cz80 ?= 1
use_sh2drc ?= 1
else ifneq (,$(findstring riscv,$(ARCH)))
use_fame ?= 1
use_cz80 ?= 1
use_sh2drc ?= 1
endif
-include Makefile.local
ifeq "$(PLATFORM)" "opendingux"
ipk: all
@rm -rf /tmp/.picodrive-ipk/ && mkdir -p /tmp/.picodrive-ipk/root/home/retrofw/emus/picodrive /tmp/.picodrive-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators /tmp/.picodrive-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators.systems
@cp -r picodrive/skin picodrive/picodrive.dge picodrive/picodrive.png /tmp/.picodrive-ipk/root/home/retrofw/emus/picodrive
@cp picodrive/picodrive.lnk /tmp/.picodrive-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators
@cp picodrive/megadrive.picodrive.lnk picodrive/segacd.picodrive.lnk picodrive/gamegear.picodrive.lnk picodrive/mastersystem.picodrive.lnk /tmp/.picodrive-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators.systems
@sed "s/^Version:.*/Version: $$(date +%Y%m%d)/" picodrive/control > /tmp/.picodrive-ipk/control
@cp picodrive/conffiles /tmp/.picodrive-ipk/
@tar --owner=0 --group=0 -czvf /tmp/.picodrive-ipk/control.tar.gz -C /tmp/.picodrive-ipk/ control conffiles
@tar --owner=0 --group=0 -czvf /tmp/.picodrive-ipk/data.tar.gz -C /tmp/.picodrive-ipk/root/ .
@echo 2.0 > /tmp/.picodrive-ipk/debian-binary
@ar r picodrive/picodrive.ipk /tmp/.picodrive-ipk/control.tar.gz /tmp/.picodrive-ipk/data.tar.gz /tmp/.picodrive-ipk/debian-binary
opk: all
@touch picodrive/picodrive.elf picodrive/picodrive.dge
@mksquashfs \
picodrive/default.gcw0.desktop \
picodrive/default.retrofw.desktop \
picodrive/megadrive.retrofw.desktop \
picodrive/segacd.retrofw.desktop \
picodrive/32x.retrofw.desktop \
picodrive/picodrive.elf \
picodrive/picodrive.dge \
picodrive/skin \
picodrive/picodrive.png \
picodrive/picodrive.opk \
-all-root -noappend -no-exports -no-xattrs
OBJS += platform/opendingux/inputmap.o
# OpenDingux is a generic platform, really.
PLATFORM := generic
endif
ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","rpi1" "rpi2"))
CFLAGS += -DHAVE_GLES -DRASPBERRY
CFLAGS += -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux/
LDFLAGS += -ldl -lbcm_host -L/opt/vc/lib
# Stupid renaming occured in latest raspbian...
ifneq (,$(wildcard /opt/vc/lib/libbrcmGLESv2.so))
LDFLAGS += -lbrcmEGL -lbrcmGLESv2
else
LDFLAGS += -lEGL -lGLESv2
endif
OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
OBJS += platform/common/plat_sdl.o
OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
OBJS += platform/libpicofe/plat_dummy.o
OBJS += platform/libpicofe/gl.o
OBJS += platform/libpicofe/gl_platform.o
USE_FRONTEND = 1
endif
ifeq "$(PLATFORM)" "generic"
OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
OBJS += platform/common/plat_sdl.o
OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
OBJS += platform/libpicofe/plat_dummy.o
USE_FRONTEND = 1
endif
ifeq "$(PLATFORM)" "pandora"
platform/common/menu_pico.o: CFLAGS += -DPANDORA
platform/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
OBJS += platform/pandora/plat.o
OBJS += platform/pandora/asm_utils.o
OBJS += platform/common/arm_utils.o
OBJS += platform/libpicofe/linux/in_evdev.o
OBJS += platform/libpicofe/linux/fbdev.o
OBJS += platform/libpicofe/linux/xenv.o
OBJS += platform/libpicofe/pandora/plat.o
USE_FRONTEND = 1
endif
ifeq "$(PLATFORM)" "gp2x"
OBJS += platform/common/arm_utils.o
OBJS += platform/libpicofe/linux/in_evdev.o
OBJS += platform/libpicofe/gp2x/in_gp2x.o
OBJS += platform/libpicofe/gp2x/soc.o
OBJS += platform/libpicofe/gp2x/soc_mmsp2.o
OBJS += platform/libpicofe/gp2x/soc_pollux.o
OBJS += platform/libpicofe/gp2x/plat.o
OBJS += platform/libpicofe/gp2x/pollux_set.o
OBJS += platform/gp2x/940ctl.o
OBJS += platform/gp2x/plat.o
OBJS += platform/gp2x/emu.o
OBJS += platform/gp2x/vid_mmsp2.o
OBJS += platform/gp2x/vid_pollux.o
OBJS += platform/gp2x/warm.o
USE_FRONTEND = 1
PLATFORM_MP3 = 1
PLATFORM_ZLIB = 1
HAVE_ARMv6 = 0
endif
ifeq "$(PLATFORM)" "libretro"
OBJS += platform/libretro/libretro.o
PLATFORM_ZLIB = 1
endif
ifeq "$(USE_FRONTEND)" "1"
# common
OBJS += platform/common/main.o platform/common/emu.o \
platform/common/menu_pico.o platform/common/config_file.o
# libpicofe
OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \
platform/libpicofe/fonts.o platform/libpicofe/linux/plat.o
# libpicofe - sound
OBJS += platform/libpicofe/sndout.o
ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
platform/libpicofe/sndout.o: CFLAGS += -DHAVE_OSS
OBJS += platform/libpicofe/linux/sndout_oss.o
endif
ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
platform/libpicofe/sndout.o: CFLAGS += -DHAVE_ALSA
OBJS += platform/libpicofe/linux/sndout_alsa.o
endif
ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
platform/libpicofe/sndout.o: CFLAGS += -DHAVE_SDL
OBJS += platform/libpicofe/sndout_sdl.o
endif
ifeq "$(ARCH)" "arm"
OBJS += platform/libpicofe/arm_linux.o
endif
endif # USE_FRONTEND
OBJS += platform/common/mp3.o platform/common/mp3_sync.o
ifeq "$(PLATFORM_MP3)" "1"
platform/common/mp3_helix.o: CFLAGS += -Iplatform/libpicofe
OBJS += platform/common/mp3_helix.o
else ifeq "$(HAVE_LIBAVCODEC)" "1"
OBJS += platform/common/mp3_libavcodec.o
else
OBJS += platform/common/mp3_dummy.o
endif
ifeq "$(PLATFORM_ZLIB)" "1"
# zlib
OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o
CFLAGS += -Izlib
endif
# unzip
OBJS += unzip/unzip.o
include platform/common/common.mak
OBJS += $(OBJS_COMMON)
CFLAGS += $(addprefix -D,$(DEFINES))
ifneq ($(findstring gcc,$(CC)),)
LDFLAGS += -Wl,-Map=$(TARGET).map
endif
target_: pico/pico_int_offs.h $(TARGET)
clean:
$(RM) $(TARGET) $(OBJS)
$(RM) -r .opk_data picodrive/picodrive.ipk picodrive/picodrive.opk
$(TARGET): $(OBJS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $^
else
$(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) $(LDLIBS)
endif
pprof: platform/linux/pprof.c
$(CC) $(CFLAGS) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ $(LDFLAGS) $(LDLIBS)
pico/pico_int_offs.h: tools/mkoffsets.sh
make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS)"
.s.o:
$(CC) $(CFLAGS) -c $< -o $@
.S.o:
$(CC) $(CFLAGS) -c $< -o $@
# special flags - perhaps fix this someday instead?
pico/draw.o: CFLAGS += -fno-strict-aliasing
pico/draw2.o: CFLAGS += -fno-strict-aliasing
pico/mode4.o: CFLAGS += -fno-strict-aliasing
pico/cd/memory.o: CFLAGS += -fno-strict-aliasing
pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing
pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing
pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing
pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing
ifeq (1,$(use_sh2drc))
ifneq (,$(findstring -flto,$(CFLAGS)))
# if using the DRC, memory and sh2soc directly use the DRC register for SH2 SR
# to avoid saving and reloading it. However, this collides with the use of LTO.
pico/32x/memory.o: CFLAGS += -fno-lto
pico/32x/sh2soc.o: CFLAGS += -fno-lto
endif
endif
# fame needs ~2GB of RAM to compile on gcc 4.8
# on x86, this is reduced by ~300MB when debug info is off (but not on ARM)
# not using O3 and -fno-expensive-optimizations seems to also help, but you may
# want to remove this stuff for better performance if your compiler can handle it
ifeq "$(DEBUG)" "0"
cpu/fame/famec.o: CFLAGS += -g0 -O2 -fno-expensive-optimizations
endif
pico/carthw_cfg.c: pico/carthw.cfg
tools/make_carthw_c $< $@
# random deps
pico/carthw/svp/compiler.o : cpu/drc/emit_arm.c
cpu/sh2/compiler.o : cpu/drc/emit_arm.c cpu/drc/emit_arm64.c
cpu/sh2/compiler.o : cpu/drc/emit_x86.c cpu/drc/emit_mips.c cpu/drc/emit_riscv.c
cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c
pico/pico.o pico/cd/mcd.o pico/32x/32x.o : pico/pico_cmn.c pico/pico_int.h
pico/memory.o pico/cd/memory.o pico/32x/memory.o : pico/pico_int.h pico/memory.h
# pico/cart.o : pico/carthw_cfg.c
cpu/fame/famec.o: cpu/fame/famec.c cpu/fame/famec_opcodes.h