-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile.libretro
258 lines (218 loc) · 7.52 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
PLATFLAGS :=
ifeq ($(platform),)
platform = unix
endif
TARGET_NAME := uae4arm
CORE_DIR := .
ROOT_DIR := .
# Default (ARM) unix
ifneq (,$(findstring unix,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
LDFLAGS := -lz -lpthread -lFLAC -lmpg123 -ldl
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T
ifneq (,$(findstring neon,$(platform)))
# Uncomment below for compilation on rpi
#CPU_FLAGS += -mfpu=neon -march=armv7-a
CFLAGS += $(PLATFORM_DEFINES)
MORE_CFLAGS += -DARMV6T2 -DARM_HAS_DIV
HAVE_NEON = 1
USE_PICASSO96 = 1
CPU_FLAGS += -marm
endif
ifneq (,$(findstring aarch64,$(platform)))
AARCH64 = 1
MORE_CFLAGS += -DCPU_AARCH64
endif
else ifneq (,$(findstring rpi4,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic = -fPIC
SHARED :=-shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
CPU_FLAGS += -mcpu=cortex-a72 -D__arm__
ifneq (,$(findstring aarch64,$(platform)))
AARCH64 = 1
MORE_CFLAGS += -DCPU_AARCH64
else
CPU_FLAGS += -marm -mfpu=neon-fp-armv8 -mfloat-abi=hard
MORE_CFLAGS += -DARMV6T2 -DARM_HAS_DIV
HAVE_NEON = 1
USE_PICASSO96 = 1
endif
CFLAGS += -DFASTCOPPER_OFF $(PLATFORM_DEFINES)
CXXFLAGS += $(PLATFORM_DEFINES)
CC = gcc
CXX = g++
LDFLAGS += -lz -lpthread -lFLAC -lmpg123 -ldl
else ifneq (,$(findstring rpi3,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic = -fPIC
SHARED :=-shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
CPU_FLAGS += -mcpu=cortex-a53 -D__arm__
ifneq (,$(findstring aarch64,$(platform)))
AARCH64 = 1
MORE_CFLAGS += -DCPU_AARCH64
else
CPU_FLAGS += -marm -mfpu=neon-fp-armv8 -mfloat-abi=hard
MORE_CFLAGS += -DARMV6T2 -DARM_HAS_DIV
HAVE_NEON = 1
USE_PICASSO96 = 1
endif
CFLAGS += $(PLATFORM_DEFINES)
CXXFLAGS += $(PLATFORM_DEFINES)
CC = gcc
CXX = g++
LDFLAGS += -lz -lpthread -lFLAC -lmpg123 -ldl
else ifeq ($(platform), rpi2)
TARGET := $(TARGET_NAME)_libretro.so
fpic = -fPIC
SHARED :=-shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
CPU_FLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -D__arm__
MORE_CFLAGS += -DARMV6T2 -DARM_HAS_DIV
HAVE_NEON = 1
USE_PICASSO96 = 1
CFLAGS += $(PLATFORM_DEFINES)
CXXFLAGS += $(PLATFORM_DEFINES)
CC = gcc
CXX = g++
LDFLAGS += -lz -lpthread -lFLAC -lmpg123 -ldl
# use for raspberry pi
else ifeq ($(platform), rpi1)
TARGET := $(TARGET_NAME)_libretro.so
CPU_FLAGS += -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard
fpic := -fPIC
LDFLAGS := -lz -lpthread
PLATFLAGS += -DARM -marm
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T
else ifeq ($(platform), crosspi)
TARGET := $(TARGET_NAME)_libretro.so
fpic = -fPIC
SHARED :=-shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined -L ../usr/lib -static-libstdc++ -static-libgcc
CPU_FLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -D__arm__
MORE_CFLAGS += -DARMV6T2 -DARM_HAS_DIV
PLATFORM_DEFINES += -I ../usr/include
HAVE_NEON = 1
USE_PICASSO96 = 1
CFLAGS += $(PLATFORM_DEFINES)
CXXFLAGS += $(PLATFORM_DEFINES)
CC = arm-linux-gnueabihf-gcc
CXX = arm-linux-gnueabihf-g++
LDFLAGS += -lz -lpthread
# Classic Platforms ####################
# Platform affix = classic_<ISA>_<µARCH>
# Help at https://modmyclassic.com/comp
# (armv7 a7, hard point, neon based) ###
# NESC, SNESC, C64 mini
else ifeq ($(platform), classic_armv7_a7)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED :=-shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
MORE_CFLAGS += -DARMV6T2 -DARM_HAS_DIV
HAVE_NEON = 1
USE_PICASSO96 = 1
CPU_FLAGS += -DARM -Ofast \
-flto=4 -fwhole-program -fuse-linker-plugin \
-fdata-sections -ffunction-sections -Wl,--gc-sections \
-fno-stack-protector -fno-ident -fomit-frame-pointer \
-falign-functions=1 -falign-jumps=1 -falign-loops=1 \
-fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
-fmerge-all-constants -fno-math-errno \
-marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
CXXFLAGS += $(CPU_FLAGS)
CPPFLAGS += $(CPU_FLAGS)
ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
CFLAGS += -march=armv7-a
else
CFLAGS += -march=armv7ve
# If gcc is 5.0 or later
ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
LDFLAGS += -static-libgcc -static-libstdc++
endif
endif
# (armv8 a35, hard point, neon based) ###
# PS Classic
else ifeq ($(platform), classic_armv8_a35)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED :=-shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
MORE_CFLAGS += -DARMV6T2 -DARM_HAS_DIV
HAVE_NEON = 1
USE_PICASSO96 = 1
CPU_FLAGS += -DARM -Ofast \
-flto=4 -fwhole-program -fuse-linker-plugin \
-fdata-sections -ffunction-sections -Wl,--gc-sections \
-fno-stack-protector -fno-ident -fomit-frame-pointer \
-falign-functions=1 -falign-jumps=1 -falign-loops=1 \
-fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
-fmerge-all-constants -fno-math-errno \
-marm -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
CXXFLAGS += $(CPU_FLAGS)
CPPFLAGS += $(CPU_FLAGS)
ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
CFLAGS += -march=armv8-a
else
CFLAGS += -march=armv8-a
# If gcc is 5.0 or later
ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
LDFLAGS += -static-libgcc -static-libstdc++
endif
endif
else ifeq ($(platform), android)
CC = arm-linux-androideabi-gcc
CXX =arm-linux-androideabi-g++
AR = @arm-linux-androideabi-ar
LD = @arm-linux-androideabi-g++
TARGET := $(TARGET_NAME)_libretro_android.so
fpic := -fPIC
LDFLAGS := -lz -lm -llog
SHARED := -Wl,--fix-cortex-a8 -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
PLATFLAGS += -DANDROID -DRETRO -DAND -DANDPORT -DARM_OPT_TEST=1
endif
GIT_VERSION := $(shell git rev-parse --short HEAD 2>/dev/null)
ifneq ($(GIT_VERSION),)
MORE_CFLAGS += -DGIT_VERSION=$(GIT_VERSION)
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g -DWITH_LOGGING
else
CFLAGS += -O3 -fomit-frame-pointer -finline
endif
ifneq ($(AARCH64), 1)
DEFS += -DARMV6_ASSEMBLY
endif
DEFS += -DPANDORA -DRASPBERRY -DWITH_INGAME_WARNING
ifeq ($(USE_PICASSO96), 1)
DEFS += -DPICASSO96
endif
ifeq ($(HAVE_NEON), 1)
DEFS += -DUSE_ARMNEON
endif
DEFINES += -D__LIBRETRO__ $(DEFS) $(MORE_CFLAGS)
#-std=gnu99
CFLAGS += $(DEFINES) -DINLINE="inline" $(CPU_FLAGS) -fexceptions -fpermissive
include Makefile.common
OBJECTS += $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o) $(SOURCES_ASM:.S=.o)
INCDIRS := $(EXTRA_INCLUDES) $(INCFLAGS)
OBJECTS += $(OBJS)
ASFLAGS += $(CPU_FLAGS)
all: $(TARGET)
CAPS = capsimg.so
capsimg.so: capsimg
(cd capsimg ; ./bootstrap ; ./configure --host=arm ; $(MAKE) ; cp capsimg.so ../ )
$(TARGET): $(OBJECTS) $(CAPS)
$(CXX) $(fpic) $(SHARED) $(INCDIRS) -o $@ $(OBJECTS) $(LDFLAGS)
$(EMU)/od-pandora/neon_helper.o: $(EMU)/od-pandora/neon_helper.s
$(CXX) $(ASFLAGS) -Wall -o $(EMU)/od-pandora/neon_helper.o -c $(EMU)/od-pandora/neon_helper.s
$(EMU)/od-pandora/arm_helper.o: $(EMU)/od-pandora/arm_helper.s
$(CXX) $(ASFLAGS) -Wall -o $(EMU)/od-pandora/arm_helper.o -c $(EMU)/od-pandora/arm_helper.s
$(EMU)/od-pandora/aarch64_helper.o: $(EMU)/od-pandora/aarch64_helper.s
$(CXX) $(ASFLAGS) -Wall -o $(EMU)/od-pandora/aarch64_helper.o -c $(EMU)/od-pandora/aarch64_helper.s
%.o: %.cpp
$(CXX) $(fpic) $(CFLAGS) $(PLATFLAGS) $(INCDIRS) -c -o $@ $<
%.o: %.c
$(CC) $(fpic) $(CFLAGS) $(PLATFLAGS) $(INCDIRS) -c -o $@ $<
%.o: %.S
$(CC_AS) $(CFLAGS) $(PLATFLAGS) -c $^ -o $@
clean:
rm -f $(OBJECTS) $(TARGET)
(cd capsimg ; make clean )
.PHONY: clean