forked from barry65536/FBAlpha
-
Notifications
You must be signed in to change notification settings - Fork 5
/
makefile.libretro
391 lines (353 loc) · 12.1 KB
/
makefile.libretro
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
DEBUG = 0
LIBRETRO_OPTIMIZATIONS = 1
FRONTEND_SUPPORTS_RGB565 = 1
HAVE_GRIFFIN = 0
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
endif
endif
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
system_platform = win
EXE_EXT=.exe
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
MAIN_FBA_DIR := src
FBA_BURN_DIR := $(MAIN_FBA_DIR)/burn
FBA_BURN_DRIVERS_DIR := $(MAIN_FBA_DIR)/burn/drv
FBA_BURNER_DIR := $(MAIN_FBA_DIR)/burner
LIBRETRO_DIR := $(FBA_BURNER_DIR)/libretro
FBA_CPU_DIR := $(MAIN_FBA_DIR)/cpu
FBA_LIB_DIR := $(MAIN_FBA_DIR)/dep/libs
FBA_INTERFACE_DIR := $(MAIN_FBA_DIR)/intf
FBA_GENERATED_DIR = $(MAIN_FBA_DIR)/dep/generated
FBA_SCRIPTS_DIR = $(MAIN_FBA_DIR)/dep/scripts
GRIFFIN_DIR = griffin-libretro
EXTERNAL_ZLIB = 0
ifeq ($(platform), unix)
TARGET := libretro.so
fpic := -fPIC
SHARED := -shared -Wl,-no-undefined -Wl,--version-script=$(LIBRETRO_DIR)/link.T
ENDIANNESS_DEFINES := -DLSB_FIRST
else ifeq ($(platform), osx)
TARGET := libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
ENDIANNESS_DEFINES := -DLSB_FIRST
else ifeq ($(platform), ps3)
TARGET := libretro_ps3.a
CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe
AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES += -D__CELLOS_LV2__
EXTERNAL_ZLIB = 1
else ifeq ($(platform), sncps3)
TARGET := libretro_ps3.a
CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES += -D__CELLOS_LV2__ -DSN_TARGET_PS3
EXTERNAL_ZLIB = 1
else ifeq ($(platform), psl1ght)
TARGET := libretro_psl1ght.a
CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
CXX = $(PS3DEV)/ppu/bin/ppu-g++$(EXE_EXT)
AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES += -D__CELLOS_LV2__
EXTERNAL_ZLIB = 1
else ifeq ($(platform), xenon)
TARGET := libretro_xenon360.a
CC = xenon-gcc$(EXE_EXT)
CXX = xenon-g++$(EXE_EXT)
AR = xenon-ar$(EXE_EXT)
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES := -D__LIBXENON__ -m32 -D__ppc__
else ifeq ($(platform), ngc)
TARGET := libretro_ngc.a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES := -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float
EXTERNAL_ZLIB = 1
else ifeq ($(platform), wii)
TARGET := libretro_wii.a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES := -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float
EXTERNAL_ZLIB = 1
else
TARGET := retro.dll
CC = gcc
CXX = g++
SHARED := -shared -Wl,-no-undefined -Wl,--version-script=$(LIBRETRO_DIR)/link.T
LDFLAGS += -static-libgcc -static-libstdc++
ENDIANNESS_DEFINES := -DLSB_FIRST
endif
CC_SYSTEM = gcc
CXX_SYSTEM = g++
.PHONY: clean generate-files generate-files-clean clean-objs
all: $(TARGET)
BURN_BLACKLIST := $(FBA_BURNER_DIR)/un7z.cpp \
$(FBA_CPU_DIR)/arm7/arm7exec.c \
$(FBA_CPU_DIR)/arm7/arm7core.c \
$(FBA_CPU_DIR)/hd6309/6309tbl.c \
$(FBA_CPU_DIR)/hd6309/6309ops.c \
$(FBA_CPU_DIR)/konami/konamtbl.c \
$(FBA_CPU_DIR)/konami/konamops.c \
$(FBA_CPU_DIR)/m68k/m68k_in.c \
$(FBA_CPU_DIR)/m6800/6800ops.c \
$(FBA_CPU_DIR)/m6800/6800tbl.c \
$(FBA_CPU_DIR)/m6805/6805ops.c \
$(FBA_CPU_DIR)/m6809/6809ops.c \
$(FBA_CPU_DIR)/m6809/6809tbl.c \
$(FBA_CPU_DIR)/sh2/mksh2.cpp \
$(FBA_CPU_DIR)/sh2/mksh2-x86.cpp \
$(FBA_CPU_DIR)/m68k/m68kmake.c \
$(FBA_BURNER_DIR)/wave_writer.cpp \
$(FBA_CPU_DIR)/m68k/m68kdasm.c \
$(FBA_LIBRETRO_DIR)/menu.cpp \
$(FBA_CPU_DIR)/sh2/mksh2.cpp \
$(FBA_BURNER_DIR)/sshot.cpp \
$(FBA_BURNER_DIR)/conc.cpp \
$(FBA_BURNER_DIR)/dat.cpp \
$(FBA_BURNER_DIR)/cong.cpp \
$(FBA_BURNER_DIR)/image.cpp \
$(FBA_BURNER_DIR)/misc.cpp \
$(FBA_CPU_DIR)/h6280/tblh6280.c \
$(FBA_CPU_DIR)/m6502/t65sc02.c \
$(FBA_CPU_DIR)/m6502/t65c02.c \
$(FBA_CPU_DIR)/m6502/tdeco16.c \
$(FBA_CPU_DIR)/m6502/tn2a03.c \
$(FBA_CPU_DIR)/m6502/t6502.c \
$(FBA_CPU_DIR)/nec/v25sfr.c \
$(FBA_CPU_DIR)/nec/v25instr.c \
$(FBA_CPU_DIR)/nec/necinstr.c \
$(FBA_BURN_DIR)/drv/capcom/ctv_make.cpp
#ifeq ($(LIBRETRO_OPTIMIZATIONS), 1)
#BURN_BLACKLIST += $(FBA_BURN_DIR)/drv/capcom/ctv.cpp
#endif
ifeq ($(EXTERNAL_ZLIB), 1)
BURN_BLACKLIST += $(FBA_BURNER_DIR)/unzip.c \
$(FBA_BURNER_DIR)/ioapi.c
endif
ifeq ($(HAVE_GRIFFIN), 1)
GRIFFIN_CXXSRCFILES := $(GRIFFIN_DIR)/cps12.cpp $(GRIFFIN_DIR)/cps3.cpp $(GRIFFIN_DIR)/neogeo.cpp $(GRIFFIN_DIR)/pgm.cpp $(GRIFFIN_DIR)/snes.cpp $(GRIFFIN_DIR)/galaxian.cpp $(GRIFFIN_DIR)/cpu-m68k.cpp
BURN_BLACKLIST += $(FBA_CPU_DIR)/m68000_intf.cpp
else
CPS2_DIR := $(FBA_BURN_DRIVERS_DIR)/capcom
CPS3_DIR := $(FBA_BURN_DRIVERS_DIR)/cps3
GALAXIAN_DIR := $(FBA_BURN_DRIVERS_DIR)/galaxian
NEOGEO_DIR := $(FBA_BURN_DRIVERS_DIR)/neogeo
PGM_DIR := $(FBA_BURN_DRIVERS_DIR)/pgm
SNES_DIR := $(FBA_BURN_DRIVERS_DIR)/snes
M68K_DIR := $(FBA_CPU_DIR)/m68k
endif
FBA_BURN_DIRS := $(FBA_BURN_DIR) \
$(FBA_BURN_DIR)/devices \
$(FBA_BURN_DIR)/snd \
$(CPS2_DIR) \
$(FBA_BURN_DRIVERS_DIR)/cave \
$(CPS3_DIR) \
$(FBA_BURN_DRIVERS_DIR)/dataeast \
$(GALAXIAN_DIR) \
$(FBA_BURN_DRIVERS_DIR)/irem \
$(FBA_BURN_DRIVERS_DIR)/konami \
$(FBA_BURN_DRIVERS_DIR)/megadrive \
$(NEOGEO_DIR) \
$(FBA_BURN_DRIVERS_DIR)/pce \
$(PGM_DIR) \
$(FBA_BURN_DRIVERS_DIR)/pre90s \
$(FBA_BURN_DRIVERS_DIR)/psikyo \
$(FBA_BURN_DRIVERS_DIR)/pst90s \
$(FBA_BURN_DRIVERS_DIR)/sega \
$(SNES_DIR) \
$(FBA_BURN_DRIVERS_DIR)/taito \
$(FBA_BURN_DRIVERS_DIR)/toaplan
FBA_CPU_DIRS := $(FBA_CPU_DIR) \
$(FBA_CPU_DIR)/arm \
$(FBA_CPU_DIR)/arm7 \
$(FBA_CPU_DIR)/h6280 \
$(FBA_CPU_DIR)/hd6309 \
$(FBA_CPU_DIR)/i8039 \
$(FBA_CPU_DIR)/konami \
$(M68K_DIR) \
$(FBA_CPU_DIR)/m6502 \
$(FBA_CPU_DIR)/m6800 \
$(FBA_CPU_DIR)/m6805 \
$(FBA_CPU_DIR)/m6809 \
$(FBA_CPU_DIR)/nec \
$(FBA_CPU_DIR)/s2650 \
$(FBA_CPU_DIR)/sh2 \
$(FBA_CPU_DIR)/z80
FBA_LIB_DIRS := $(FBA_LIB_DIR)/zlib
FBA_SRC_DIRS := $(FBA_BURNER_DIR) $(FBA_BURN_DIRS) $(FBA_CPU_DIRS) $(FBA_BURNER_DIRS)
ifeq ($(EXTERNAL_ZLIB), 1)
FBA_DEFINES += -DEXTERNAL_ZLIB
else
FBA_SRC_DIRS += $(FBA_LIB_DIRS)
endif
FBA_CXXSRCS := $(GRIFFIN_CXXSRCFILES) $(filter-out $(BURN_BLACKLIST),$(foreach dir,$(FBA_SRC_DIRS),$(wildcard $(dir)/*.cpp)))
FBA_CXXSRCS += $(LIBRETRO_DIR)/libretro.cpp $(LIBRETRO_DIR)/neocdlist.cpp
FBA_CXXOBJ := $(FBA_CXXSRCS:.cpp=.o)
FBA_CSRCS := $(filter-out $(BURN_BLACKLIST),$(foreach dir,$(FBA_SRC_DIRS),$(wildcard $(dir)/*.c)))
FBA_COBJ := $(FBA_CSRCS:.c=.o)
OBJS := $(FBA_COBJ) $(FBA_CXXOBJ)
FBA_DEFINES := -DUSE_SPEEDHACKS -D__LIBRETRO__ \
-D__LIBRETRO_OPTIMIZATIONS__ \
$(ENDIANNESS_DEFINES) \
$(PLATFORM_DEFINES) \
-DINLINE="static inline" \
-DSH2_INLINE="static inline"
INCDIRS := -I$(FBA_BURNER_DIR)/win32 \
-I$(LIBRETRO_DIR) \
-I$(LIBRETRO_DIR)/tchar \
-I$(FBA_BURN_DIR) \
-I$(MAIN_FBA_DIR)/cpu \
-I$(FBA_BURN_DIR)/snd \
-I$(FBA_BURN_DIR)/devices \
-I$(FBA_INTERFACE_DIR) \
-I$(FBA_INTERFACE_DIR)/input \
-I$(FBA_INTERFACE_DIR)/cd \
-I$(FBA_BURNER_DIR) \
-I$(FBA_CPU_DIR) \
-I$(FBA_CPU_DIR)/i8039 \
-I$(FBA_LIB_DIR)/zlib \
-I$(FBA_BURN_DIR)/drv/capcom \
-I$(FBA_BURN_DIR)/drv/dataeast \
-I$(FBA_BURN_DIR)/drv/cave \
-I$(FBA_BURN_DIR)/drv/neogeo \
-I$(FBA_BURN_DIR)/drv/psikyo \
-I$(FBA_BURN_DIR)/drv/sega \
-I$(FBA_BURN_DIR)/drv/toaplan \
-I$(FBA_BURN_DIR)/drv/taito \
-I$(FBA_GENERATED_DIR) \
-I$(FBA_LIB_DIR)
ifeq ($(LIBRETRO_OPTIMIZATIONS), 1)
FBA_DEFINES += -D__LIBRETRO_OPTIMIZATIONS__
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
CXXFLAGS += -O0 -g
else
CFLAGS += -O3 -DNDEBUG
CXXFLAGS += -O3 -DNDEBUG
endif
ifeq ($(platform), sncps3)
WARNINGS_DEFINES =
else
WARNINGS_DEFINES = -Wno-write-strings
C_STD_DEFINES = -std=gnu99
endif
CFLAGS += $(C_STD_DEFINES) $(fpic) $(WARNINGS_DEFINES) $(FBA_DEFINES)
CXXFLAGS += $(fpic) $(WARNINGS_DEFINES) $(FBA_DEFINES)
LDFLAGS += $(fpic)
ifeq ($(FRONTEND_SUPPORTS_RGB565), 1)
CFLAGS += -DFRONTEND_SUPPORTS_RGB565
CXXFLAGS += -DFRONTEND_SUPPORTS_RGB565
endif
ifeq ($(ZLIB_INTERNAL), 0)
INCDIRS += -I$(FBA_LIB_DIR)
endif
ifeq ($(LIBRETRO_OPTIMIZATIONS), 1)
GENERATE_OPTS := -D__LIBRETRO_OPTIMIZATIONS__
else
GENERATE_OPTS :=
endif
PERL = perl$(EXE_EXT)
M68KMAKE_EXE = m68kmake$(EXE_EXT)
CTVMAKE_EXE = ctvmake$(EXE_EXT)
PGM_SPRITE_CREATE_EXE = pgmspritecreate$(EXE_EXT)
EXE_PREFIX = ./
generate-files-clean:
rm -rf $(FBA_GENERATED_DIR)/
rm -rf $(FBA_CPU_DIR)/m68k/m68kopac.c
rm -rf $(FBA_CPU_DIR)/m68k/m68kopdm.c
rm -rf $(FBA_CPU_DIR)/m68k/m68kopnz.c
rm -rf $(FBA_CPU_DIR)/m68k/m68kops.c
rm -rf $(FBA_CPU_DIR)/m68k/m68kops.h
generate-files:
@mkdir -p $(FBA_GENERATED_DIR) 2>/dev/null || /bin/true
@echo "Generating $(FBA_GENERATED_DIR)/driverlist.h..."
@echo ""
$(PERL) $(FBA_SCRIPTS_DIR)/gamelist.pl -o $(FBA_GENERATED_DIR)/driverlist.h -l gamelist.txt $(FBA_BURN_DRIVERS_DIR)/capcom $(FBA_BURN_DRIVERS_DIR)/cave $(FBA_BURN_DRIVERS_DIR)/cps3 $(FBA_BURN_DRIVERS_DIR)/dataeast $(FBA_BURN_DRIVERS_DIR)/galaxian $(FBA_BURN_DRIVERS_DIR)/irem $(FBA_BURN_DRIVERS_DIR)/konami $(FBA_BURN_DRIVERS_DIR)/megadrive $(FBA_BURN_DRIVERS_DIR)/neogeo $(FBA_BURN_DRIVERS_DIR)/pce $(FBA_BURN_DRIVERS_DIR)/pgm $(FBA_BURN_DRIVERS_DIR)/pre90s $(FBA_BURN_DRIVERS_DIR)/psikyo $(FBA_BURN_DRIVERS_DIR)/pst90s $(FBA_BURN_DRIVERS_DIR)/sega $(FBA_BURN_DRIVERS_DIR)/snes $(FBA_BURN_DRIVERS_DIR)/taito $(FBA_BURN_DRIVERS_DIR)/toaplan
@echo ""
@echo "Generating $(FBA_GENERATED_DIR)/neo_sprite_func.h..."
@echo ""
@echo "Generating $(FBA_GENERATED_DIR)/neo_sprite_func_table.h..."
@echo ""
$(PERL) $(FBA_SCRIPTS_DIR)/neo_sprite_func.pl -o $(FBA_GENERATED_DIR)/neo_sprite_func.h $(LIBRETRO_OPTIMIZATIONS)
@echo ""
@echo "Generating $(FBA_GENERATED_DIR)/psikyo_tile_func.h..."
@echo ""
@echo "Generating $(FBA_GENERATED_DIR)/psikyo_tile_func_table.h..."
@echo ""
$(PERL) $(FBA_SCRIPTS_DIR)/psikyo_tile_func.pl -o $(FBA_GENERATED_DIR)/psikyo_tile_func.h
@echo "Generating $(FBA_GENERATED_DIR)/cave_sprite_func.h..."
@echo ""
@echo "Generating[ $(FBA_GENERATED_DIR)/cave_tile_func_table.h"
@echo ""
$(PERL) $(FBA_SCRIPTS_DIR)/cave_sprite_func.pl -o $(FBA_GENERATED_DIR)/cave_sprite_func.h
$(PERL) $(FBA_SCRIPTS_DIR)/cave_tile_func.pl -o $(FBA_GENERATED_DIR)/cave_tile_func.h
@echo ""
@echo "Generate $(FBA_GENERATED_DIR)/toa_gp9001_func_table.h"
@echo ""
$(PERL) $(FBA_SCRIPTS_DIR)/toa_gp9001_func.pl -o $(FBA_GENERATED_DIR)/toa_gp9001_func.h
$(CXX_SYSTEM) $(GENERATE_OPTS) -o $(PGM_SPRITE_CREATE_EXE) $(FBA_BURN_DRIVERS_DIR)/pgm/pgm_sprite_create.cpp
@echo ""
@echo "Generating $(FBA_GENERATED_DIR)/pgm_sprite.h..."
@echo ""
$(EXE_PREFIX)$(PGM_SPRITE_CREATE_EXE) > $(FBA_GENERATED_DIR)/pgm_sprite.h
$(CC_SYSTEM) $(GENERATE_OPTS) -o $(M68KMAKE_EXE) $(FBA_CPU_DIR)/m68k/m68kmake.c
$(EXE_PREFIX)$(M68KMAKE_EXE) $(FBA_CPU_DIR)/m68k/ $(FBA_CPU_DIR)/m68k/m68k_in.c
$(CXX_SYSTEM) $(GENERATE_OPTS) -o $(CTVMAKE_EXE) $(FBA_BURN_DRIVERS_DIR)/capcom/ctv_make.cpp
@echo ""
@echo "Generating $(FBA_GENERATED_DIR)/ctv.h..."
@echo ""
$(EXE_PREFIX)$(CTVMAKE_EXE) > $(FBA_GENERATED_DIR)/ctv.h
$(TARGET): $(OBJS)
@echo "LD $@"
ifeq ($(platform), ps3)
@$(AR) rcs $@ $(OBJS)
else ifeq ($(platform), sncps3)
$(AR) rcs $@ $(OBJS)
else ifeq ($(platform), psl1ght)
$(AR) rcs $@ $(OBJS)
else ifeq ($(platform), xenon)
@$(AR) rcs $@ $(OBJS)
else ifeq ($(platform), ngc)
@$(AR) rcs $@ $(OBJS)
else ifeq ($(platform), wii)
@$(AR) rcs $@ $(OBJS)
else
@$(CXX) -o $@ $(SHARED) $(OBJS) $(LDFLAGS)
endif
%.o: %.cpp
@echo "CXX $<"
@$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
%.o: %.c
@echo "CC $<"
@$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
clean-objs:
rm -f $(OBJS)
clean:
rm -f $(TARGET)
rm -f $(OBJS)
rm -f $(M68KMAKE_EXE)
rm -f $(PGM_SPRITE_CREATE_EXE)
rm -f $(CTVMAKE_EXE)