forked from libretro/mame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.libretro
250 lines (222 loc) · 6.45 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
VERBOSE ?= 1
RETRO ?= 1
NOWERROR ?= 1
CONFIG ?= libretro"
NO_USE_MIDI ?= 1
NO_USE_PORTAUDIO ?= 1
PTR64 ?= 1
TARGET ?= mame
# OS ?= linux
# TARGETOS ?= linux
PYTHON_EXECUTABLE ?= python3
REGENIE ?= 1
GITHUB_REPO ?= https://github.com/libretro/mame/
DEBUG ?= 0
###########################################################################
#
# LIBRETRO PLATFORM GUESSING
#
# If the caller doesn't specify $platform and $ARCH, we guess
#
###########################################################################
UNAME_S = $(shell uname -s)
UNAME_M = $(shell uname -m)
ifeq ($(platform),)
platform = unix
ifeq ($(UNAME_S),)
platform = win
else ifneq ($(findstring MINGW,$(UNAME_S)),)
platform = win
else ifneq ($(findstring MSYS,$(UNAME_S)),)
platform = win
else ifneq ($(findstring Darwin,$(UNAME_S)),)
platform = osx
else ifneq ($(findstring win,$(UNAME_S)),)
platform = win
else ifeq ($(UNAME_M), "i686")
platform = linux32
endif
endif
ifeq ($(ARCH),)
LIBRETRO_CPU = $(ARCH)
endif
ifeq ($(LIBRETRO_CPU),)
ifeq ($(UNAME_M),)
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
LIBRETRO_CPU = x86_64
endif
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
LIBRETRO_CPU = x86_64
endif
else ifeq ($(UNAME_M),amd64)
LIBRETRO_CPU = x86_64
else
LIBRETRO_CPU = $(UNAME_M)
endif
endif
ifeq ($(ARCH),x86)
PTR64 := 0
endif
###########################################################################
#
# BUILD FLAGS
#
###########################################################################
BUILDFLAGS = RETRO=$(RETRO) REGENIE=$(REGENIE) VERBOSE=$(VERBOSE) NOWERROR=$(NOWERROR) OSD="retro" NO_USE_MIDI=$(NO_USE_MIDI) NO_USE_PORTAUDIO=$(NO_USE_PORTAUDIO)
ifneq ($(PYTHON_EXECUTABLE),)
BUILDFLAGS += PYTHON_EXECUTABLE=$(PYTHON_EXECUTABLE)
endif
ifeq ($(DEBUG),1)
BUILDFLAGS += CONFIG=libretrodbg
BUILDFLAGS += SYMBOLS=1 SYMLEVEL=1 OPTIMIZE=g
else
BUILDFLAGS += CONFIG=libretro
endif
###########################################################################
#
# PLATFORM FLAGS
#
###########################################################################
PLATFLAGS =
ifneq ($(findstring win,$(platform)),)
ifeq ($(MSYSTEM),MINGW64)
MINGW64 ?= /mingw64
PLATFLAGS += MINGW64="$(MINGW64)"
LIBRETRO_CPU="x86_64"
else ifeq ($(MSYSTEM),MINGW32)
MINGW32 ?= /mingw32
PLATFLAGS += MINGW32="$(MINGW32)"
LIBRETRO_CPU="x86"
PTR64=0
endif
CC ?= cc
CXX ?= cxx
AR ?= ar
PLATFLAGS += TARGETOS="windows" OVERRIDE_CC="$(CC)" OVERRIDE_CXX="$(CXX)" "AR=$(AR)"
ifneq ($(WINDRES),)
PLATFLAGS += WINDRES="$(WINDRES)"
endif
endif
ifeq ($(platform),android-arm)
ANDROID_NDK_LLVM ?= /opt/ndk/toolchains/llvm/prebuilt/linux-x86_64
ANDROID_NDK_ARM ?= /opt/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
ANDROID_NDK_ROOT ?= /opt/ndk
PLATFLAGS += TARGETOS="android-arm" gcc="android-arm"
PLATFLAGS += ANDROID_NDK_LLVM="$(ANDROID_NDK_LLVM)"
PLATFLAGS += ANDROID_NDK_ARM="$(ANDROID_NDK_ARM)"
PLATFLAGS += ANDROID_NDK_ROOT="$(ANDROID_NDK_ROOT)"
LIBRETRO_CPU :=
ARCH :=
LIBRETRO_OS :=
PTR64 :=
endif
ifeq ($(platform),android-arm64)
ANDROID_NDK_LLVM ?= /opt/ndk/toolchains/llvm/prebuilt/linux-x86_64
ANDROID_NDK_ARM64 ?= /opt/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64
ANDROID_NDK_ROOT ?= /opt/ndk
PLATFLAGS += TARGETOS="android-arm64" gcc="android-arm64"
PLATFLAGS += ANDROID_NDK_LLVM="$(ANDROID_NDK_LLVM)"
PLATFLAGS += ANDROID_NDK_ARM64="$(ANDROID_NDK_ARM64)"
PLATFLAGS += ANDROID_NDK_ROOT="$(ANDROID_NDK_ROOT)"
LIBRETRO_CPU :=
ARCH :=
LIBRETRO_OS :=
PTR64 :=
endif
ifeq ($(platform),android-x86_64)
ANDROID_NDK_LLVM ?= /opt/ndk/toolchains/llvm/prebuilt/linux-x86_64
ANDROID_NDK_X64 ?= /opt/ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64
ANDROID_NDK_ROOT ?= /opt/ndk
PLATFLAGS += TARGETOS="android-x64" gcc="android-x64"
PLATFLAGS += ANDROID_NDK_LLVM="$(ANDROID_NDK_LLVM)"
PLATFLAGS += ANDROID_NDK_X64="$(ANDROID_NDK_X64)"
PLATFLAGS += ANDROID_NDK_ROOT="$(ANDROID_NDK_ROOT)"
LIBRETRO_CPU :=
ARCH :=
LIBRETRO_OS :=
PTR64 :=
endif
ifeq ($(platform),linux32)
PTR64 := 0
endif
ifeq ($(platform),osx)
PLATFLAGS += DONT_USE_NETWORK=1
ifeq ($(CROSS_COMPILE),1)
LIBRETRO_CPU = arm64
LIBRETRO_OS = osx-arm64
ARCH = arm64
TARGET_RULE = -arch $(ARCH) -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
CC = clang $(TARGET_RULE)
CXX = clang++ $(TARGET_RULE)
PLATFLAGS += OVERRIDE_CC="$(CC)" OVERRIDE_CXX="$(CXX)"
CFLAGS += $(TARGET_RULE)
CPPFLAGS += $(TARGET_RULE)
CXXFLAGS += $(TARGET_RULE)
LDFLAGS += $(TARGET_RULE)
endif
endif
ifeq ($(platform),ios-arm64)
PLATFLAGS += DONT_USE_NETWORK=1
LIBRETRO_CPU = arm64
ARCH = arm64
LIBRETRO_OS = ios-arm64
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
CC = cc -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=12.0
CXX = c++ -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=12.0
PLATFLAGS += OVERRIDE_CC="$(CC)" OVERRIDE_CXX="$(CXX)"
endif
ifeq ($(platform),tvos-arm64)
PLATFLAGS += DONT_USE_NETWORK=1
LIBRETRO_CPU = arm64
ARCH = arm64
LIBRETRO_OS = ios-arm64
IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
CC = cc -arch arm64 -isysroot $(IOSSDK)
CXX = c++ -arch arm64 -isysroot $(IOSSDK)
PLATFLAGS += OVERRIDE_CC="$(CC)" OVERRIDE_CXX="$(CXX)"
endif
ifneq ($(LIBRETRO_CPU),)
PLATFLAGS += ARCH="" LIBRETRO_CPU="$(LIBRETRO_CPU)"
endif
ifneq ($(FORCE_DRC_C_BACKEND),)
PLATFLAGS += FORCE_DRC_C_BACKEND="$(FORCE_DRC_C_BACKEND)"
endif
ifneq ($(LIBRETRO_OS),)
PLATFLAGS += LIBRETRO_OS="$(platform)"
endif
ifneq ($(PTR64),)
PLATFLAGS += PTR64=$(PTR64)
endif
###########################################################################
#
# TARGET FLAGS
#
###########################################################################
TARGETFLAGS =
ifneq ($(TARGET),)
TARGETFLAGS += TARGET=$(TARGET)
endif
ifneq ($(SUBTARGET),)
TARGETFLAGS += SUBTARGET=$(SUBTARGET)
endif
ifneq ($(SOURCES),)
TARGETFLAGS += SOURCES=$(SOURCES)
endif
###########################################################################
#
# MAKE RULES
#
# We just call upstream GENie here with appropriate args
#
###########################################################################
# MAKEFILE is set by libretro gitlab-ci, but it confuses GENIE. So, unset it.
# undefine <var> is not supported on make 3.81 (used by macosx).
MAKEFILE :=
all: build
build:
$(MAKE) $(BUILDFLAGS) $(PLATFLAGS) $(TARGETFLAGS)
vs2015:
$(MAKE) $(BUILDFLAGS) $(PLATFLAGS) $(TARGETFLAGS) vs2015
clean:
$(MAKE) $(BUILDFLAGS) $(PLATFLAGS) $(TARGETFLAGS) clean
.PHONY: all build clean vs2015