-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
295 lines (256 loc) · 8.19 KB
/
Makefile
File metadata and controls
295 lines (256 loc) · 8.19 KB
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
STATIC_LINKING := 0
AR ?= ar
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -s),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -s)),)
platform = osx
arch = intel
ifeq ($(shell uname -p),arm)
arch = arm
endif
else ifneq ($(findstring MINGW,$(shell uname -s)),)
platform = win
endif
endif
# system platform
system_platform = unix
ifeq ($(shell uname -s),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -s)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -s)),)
system_platform = win
endif
TARGET_NAME := amiarcadia
LIBRETRO_DIR := $(CURDIR)
CORE_DIR := DroidArcadia/app/src/main/cpp
LIBRETRO_COMMON_DIR := $(CURDIR)/libretro-common
CC ?= gcc
CXX ?= g++
DEBUG ?= 0
GIT_VERSION ?= $(shell git rev-parse --short HEAD 2>/dev/null)
ifneq ($(GIT_VERSION),)
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
LIBS := -lm
###############################################################################
# Platform detection
###############################################################################
# Unix / Linux
ifneq (,$(findstring unix,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined
# macOS
else ifneq (,$(findstring osx,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
OSXVER := $(shell sw_vers -productVersion | cut -d. -f 1)
OSX_LT_MAVERICKS = $(shell [ $(OSXVER) -lt 10 ] && echo "NO")
ifeq ($(OSX_LT_MAVERICKS), NO)
fpic += -mmacosx-version-min=10.1
endif
ifeq ($(arch),arm)
CFLAGS += -arch arm64
LDFLAGS += -arch arm64
endif
ifeq ($(CROSS_COMPILE),1)
TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
CFLAGS += $(TARGET_RULE)
LDFLAGS += $(TARGET_RULE)
endif
# iOS arm64
else ifeq ($(platform), ios-arm64)
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
CC = clang -arch arm64 -isysroot $(IOSSDK)
CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
CFLAGS += -DIOS -miphoneos-version-min=8.0
LDFLAGS += -arch arm64 -miphoneos-version-min=8.0
# iOS9 (armv7)
else ifeq ($(platform), ios9)
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
CC = clang -arch armv7 -isysroot $(IOSSDK)
CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
CFLAGS += -DIOS -miphoneos-version-min=8.0
LDFLAGS += -arch armv7 -miphoneos-version-min=8.0
# iOS (legacy armv7)
else ifeq ($(platform), ios)
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
CC = clang -arch armv7 -isysroot $(IOSSDK)
CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
CFLAGS += -DIOS
# tvOS
else ifeq ($(platform), tvos-arm64)
TARGET := $(TARGET_NAME)_libretro_tvos.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(TVOSSDK),)
TVOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
endif
CC = clang -arch arm64 -isysroot $(TVOSSDK)
CXX = clang++ -arch arm64 -isysroot $(TVOSSDK)
CFLAGS += -DIOS -mappletvos-version-min=11.0
LDFLAGS += -arch arm64
# Nintendo Switch (libnx)
else ifeq ($(platform), libnx)
include $(DEVKITPRO)/libnx/switch_rules
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CFLAGS += -D__SWITCH__ -DHAVE_LIBNX -I$(LIBNX)/include/ -specs=$(LIBNX)/switch.specs
CFLAGS += -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS += -ffunction-sections -fdata-sections
STATIC_LINKING := 1
# Nintendo WiiU
else ifeq ($(platform), wiiu)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
CFLAGS += -DGEKKO -DWIIU -DHW_RVL -mcpu=750 -meabi -mhard-float
CFLAGS += -ffunction-sections -fdata-sections -D__wiiu__ -D__wut__
CFLAGS += -DMSB_FIRST
STATIC_LINKING := 1
# Nintendo Wii
else ifeq ($(platform), wii)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float
CFLAGS += -DMSB_FIRST
STATIC_LINKING := 1
# Nintendo GameCube
else ifeq ($(platform), ngc)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float
CFLAGS += -DMSB_FIRST
STATIC_LINKING := 1
# Nintendo 3DS
else ifeq ($(platform), ctr)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
CFLAGS += -DARM11 -D_3DS
CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS += -mword-relocations -ffast-math
STATIC_LINKING := 1
# PlayStation Vita
else ifeq ($(platform), vita)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = arm-vita-eabi-gcc
AR = arm-vita-eabi-ar
CFLAGS += -O3
STATIC_LINKING := 1
# PlayStation Portable
else ifeq ($(platform), psp1)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = psp-gcc
AR = psp-ar
CFLAGS += -G0
STATIC_LINKING := 1
# PlayStation 2
else ifeq ($(platform), ps2)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = mips64r5900el-ps2-elf-gcc
AR = mips64r5900el-ps2-elf-ar
CFLAGS += -G0 -DPS2
STATIC_LINKING := 1
# GCW0 / OpenDingux (MIPS)
else ifeq ($(platform), gcw0)
TARGET := $(TARGET_NAME)_libretro.so
CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined
CFLAGS += -march=mips32 -mtune=mips32r2 -mhard-float
# RetroFW (MIPS)
else ifeq ($(platform), retrofw)
TARGET := $(TARGET_NAME)_libretro.so
CC = /opt/retrofw-toolchain/usr/bin/mipsel-linux-gcc
AR = /opt/retrofw-toolchain/usr/bin/mipsel-linux-ar
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined
CFLAGS += -march=mips32 -mtune=mips32 -mhard-float
# Miyoo (ARM)
else ifeq ($(platform), miyoo)
TARGET := $(TARGET_NAME)_libretro.so
CC = /opt/miyoo/usr/bin/arm-linux-gcc
AR = /opt/miyoo/usr/bin/arm-linux-ar
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined
CFLAGS += -mcpu=arm926ej-s -ffast-math
# Windows (MinGW)
else ifneq (,$(findstring win,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dll
SHARED := -shared -static-libgcc -static-libstdc++ -Wl,--no-undefined
LDFLAGS += -lws2_32
LIBS :=
# Default fallback (unix-like)
else
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined
endif
###############################################################################
# Compiler flags
###############################################################################
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g -DDEBUG
else
CFLAGS += -O2 -DNDEBUG
endif
CFLAGS += -DLIBRETRO
CFLAGS += -I$(LIBRETRO_COMMON_DIR)/include
CFLAGS += -I$(CORE_DIR)
CFLAGS += $(fpic)
CFLAGS += -Wall
LDFLAGS += $(fpic) $(LIBS)
###############################################################################
# Sources
###############################################################################
SOURCES := \
src/libretro.c \
$(CORE_DIR)/android.c \
$(CORE_DIR)/2650.c \
$(CORE_DIR)/arcadia.c \
$(CORE_DIR)/coin-ops.c \
$(CORE_DIR)/elektor.c \
$(CORE_DIR)/formats.c \
$(CORE_DIR)/interton.c \
$(CORE_DIR)/malzak.c \
$(CORE_DIR)/pvi.c \
$(CORE_DIR)/zaccaria.c
OBJECTS := $(SOURCES:.c=.o)
###############################################################################
# Targets
###############################################################################
all: $(TARGET)
$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJECTS)
else
$(CC) -o $@ $(SHARED) $(OBJECTS) $(LDFLAGS)
endif
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f $(OBJECTS) $(TARGET)
.PHONY: all clean