forked from mamedev/mame
-
Notifications
You must be signed in to change notification settings - Fork 74
/
Makefile.libretro
329 lines (298 loc) · 10.2 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
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
VERBOSE ?= 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
#see https://github.com/libretro/mame/blob/093209930f5fbdaee0d6f3a3666f3d70025d089f/3rdparty/genie/build/gmake.darwin/genie.make#L55C2-L55C47
export LIBRETRO_OS
#this make file need dont better ad use vars instead of the way it done again can wait till the mac builds work
export ARCHOPTS
export ARCH
###########################################################################
#
# 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 = linux
endif
endif
ifneq ($(ARCH),)
LIBRETRO_CPU = $(ARCH)
#GENIE makefiles use this variable fr something else unset if set
ifeq ($(ARCH),x86)
PTR64 := 0
endif
ARCH :=
$(info unsetting ARCH=$(LIBRETRO_CPU))
endif
ifeq ($(platform),)
$(error platform not set)
else
$(info platform=$(platform))
$(info Defaults cc=$(cc) CC=$(CC) CFLAGS=$(CFLAGS) CCFLAGS=$(CCFLAGS) CXXFLAGS=$(CXXFLAGS) LDFLAGS=$(LDFLAGS) ARCH=$(ARCH) arch=$(arch) NUMPROC=$(NUMPROC))
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
###########################################################################
#
# BUILD FLAGS
#
###########################################################################
BUILDFLAGS = 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)
LLD := $(shell command -v lld 2> /dev/null)
ifneq ($(LLD),)
BUILDFLAGS += LDOPTS=-fuse-ld=lld
endif
ifneq ($(WINDRES),)
PLATFLAGS += WINDRES=$(WINDRES)
endif
endif
# android only needs a valid ANDROID_NDK_HOME set no paths are needed toolchain and makefile takes care of that
# make CONFIG=libretero OSD=retro android-xxx is all thes required
ifeq ($(platform),android-arm)
#buildbot fix
ifneq ($(ANDROID_NDK_ROOT),)
ANDROID_NDK_HOME=$(ANDROID_NDK_ROOT)
endif
export ANDROID_NDK_HOME ?= /opt/ndk
PLATFLAGS += TARGETOS=android-arm gcc=android-arm PLATFORM=arm
LIBRETRO_CPU :=
LIBRETRO_OS :=
PTR64 :=
endif
ifeq ($(platform),android-arm64)
#buildbot fix
ifneq ($(ANDROID_NDK_ROOT),)
ANDROID_NDK_HOME=$(ANDROID_NDK_ROOT)
endif
export ANDROID_NDK_HOME ?= /opt/ndk
PLATFLAGS += TARGETOS=android-arm64 gcc=android-arm64 PLATFORM=arm64
LIBRETRO_CPU :=
LIBRETRO_OS :=
PTR64 :=
endif
ifeq ($(platform),android-x86)
#buildbot fix
ifneq ($(ANDROID_NDK_ROOT),)
ANDROID_NDK_HOME=$(ANDROID_NDK_ROOT)
endif
export ANDROID_NDK_HOME ?= /opt/ndk
PLATFLAGS += TARGETOS=android-x86 gcc=android-x86 PLATFORM=x86
LIBRETRO_CPU :=
LIBRETRO_OS :=
PTR64 :=
endif
ifeq ($(platform),android-x86_64)
#buildbot fix
ifneq ($(ANDROID_NDK_ROOT),)
ANDROID_NDK_HOME=$(ANDROID_NDK_ROOT)
endif
export ANDROID_NDK_HOME ?= /opt/ndk
PLATFLAGS += TARGETOS=android-x64 gcc=android-x64 PLATFORM=x64
LIBRETRO_CPU :=
LIBRETRO_OS :=
PTR64 :=
endif
ifneq ($(ANDROID_NDK_HOME),)
OK := $(shell if [ -d $(ANDROID_NDK_HOME) ]; then echo "ok"; fi)
ifeq ($(OK),)
$(error path $(ANDROID_NDK_HOME) does not exist! please set ANDROID_NDK_HOME!)
else
$(info ANDROID_NDK_HOME path is a valid directory $(ANDROID_NDK_HOME))
endif
endif
ifeq ($(platform),linux32)
TARGETOS = linux
PTR64 := 0
endif
ifeq ($(platform),osx)
PLATFLAGS += DONT_USE_NETWORK=1
#PLATFLAGS +=OVERRIDE_CC=clang OVERRIDE_CXX=clang++
PLATFLAGS +=TARGETOS=macosx
ifeq ($(CROSS_COMPILE),1)
ARCHOPTS =-target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
#libretro cpu and and libretro os arent needed for the mac anymore builds, Ill need to make sure there not used in other places (in the lua scripts)
#leave as is for now but add the the platfrom and remove the conditions in LUA when ready to test. LEts get the builds working. LIBRETRO_CPU = arm64
LIBRETRO_OS = macosx
LIBRETRO_CPU = arm64
PLATFLAGS +=LIBRETRO_OSX_ARM64=1
PLATFLAGS +=PLATFORM=arm64
#this will be removed like x64 platfrom after the builds are working
ARCHOPTS +=-arch $(LIBRETRO_CPU)
#this isint needed but it confuses people and they assume ist a x64 instead of arm build when there is a makefile issue
PLATFLAGS +=macosx_arm64_clang
else
LIBRETRO_OS = macosx
LIBRETRO_CPU =x86_64
#not set on x64 use the info from arm64 so we get the right target and path
LIBRETRO_APPLE_PLATFORM=x86_64-apple-macos10.15
LIBRETRO_APPLE_ISYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
ARCHOPTS =-target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
PLATFLAGS +=PLATFORM=x64
#we dont need to pass -arch as i fixed the condition and there and arm is added from upstream in the last pull req.
#There is no variable in the lua scrip to disable it the other platfrom will follow suit and just use PLATFORM when we are up and running.
endif
PTR64 = 1
endif
ifeq ($(platform),ios-arm64)
LIBRETRO_APPLE_PLATFORM = arm64-apple-ios12.0
LIBRETRO_APPLE_ISYSROOT := $(shell xcodebuild -version -sdk iphoneos Path)
ARCHOPTS =-target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT) -miphoneos-version-min=12.0
#the ci should set above only osx does it so far unset if its added to the ci
#-isysroot $(LIBRETRO_APPLE_ISYSROOT)
#-arch $(LIBRETRO_CPU) -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(IOSSDK) -miphoneos-version-min=12.0 was the flags used
#This is my first time touching mac related stuff, someone more knowlagable of the platfrom can tweak the settings. Again the llvm is a good place to start
# thats how i got the tagets needed.
PLATFLAGS +=OVERRIDE_CC=clang OVERRIDE_CXX=clang++
PLATFLAGS +=DONT_USE_NETWORK=1
PLATFLAGS +=NOASM=1
PLATFLAGS +=NO_USE_MIDI=1
PLATFLAGS +=NO_OPENGL=1
PLATFLAGS +=USE_QTDEBUG=0
PLATFLAGS +=LIBRETRO_IOS=1
#libretro cpu and and libretro os arent needed for the mac anymore builds, Ill need to make sure there not used in other places(in the lua scripts)
#leave as is for now but add the the platfrom and remove the conditions in LUA when ready to test. LEts get the builds working.
LIBRETRO_CPU = arm64
LIBRETRO_OS = macosx
PLATFLAGS +=LIBRETRO_IOS=1
ARCHOPTS +=-arch $(LIBRETRO_CPU)
PLATFLAGS +=TARGETOS=macosx
PLATFLAGS +=PLATFORM=arm64
BUILDFLAGS += OPTIMIZE=s
PTR64 =1
#this isint needed but it confuses people and they assume ist a x64 instead of arm build when there is a makefile issue
PLATFLAGS +=macosx_arm64_clang
endif
ifeq ($(platform),tvos-arm64)
LIBRETRO_APPLE_PLATFORM = arm64-apple-tvos11.0
LIBRETRO_APPLE_ISYSROOT := $(shell xcodebuild -version -sdk appletvos Path)
ARCHOPTS =-target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT) -mappletvos-version-min=11.0
#the ci should set above only osx does it so far unset if its udded to the ci
PLATFLAGS +=OVERRIDE_CC=clang OVERRIDE_CXX=clang++
PLATFLAGS +=DONT_USE_NETWORK=1
PLATFLAGS +=NOASM=1
PLATFLAGS +=NO_USE_MIDI=1
PLATFLAGS +=NO_OPENGL=1
PLATFLAGS +=USE_QTDEBUG=0
#libretro cpu and and libretro os arent needed for the mac anymore builds, Ill need to make sure there not used in other places(in the lua scripts)
#leave as is for now but add the the platfrom and remove the conditions in LUA when ready to test. LEts get the builds working.
LIBRETRO_CPU = arm64
LIBRETRO_OS =macosx
PLATFLAGS +=LIBRETRO_TVOS=1
ARCHOPTS +=-arch $(LIBRETRO_CPU)
PLATFLAGS +=TARGETOS=macosx
PLATFLAGS +=PLATFORM=arm64
BUILDFLAGS += OPTIMIZE=s
PTR64 =1
#this isint needed but it confuses people and they assume ist a x64 instead of arm build when there is a makefile issue
PLATFLAGS +=macosx_arm64_clang
endif
ifneq ($(LIBRETRO_CPU),)
PLATFLAGS += LIBRETRO_CPU=$(LIBRETRO_CPU)
endif
ifneq ($(FORCE_DRC_C_BACKEND),)
PLATFLAGS += FORCE_DRC_C_BACKEND=$(FORCE_DRC_C_BACKEND)
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)
vs2019:
$(MAKE) $(BUILDFLAGS) $(PLATFLAGS) $(TARGETFLAGS) vs2019
clean:
$(MAKE) $(BUILDFLAGS) $(PLATFLAGS) $(TARGETFLAGS) clean
.PHONY: all build clean vs2019