-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
271 lines (238 loc) · 7.32 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
#DEBUG=1
ifneq ($(SANITIZER),)
CFLAGS := -fsanitize=$(SANITIZER) $(CFLAGS)
CXXFLAGS := -fsanitize=$(SANITIZER) $(CXXFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
endif
GIT_VERSION ?= " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown")
CXXFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
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
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
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
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
TARGET_NAME = daphne
CORE_DIR := .
ifeq ($(platform), unix)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
LIBS += -lpthread -ldl
else ifneq (,$(findstring osx,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
CXXFLAGS += -DOSX
CFLAGS += -DOSX
ifeq ($(arch),ppc)
CXXFLAGS += -D__ppc__ -DOSX_PPC
CFLAGS += -D__ppc__ -DOSX_PPC
endif
OSXVER = `sw_vers -productVersion | cut -d. -f 2`
OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
fpic += -mmacosx-version-min=10.1
else ifeq ($(platform), pi)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
CXXFLAGS += -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/vmcs_host/linux
CFLAGS += -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/vmcs_host/linux
LIBS += -L/opt/vc/lib -lpthread -ldl -lbcm_host -lvchostif
else ifneq (,$(findstring ios,$(platform)))
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
DEFINES := -DIOS -Wno-error=implicit-function-declaration
CXXFLAGS += $(DEFINES) -stdlib=libc++
CFLAGS += $(DEFINES)
CC = cc -arch armv7 -isysroot $(IOSSDK)
CXX = c++ -arch armv7 -isysroot $(IOSSDK)
ifeq ($(platform),ios9)
CC += -miphoneos-version-min=8.0
CXXFLAGS += -miphoneos-version-min=8.0
CFLAGS += -miphoneos-version-min=8.0
else
CC += -miphoneos-version-min=5.0
CXXFLAGS += -miphoneos-version-min=5.0
CFLAGS += -miphoneos-version-min=5.0
endif
else ifeq ($(platform), tvos-arm64)
TARGET := $(TARGET_NAME)_libretro_tvos.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
endif
DEFINES := -DIOS -Wno-error=implicit-function-declaration
CXXFLAGS += $(DEFINES) -stdlib=libc++
CFLAGS += $(DEFINES)
else ifneq (,$(findstring qnx,$(platform)))
TARGET := $(TARGET_NAME)_libretro_qnx.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T
CC = qcc -Vgcc_ntoarmv7le
AR = qcc -Vgcc_ntoarmv7le
else ifneq (,$(findstring armv,$(platform)))
CC ?= gcc
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
CXXFLAGS += -I.
CFLAGS += -I.
ifneq (,$(findstring cortexa8,$(platform)))
CXXFLAGS += -marm -mcpu=cortex-a8
CFLAGS += -marm -mcpu=cortex-a8
else ifneq (,$(findstring cortexa9,$(platform)))
CXXFLAGS += -marm -mcpu=cortex-a9
CFLAGS += -marm -mcpu=cortex-a9
endif
CXXFLAGS += -marm
CFLAGS += -marm
ifneq (,$(findstring neon,$(platform)))
CXXFLAGS += -mfpu=neon
CFLAGS += -mfpu=neon
endif
ifneq (,$(findstring softfloat,$(platform)))
CXXFLAGS += -mfloat-abi=softfp
CFLAGS += -mfloat-abi=softfp
else ifneq (,$(findstring hardfloat,$(platform)))
CXXFLAGS += -mfloat-abi=hard
CFLAGS += -mfloat-abi=hard
endif
CXXFLAGS += -DARM
CFLAGS += -DARM
LIBS += -lpthread -ldl
# Classic Platforms ####################
# Platform affix = classic_<ISA>_<µARCH>
# Help at https://modmyclassic.com/comp
# (armv7 a7, hard point, neon based) ###
# NESC, SNESC, C64 mini
ifneq (,$(findstring classic_armv7_a7, $(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC -pthread
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
CFLAGS += -I. -DARM
CFLAGS += -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 += $(CFLAGS)
LDFLAGS += -lpthread
HAVE_NEON = 1
ARCH = arm
LIBS += -lpthread -ldl
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
endif
# (armv8 a35, hard point, neon based) ###
# Playstation Classic
ifneq (,$(findstring classic_armv8_a35, $(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
LIBS += -lpthread -ldl
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined -lrt
CFLAGS += -Ofast -I. -DARM \
-flto -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 += $(CFLAGS)
HAVE_NEON = 1
ARCH = arm
CFLAGS += -march=armv8-a
LDFLAGS += -static-libgcc -static-libstdc++
endif
#######################################
# emscripten
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
else
CC ?= gcc
TARGET := $(TARGET_NAME)_libretro.dll
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -lwinmm -Wl,--no-undefined
LIBS += -lwinmm -lws2_32
CXXFLAGS += -I..
CFLAGS += -I..
endif
ifeq ($(DEBUG), 1)
CXXFLAGS += -O0 -g
CFLAGS += -O0 -g
LDFLAGS += -g
else
CXXFLAGS += -O2 -DNDEBUG
CFLAGS += -O2 -DNDEBUG
endif
ifneq (,$(findstring qnx,$(platform)))
CFLAGS += -Wc,-std=c99
else
CFLAGS += -std=c99
endif
include Makefile.common
OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o)
CXXFLAGS += $(fpic)
CFLAGS += -Wall -pedantic $(fpic)
ifneq (,$(findstring osx,$(platform)))
CXXFLAGS += -std=c++11
endif
CFLAGS += $(INCFLAGS) $(FLAGS)
CXXFLAGS += $(INCFLAGS) $(FLAGS)
ifeq ($(CORE), 1)
CXXFLAGS += -DCORE
CFLAGS += -DCORE
endif
CXXFLAGS += -D__LIBRETRO__
CFLAGS += -D__LIBRETRO__
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CXX) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LIBS) $(LDFLAGS) -lm
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(fpic) -c -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) $(fpic) -c -o $@ $<
clean:
rm -f $(OBJECTS) $(TARGET)
.PHONY: clean