forked from libretro/mame2000-libretro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.libretro
202 lines (173 loc) · 5.34 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
DEBUG=0
#set later according to platform
IS_X86 = 0
TARGET = mame
# extension for executables
EXE = .so
GCC_DEFINES := -Wno-sign-compare -Wunused -Wpointer-arith -Waggregate-return -Wshadow
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
else ifneq ($(findstring win,$(shell uname -a)),)
platform = win
endif
endif
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
ifeq ($(platform), unix)
EXE = .so
TARGET := libretro
fpic := -fPIC
SHARED := -shared -Wl,--version-script=src/libretro/link.T -Wl,-no-undefined
ENDIANNESS_DEFINES := -DLSB_FIRST
IS_X86 = 1
else ifeq ($(platform), osx)
EXE = .dylib
TARGET := libretro
fpic := -fPIC
SHARED := -dynamiclib
ENDIANNESS_DEFINES := -DLSB_FIRST
IS_X86 = 1
else ifeq ($(platform), ps3)
EXE = .a
TARGET := libretro
CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
ENDIANNESS_DEFINES :=
PLATFORM_DEFINES := -D__CELLOS_LV2__ -D__ppc__
HAVE_RZLIB := 1
else ifeq ($(platform), sncps3)
EXE = .a
TARGET := libretro
CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
CFLAGS += -DWORDS_BIGENDIAN=1
GCC_DEFINES :=
PLATFORM_DEFINES := -D__CELLOS_LV2__ -D__ppc__
HAVE_RZLIB := 1
else ifeq ($(platform), psl1ght)
EXE = .a
TARGET := libretro
CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
CFLAGS += -DWORDS_BIGENDIAN=1
GCC_DEFINES :=
PLATFORM_DEFINES := -D__CELLOS_LV2__ -D__ppc__
HAVE_RZLIB := 1
else ifeq ($(platform), xenon)
EXE = .a
TARGET := libretro
CC = xenon-gcc$(EXE_EXT)
AR = xenon-ar$(EXE_EXT)
CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
PLATFORM_DEFINES := -D__LIBXENON__ -D__ppc_
else ifeq ($(platform), ngc)
EXE = .a
TARGET := libretro
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
PLATFORM_DEFINES += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float
HAVE_RZLIB := 1
else ifeq ($(platform), wii)
EXE = .a
TARGET := libretro
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
PLATFORM_DEFINES += -DGEKKO _DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float
HAVE_RZLIB := 1
else
EXE = .dll
TARGET := retro
CC = gcc
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=src/libretro/link.T
CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ -Wno-missing-field-initializers
ENDIANNESS_DEFINES := -DLSB_FIRST
IS_X86 = 1
endif
ifeq ($(IS_X86), 1)
X86_DEFINES = -Dasm="__asm__ __volatile__"
CFLAGS += $(X86_DEFINES)
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3
endif
# set this the operating system you're building for
# (actually you'll probably need your own main makefile anyways)
# MAMEOS = msdos
MAMEOS = libretro
# CPU core include paths
VPATH=src $(wildcard src/cpu/*)
# compiler, linker and utilities
MD = @mkdir -p
RM = @rm -f
EMULATOR = $(TARGET)$(EXE)
DEFS = -DGP2X -DALIGN_INTS -DALIGN_SHORTS -DINLINE="static __inline" $(X86_DEFINES) -DMAME_UNDERCLOCK -DMAME_FASTSOUND -DENABLE_AUTOFIRE -DBIGCASE -D__LIBRETRO__ $(ENDIANNESS_DEFINES)
LIBS = -lm -lpthread
OBJ = obj_$(TARGET)_$(MAMEOS)
ifeq ($(HAVE_RZLIB),)
ZLIB_INCLUDE := -Isrc/zlib
endif
CFLAGS += -ffast-math $(fpic) $(PLATFORM_DEFINES) -Isrc -Isrc/$(MAMEOS) $(ZLIB_INCLUDE) $(GCC_DEFINES)
OBJDIRS = $(OBJ) $(OBJ)/cpu $(OBJ)/sound $(OBJ)/$(MAMEOS) \
$(OBJ)/drivers $(OBJ)/machine $(OBJ)/vidhrdw $(OBJ)/sndhrdw $(OBJ)/zlib
all: maketree $(EMULATOR)
# include the various .mak files
include src/core.mak
include src/mame.mak
include src/rules.mak
include src/sound.mak
include src/$(MAMEOS)/$(MAMEOS).mak
# combine the various definitions to one
CDEFS = $(DEFS) $(COREDEFS) $(CPUDEFS) $(SOUNDDEFS)
ifeq ($(HAVE_RZLIB),1)
OBJECTS_COMBINED := $(COREOBJS) $(OSOBJS) $(DRVOBJS)
else
OBJECTS_COMBINED := $(ZLIBOBJS) $(COREOBJS) $(OSOBJS) $(DRVOBJS)
endif
$(EMULATOR): $(OBJECTS_COMBINED)
ifeq ($(platform), ps3)
$(AR) rcs $@ $(OBJECTS_COMBINED)
else ifeq ($(platform), sncps3)
$(AR) rcs $@ $(OBJECTS_COMBINED)
else ifeq ($(platform), psl1ght)
$(AR) rcs $@ $(OBJECTS_COMBINED)
else ifeq ($(platform), xenon)
$(AR) rcs $@ $(OBJECTS_COMBINED)
else ifeq ($(platform), ngc)
$(AR) rcs $@ $(OBJECTS_COMBINED)
else ifeq ($(platform), wii)
$(AR) rcs $@ $(OBJECTS_COMBINED)
else
@echo Linking $@...
@$(CC) $(SHARED) $(LDFLAGS) $(LIBS) $(OBJECTS_COMBINED) -o $@
endif
$(OBJ)/%.o: src/%.c
@echo Compiling $<...
@$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
$(OBJ)/%.o: src/%.s
@echo Compiling $<...
@$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
$(OBJ)/%.o: src/%.S
@echo Compiling $<...
@$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
$(sort $(OBJDIRS)):
$(MD) $@
maketree: $(sort $(OBJDIRS))
clean:
$(RM) -r $(OBJ)
$(RM) $(EMULATOR)