Makefile 20.9 KB
Newer Older
1
2
DEBUG = 0
FRONTEND_SUPPORTS_RGB565 = 1
jdgleaver's avatar
jdgleaver committed
3
FRONTEND_SUPPORTS_XRGB8888 = 0
4

Libretro-Admin's avatar
Libretro-Admin committed
5
TARGET_NAME := handy
6
7
8
9
GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown")
	CXXFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
LLeny's avatar
LLeny committed
10

Libretro-Admin's avatar
Libretro-Admin committed
11
ifeq ($(platform),)
sergiobenrocha2's avatar
sergiobenrocha2 committed
12
13
14
15
16
17
18
19
20
21
	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
	else ifneq ($(findstring win,$(shell uname -a)),)
		platform = win
	endif
Libretro-Admin's avatar
Libretro-Admin committed
22
23
24
25
26
endif

LIBRETRO_DIR := libretro
CORE_DIR := src

Adrien Plazas's avatar
Adrien Plazas committed
27
28
29
30
31
prefix := /usr
libdir := $(prefix)/lib

LIBRETRO_INSTALL_DIR := libretro

Libretro-Admin's avatar
Libretro-Admin committed
32
33
34
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
sergiobenrocha2's avatar
sergiobenrocha2 committed
35
36
	EXE_EXT = .exe
	system_platform = win
Libretro-Admin's avatar
Libretro-Admin committed
37
else ifneq ($(findstring Darwin,$(shell uname -a)),)
sergiobenrocha2's avatar
sergiobenrocha2 committed
38
	system_platform = osx
Libretro-Admin's avatar
Libretro-Admin committed
39
else ifneq ($(findstring MINGW,$(shell uname -a)),)
sergiobenrocha2's avatar
sergiobenrocha2 committed
40
	system_platform = win
Libretro-Admin's avatar
Libretro-Admin committed
41
42
endif

Libretro-Admin's avatar
Libretro-Admin committed
43
44
45
46
47
48
49
50
51
SPACE :=
SPACE := $(SPACE) $(SPACE)
BACKSLASH :=
BACKSLASH := \$(BACKSLASH)
filter_out1 = $(filter-out $(firstword $1),$1)
filter_out2 = $(call filter_out1,$(call filter_out1,$1))
unixpath = $(subst \,/,$1)
unixcygpath = /$(subst :,,$(call unixpath,$1))

sergiobenrocha2's avatar
sergiobenrocha2 committed
52
# Unix
liberodark's avatar
liberodark committed
53
ifneq (,$(findstring unix,$(platform)))
sergiobenrocha2's avatar
sergiobenrocha2 committed
54
55
56
	fpic := -fPIC
	TARGET := $(TARGET_NAME)_libretro.so
	SHARED := -shared -Wl,-version-script=$(LIBRETRO_DIR)/link.T -Wl,-no-undefined
jdgleaver's avatar
jdgleaver committed
57
	FRONTEND_SUPPORTS_XRGB8888 = 1
Libretro-Admin's avatar
Libretro-Admin committed
58

sergiobenrocha2's avatar
sergiobenrocha2 committed
59
60
61
62
63
64
65
66
# OS X
else ifeq ($(platform),osx)
	fpic := -fPIC
	TARGET := $(TARGET_NAME)_libretro.dylib
	SHARED := -dynamiclib
	LIBS :=
	OSXVER = `sw_vers -productVersion | cut -d. -f 2`
	OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
Libretro-Admin's avatar
Libretro-Admin committed
67
ifeq ($(OSX_LT_MAVERICKS),"YES")
Libretro-Admin's avatar
Libretro-Admin committed
68
	fpic += -mmacosx-version-min=10.1
Libretro-Admin's avatar
Libretro-Admin committed
69
70
71
else
	fpic += -mmacosx-version-min=10.7 -stdlib=libc++
endif
sergiobenrocha2's avatar
sergiobenrocha2 committed
72
73
74
75
76
77
78
	ifndef ($(NOUNIVERSAL))
		CFLAGS  += $(ARCHFLAGS)
		CXXFLAGS  += $(ARCHFLAGS)
		LDFLAGS += $(ARCHFLAGS)
	endif

# iOS
Libretro-Admin's avatar
Libretro-Admin committed
79
80
else ifneq (,$(findstring ios,$(platform)))

sergiobenrocha2's avatar
sergiobenrocha2 committed
81
82
83
84
	fpic := -fPIC
	TARGET := $(TARGET_NAME)_libretro_ios.dylib
	SHARED := -dynamiclib
	ifeq ($(IOSSDK),)
85
		IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
sergiobenrocha2's avatar
sergiobenrocha2 committed
86
	endif
harakari's avatar
harakari committed
87
88
89
90
91
92
93
	ifeq ($(platform),ios-arm64)
		CC = cc -arch arm64 -isysroot $(IOSSDK)
		CXX = c++ -arch arm64 -isysroot $(IOSSDK)
	else
		CC = cc -arch armv7 -isysroot $(IOSSDK)
		CXX = c++ -arch armv7 -isysroot $(IOSSDK)
	endif
sergiobenrocha2's avatar
sergiobenrocha2 committed
94
	LIBS :=
harakari's avatar
harakari committed
95
ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
Libretro-Admin's avatar
Libretro-Admin committed
96
97
98
99
100
101
102
103
	SHARED += -miphoneos-version-min=8.0
	CC +=  -miphoneos-version-min=8.0
	CXX +=  -miphoneos-version-min=8.0
else
	SHARED += -miphoneos-version-min=5.0
	CC +=  -miphoneos-version-min=5.0
	CXX +=  -miphoneos-version-min=5.0
endif
sergiobenrocha2's avatar
sergiobenrocha2 committed
104

harakari's avatar
harakari committed
105
106
107
108
109
110
111
112
113
114
# tvOS
else ifeq ($(platform), tvos-arm64)
	fpic := -fPIC
	TARGET := $(TARGET_NAME)_libretro_tvos.dylib
	SHARED := -dynamiclib
	ifeq ($(IOSSDK),)
		IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
	endif
	LIBS :=

sergiobenrocha2's avatar
sergiobenrocha2 committed
115
# Theos iOS
116
else ifeq ($(platform), theos_ios)
sergiobenrocha2's avatar
sergiobenrocha2 committed
117
118
119
120
121
122
123
124
125
	DEPLOYMENT_IOSVERSION = 5.0
	TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION)
	ARCHS = armv7 armv7s
	TARGET_IPHONEOS_DEPLOYMENT_VERSION=$(DEPLOYMENT_IOSVERSION)
	THEOS_BUILD_DIR := objs
	include $(THEOS)/makefiles/common.mk
	LIBRARY_NAME = $(TARGET_NAME)_libretro_ios

# QNX
Libretro-Admin's avatar
Libretro-Admin committed
126
else ifeq ($(platform),qnx)
sergiobenrocha2's avatar
sergiobenrocha2 committed
127
	fpic := -fPIC
Libretro-Admin's avatar
Libretro-Admin committed
128
	TARGET := $(TARGET_NAME)_libretro_$(platform).so
sergiobenrocha2's avatar
sergiobenrocha2 committed
129
	SHARED := -shared -Wl,-version-script=$(LIBRETRO_DIR)/link.T -Wl,-no-undefined
Libretro-Admin's avatar
Libretro-Admin committed
130
131
	CC = qcc -Vgcc_ntoarmv7le
	CXX = QCC -Vgcc_ntoarmv7le_cpp
Libretro-Admin's avatar
Libretro-Admin committed
132

sergiobenrocha2's avatar
sergiobenrocha2 committed
133
134
# PS3
else ifeq ($(platform),ps3)
Libretro-Admin's avatar
Libretro-Admin committed
135
	TARGET := $(TARGET_NAME)_libretro_$(platform).a
sergiobenrocha2's avatar
sergiobenrocha2 committed
136
	CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
Libretro-Admin's avatar
Libretro-Admin committed
137
	CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe
sergiobenrocha2's avatar
sergiobenrocha2 committed
138
	AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
Libretro-Admin's avatar
update    
Libretro-Admin committed
139
	FLAGS += -DMSB_FIRST
Libretro-Admin's avatar
Libretro-Admin committed
140
141
142
	STATIC_LINKING := 1
	LIBS :=

sergiobenrocha2's avatar
sergiobenrocha2 committed
143
144
145
146
147
148
# sncps3
else ifeq ($(platform), sncps3)
	TARGET := $(TARGET_NAME)_libretro_ps3.a
	CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
	CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
	AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
Libretro-Admin's avatar
update    
Libretro-Admin committed
149
	FLAGS += -DMSB_FIRST
Libretro-Admin's avatar
Libretro-Admin committed
150
151
	STATIC_LINKING := 1
	LIBS :=
sergiobenrocha2's avatar
sergiobenrocha2 committed
152

fjtrujy's avatar
fjtrujy committed
153
154
155
# PS2
else ifeq ($(platform),ps2)
	TARGET := $(TARGET_NAME)_libretro_$(platform).a
156
157
158
	CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT)
	CXX = mips64r5900el-ps2-elf-g++$(EXE_EXT)
	AR = mips64r5900el-ps2-elf-ar$(EXE_EXT)
fjtrujy's avatar
fjtrujy committed
159
160
161
162
163
	FLAGS += -G0 -DPS2 -DABGR1555 -DHAVE_NO_LANGEXTRA
	INCFLAGS_PLATFORM += -O3
	STATIC_LINKING := 1
	LIBS :=

sergiobenrocha2's avatar
sergiobenrocha2 committed
164
# PSP
Libretro-Admin's avatar
Libretro-Admin committed
165
else ifeq ($(platform),psp1)
Libretro-Admin's avatar
Libretro-Admin committed
166
	TARGET := $(TARGET_NAME)_libretro_$(platform).a
Libretro-Admin's avatar
Libretro-Admin committed
167
168
169
	CC = psp-gcc$(EXE_EXT)
	CXX = psp-g++$(EXE_EXT)
	AR = psp-ar$(EXE_EXT)
170
171
	FLAGS += -G0 -DPSP 
	INCFLAGS_PLATFORM += -O3
Libretro-Admin's avatar
Libretro-Admin committed
172
173
	STATIC_LINKING := 1
	LIBS :=
sergiobenrocha2's avatar
sergiobenrocha2 committed
174

Libretro-Admin's avatar
Libretro-Admin committed
175
176
# Vita
else ifeq ($(platform),vita)
Libretro-Admin's avatar
Libretro-Admin committed
177
	TARGET := $(TARGET_NAME)_libretro_$(platform).a
Libretro-Admin's avatar
Libretro-Admin committed
178
179
180
	CC = arm-vita-eabi-gcc$(EXE_EXT)
	CXX = arm-vita-eabi-g++$(EXE_EXT)
	AR = arm-vita-eabi-ar$(EXE_EXT)
Libretro-Admin's avatar
update    
Libretro-Admin committed
181
	FLAGS += -DVITA -DLSB_FIRST
Libretro-Admin's avatar
Libretro-Admin committed
182
183
184
	STATIC_LINKING := 1
	LIBS :=

185
186
# Nintendo Game Cube
else ifeq ($(platform), ngc)
Libretro-Admin's avatar
Libretro-Admin committed
187
	TARGET := $(TARGET_NAME)_libretro_$(platform).a
188
189
190
191
192
193
194
195
196
	CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
	CXX = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
	AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
	FLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
	STATIC_LINKING = 1
	LIBS :=

# Nintendo Wii
else ifeq ($(platform), wii)
Libretro-Admin's avatar
Libretro-Admin committed
197
	TARGET := $(TARGET_NAME)_libretro_$(platform).a
198
199
200
201
202
203
204
	CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
	CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
	AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
	FLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
	STATIC_LINKING = 1
	LIBS :=

MrHuu's avatar
MrHuu committed
205
# Nintendo Wiiu
Libretro-Admin's avatar
Libretro-Admin committed
206
207
208
209
210
211
212
213
else ifeq ($(platform), wiiu)
	TARGET := $(TARGET_NAME)_libretro_$(platform).a
	CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
	CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
	AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
	FLAGS += -DGEKKO -DWIIU -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
	STATIC_LINKING = 1
	LIBS :=
jdgleaver's avatar
jdgleaver committed
214

MrHuu's avatar
MrHuu committed
215
216
217
218
219
220
221
222
223
224
225
226
# CTR (3DS)
else ifeq ($(platform), ctr)
	TARGET := $(TARGET_NAME)_libretro_$(platform).a
	CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
	CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
	AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
	PLATFORM_DEFINES := -DARM11 -D_3DS -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS
	CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard
	CFLAGS += -Wall -mword-relocations
	CFLAGS += -fomit-frame-pointer -ffast-math
	CXXFLAGS += $(CFLAGS)
	STATIC_LINKING = 1
Libretro-Admin's avatar
Libretro-Admin committed
227

jdgleaver's avatar
jdgleaver committed
228
229
230
231
232
233
234
235
236
237
# GCW0
else ifeq ($(platform), gcw0)
   TARGET := $(TARGET_NAME)_libretro.so
   CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
   CXX = /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++
   AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
   fpic := -fPIC
   SHARED := -shared -Wl,--no-undefined -Wl,-version-script=$(LIBRETRO_DIR)/link.T
   FLAGS += -DDINGUX -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float

m4xw's avatar
m4xw committed
238
239
240
241
242
243
244
245
246
247
248
249
250
# Nintendo Switch (libnx)
else ifeq ($(platform), libnx)
	include $(DEVKITPRO)/libnx/switch_rules
	EXT=a
	TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
	DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL
	CFLAGS := $(DEFINES) -g -O3 -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs
	CFLAGS += $(INCDIRS)
	CFLAGS += $(INCLUDE)  -D__SWITCH__
	CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
	CFLAGS += -std=gnu11
	STATIC_LINKING = 1

Lubosz Sarnecki's avatar
Lubosz Sarnecki committed
251
252
253
254
255
256
# Nintendo Switch (libtransistor)
else ifeq ($(platform), switch)
   TARGET := $(TARGET_NAME)_libretro_$(platform).a
   include $(LIBTRANSISTOR_HOME)/libtransistor.mk
   STATIC_LINKING=1

Ryan 'Swingflip' Hamlin's avatar
Ryan 'Swingflip' Hamlin committed
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
# 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=$(LIBRETRO_DIR)/link.T -Wl,-no-undefined
	FLAGS += -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
	HAVE_NEON = 1
	ARCH = arm
	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
funbars's avatar
funbars committed
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

# (armv8 a35, hard point, neon based) ###
# Playstation Classic
else ifeq ($(platform), classic_armv8_a35)
	TARGET := $(TARGET_NAME)_libretro.so
	fpic := -fPIC
    SHARED := -shared -Wl,-version-script=$(LIBRETRO_DIR)/link.T -Wl,-no-undefined
	FLAGS += -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
	HAVE_NEON = 1
	ARCH = arm
	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
Ryan 'Swingflip' Hamlin's avatar
Ryan 'Swingflip' Hamlin committed
312
313
#######################################

sergiobenrocha2's avatar
sergiobenrocha2 committed
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# ARM
else ifneq (,$(findstring armv,$(platform)))
	TARGET := $(TARGET_NAME)_libretro.so
	SHARED := -shared -Wl,-version-script=$(LIBRETRO_DIR)/link.T -Wl,-no-undefined
	fpic := -fPIC
	ifneq (,$(findstring cortexa5,$(platform)))
		FLAGS += -marm -mcpu=cortex-a5
	else ifneq (,$(findstring cortexa8,$(platform)))
		FLAGS += -marm -mcpu=cortex-a8
	else ifneq (,$(findstring cortexa9,$(platform)))
		FLAGS += -marm -mcpu=cortex-a9
	else ifneq (,$(findstring cortexa15a7,$(platform)))
		FLAGS += -marm -mcpu=cortex-a15.cortex-a7
	else
		FLAGS += -marm
	endif
	ifneq (,$(findstring softfloat,$(platform)))
		FLAGS += -mfloat-abi=softfp
	else ifneq (,$(findstring hardfloat,$(platform)))
		FLAGS += -mfloat-abi=hard
	endif

Libretro-Admin's avatar
Libretro-Admin committed
336
337
338
339
# Emscripten
else ifeq ($(platform), emscripten)
	TARGET := $(TARGET_NAME)_libretro_$(platform).bc
	STATIC_LINKING = 1
funbars's avatar
funbars committed
340

Libretro-Admin's avatar
Libretro-Admin committed
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# Windows MSVC 2010 x64
else ifeq ($(platform), windows_msvc2010_x64)
	CC  = cl.exe
	CXX = cl.exe

PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin/amd64"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
LIB := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/lib/amd64")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include")

WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib/x64
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib/x64

WindowsSdkDirInc := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include
WindowsSdkDirInc ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include


INCFLAGS_PLATFORM = -I"$(WindowsSdkDirInc)"
export INCLUDE := $(INCLUDE)
export LIB := $(LIB);$(WindowsSdkDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
funbars's avatar
funbars committed
364

Libretro-Admin's avatar
Libretro-Admin committed
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# Windows MSVC 2010 x86
else ifeq ($(platform), windows_msvc2010_x86)
	CC  = cl.exe
	CXX = cl.exe

PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/lib")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include")

WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib

WindowsSdkDirInc := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include
WindowsSdkDirInc ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include


INCFLAGS_PLATFORM = -I"$(WindowsSdkDirInc)"
export INCLUDE := $(INCLUDE)
export LIB := $(LIB);$(WindowsSdkDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL

Libretro-Admin's avatar
Libretro-Admin committed
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# Windows MSVC 2005 x86
else ifeq ($(platform), windows_msvc2005_x86)
	CC  = cl.exe
	CXX = cl.exe

PATH := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/include")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS80COMNTOOLS)../../VC/lib")
BIN := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin")

WindowsSdkDir := $(INETSDK)

export INCLUDE := $(INCLUDE);$(INETSDK)/Include;libretro-common/include/compat/msvc
export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
CFLAGS += -D_CRT_SECURE_NO_DEPRECATE
LIBS =
Libretro-Admin's avatar
Libretro-Admin committed
409

Libretro-Admin's avatar
Libretro-Admin committed
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# Windows MSVC 2003 Xbox 1
else ifeq ($(platform), xbox1_msvc2003)
TARGET := $(TARGET_NAME)_libretro_xdk1.lib
CC  = CL.exe
CXX  = CL.exe
LD   = lib.exe

export INCLUDE := $(XDK)/xbox/include
export LIB := $(XDK)/xbox/lib
PATH := $(call unixcygpath,$(XDK)/xbox/bin/vc71):$(PATH)
PSS_STYLE :=2
CFLAGS   += -D_XBOX -D_XBOX1
CXXFLAGS += -D_XBOX -D_XBOX1
STATIC_LINKING=1

Libretro-Admin's avatar
Libretro-Admin committed
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# Windows MSVC 2003 x86
else ifeq ($(platform), windows_msvc2003_x86)
	CC  = cl.exe
	CXX = cl.exe

PATH := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/include")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS71COMNTOOLS)../../Vc7/lib")
BIN := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin")

WindowsSdkDir := $(INETSDK)

export INCLUDE := $(INCLUDE);$(INETSDK)/Include;libretro-common/include/compat/msvc
export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
CFLAGS += -D_CRT_SECURE_NO_DEPRECATE

funbars's avatar
funbars committed
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
# Windows MSVC 2017 all architectures
else ifneq (,$(findstring windows_msvc2017,$(platform)))

   PlatformSuffix = $(subst windows_msvc2017_,,$(platform))
   ifneq (,$(findstring desktop,$(PlatformSuffix)))
      WinPartition = desktop
      MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -FS
      LDFLAGS += -MANIFEST -LTCG:incremental -NXCOMPAT -DYNAMICBASE -DEBUG -OPT:REF -INCREMENTAL:NO -SUBSYSTEM:WINDOWS -MANIFESTUAC:"level='asInvoker' uiAccess='false'" -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1
      LIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
   else ifneq (,$(findstring uwp,$(PlatformSuffix)))
      WinPartition = uwp
      MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WINDLL -D_UNICODE -DUNICODE -D__WRL_NO_DEFAULT_LIB__ -EHsc -FS
      LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO
      LIBS += WindowsApp.lib
   endif

   CFLAGS += $(MSVC2017CompileFlags) -DNOMINMAX
   CXXFLAGS += $(MSVC2017CompileFlags) -DNOMINMAX

   TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix))

   CC  = cl.exe
   CXX = cl.exe
   LD = link.exe

   reg_query = $(call filter_out2,$(subst $2,,$(shell reg query "$2" -v "$1" 2>nul)))
   fix_path = $(subst $(SPACE),\ ,$(subst \,/,$1))

Libretro-Admin's avatar
Libretro-Admin committed
473
   ProgramFiles86w := $(shell cmd //c "echo %PROGRAMFILES(x86)%")
funbars's avatar
funbars committed
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
   ProgramFiles86 := $(shell cygpath "$(ProgramFiles86w)")

   WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
   WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
   WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
   WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
   WindowsSdkDir := $(WindowsSdkDir)

   WindowsSDKVersion ?= $(firstword $(foreach folder,$(subst $(subst \,/,$(WindowsSdkDir)Include/),,$(wildcard $(call fix_path,$(WindowsSdkDir)Include\*))),$(if $(wildcard $(call fix_path,$(WindowsSdkDir)Include/$(folder)/um/Windows.h)),$(folder),)))$(BACKSLASH)
   WindowsSDKVersion := $(WindowsSDKVersion)

   VsInstallBuildTools = $(ProgramFiles86)/Microsoft Visual Studio/2017/BuildTools
   VsInstallEnterprise = $(ProgramFiles86)/Microsoft Visual Studio/2017/Enterprise
   VsInstallProfessional = $(ProgramFiles86)/Microsoft Visual Studio/2017/Professional
   VsInstallCommunity = $(ProgramFiles86)/Microsoft Visual Studio/2017/Community

   VsInstallRoot ?= $(shell if [ -d "$(VsInstallBuildTools)" ]; then echo "$(VsInstallBuildTools)"; fi)
   ifeq ($(VsInstallRoot), )
      VsInstallRoot = $(shell if [ -d "$(VsInstallEnterprise)" ]; then echo "$(VsInstallEnterprise)"; fi)
   endif
   ifeq ($(VsInstallRoot), )
      VsInstallRoot = $(shell if [ -d "$(VsInstallProfessional)" ]; then echo "$(VsInstallProfessional)"; fi)
   endif
   ifeq ($(VsInstallRoot), )
      VsInstallRoot = $(shell if [ -d "$(VsInstallCommunity)" ]; then echo "$(VsInstallCommunity)"; fi)
   endif
   VsInstallRoot := $(VsInstallRoot)

   VcCompilerToolsVer := $(shell cat "$(VsInstallRoot)/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | grep -o '[0-9\.]*')
   VcCompilerToolsDir := $(VsInstallRoot)/VC/Tools/MSVC/$(VcCompilerToolsVer)

   WindowsSDKSharedIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\shared")
   WindowsSDKUCRTIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\ucrt")
   WindowsSDKUMIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\um")
   WindowsSDKUCRTLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\ucrt\$(TargetArchMoniker)")
   WindowsSDKUMLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\um\$(TargetArchMoniker)")

   # For some reason the HostX86 compiler doesn't like compiling for x64
   # ("no such file" opening a shared library), and vice-versa.
   # Work around it for now by using the strictly x86 compiler for x86, and x64 for x64.
   # NOTE: What about ARM?
   ifneq (,$(findstring x64,$(TargetArchMoniker)))
      VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX64
   else
      VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX86
   endif

   PATH := $(shell IFS=$$'\n'; cygpath "$(VCCompilerToolsBinDir)/$(TargetArchMoniker)"):$(PATH)
   PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VsInstallRoot)/Common7/IDE")
   INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/include")
   LIB := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/lib/$(TargetArchMoniker)")
   ifneq (,$(findstring uwp,$(PlatformSuffix)))
      LIB := $(LIB)/store;$(LIB)
   endif

   export INCLUDE := $(INCLUDE);$(WindowsSDKSharedIncludeDir);$(WindowsSDKUCRTIncludeDir);$(WindowsSDKUMIncludeDir)
   export LIB := $(LIB);$(WindowsSDKUCRTLibDir);$(WindowsSDKUMLibDir)
   TARGET := $(TARGET_NAME)_libretro.dll
   PSS_STYLE :=2
   LDFLAGS += -DLL

sergiobenrocha2's avatar
sergiobenrocha2 committed
535
# Windows
Libretro-Admin's avatar
Libretro-Admin committed
536
else
sergiobenrocha2's avatar
sergiobenrocha2 committed
537
538
	fpic :=
	TARGET := $(TARGET_NAME)_libretro.dll
539
540
	CC ?= gcc
	CXX ?= g++
sergiobenrocha2's avatar
sergiobenrocha2 committed
541
	SHARED := -shared -static-libgcc -static-libstdc++ -Wl,-no-undefined -Wl,-version-script=$(LIBRETRO_DIR)/link.T
jdgleaver's avatar
jdgleaver committed
542
	FRONTEND_SUPPORTS_XRGB8888 = 1
sergiobenrocha2's avatar
sergiobenrocha2 committed
543

LLeny's avatar
LLeny committed
544
545
endif

Libretro-Admin's avatar
Libretro-Admin committed
546
CORE_DIR := .
Libretro-Admin's avatar
Libretro-Admin committed
547

Libretro-Admin's avatar
Libretro-Admin committed
548
include Makefile.common
Libretro-Admin's avatar
Libretro-Admin committed
549

Libretro-Admin's avatar
Libretro-Admin committed
550
OBJECTS := $(SOURCES_CXX:.cpp=.o)
Libretro-Admin's avatar
Libretro-Admin committed
551

Libretro-Admin's avatar
Libretro-Admin committed
552
ifeq ($(DEBUG),1)
jdgleaver's avatar
jdgleaver committed
553
FLAGS += -O0 -g
Libretro-Admin's avatar
Libretro-Admin committed
554
else
Libretro-Admin's avatar
Libretro-Admin committed
555
FLAGS += -O2 -DNDEBUG
Libretro-Admin's avatar
Libretro-Admin committed
556
557
endif

Libretro-Admin's avatar
Update    
Libretro-Admin committed
558
559
560
561
562
ifeq (,$(findstring msvc,$(platform)))
FLAGS += -fomit-frame-pointer
endif

FLAGS += -I. $(fpic) $(libs) $(includes) -DWANT_CRC32
Libretro-Admin's avatar
Libretro-Admin committed
563
564
565
566
567
568
569
570
571
572
573
574
575
CXXFLAGS += $(FLAGS) $(INCFLAGS) $(INCFLAGS_PLATFORM)
CFLAGS += $(FLAGS) $(INCFLAGS) $(INCFLAGS_PLATFORM)

OBJOUT   = -o
LINKOUT  = -o 

ifneq (,$(findstring msvc,$(platform)))
	OBJOUT = -Fo
	LINKOUT = -out:
	LD = link.exe
else
	LD = $(CXX)
endif
Libretro-Admin's avatar
Libretro-Admin committed
576

577
%.o: %.cpp
Libretro-Admin's avatar
Libretro-Admin committed
578
	$(CXX) -c $(OBJOUT)$@ $< $(CXXFLAGS)
579
580

%.o: %.c
Libretro-Admin's avatar
Libretro-Admin committed
581
	$(CC) -c $(OBJOUT)$@ $< $(CFLAGS)
582
583

ifeq ($(platform), theos_ios)
Libretro-Admin's avatar
Libretro-Admin committed
584
COMMON_FLAGS := -DIOS $(COMMON_DEFINES) -I$(THEOS_INCLUDE_PATH) -Wno-error
585
586
587
588
589
590
$(LIBRARY_NAME)_CFLAGS += $(CFLAGS) $(COMMON_FLAGS)
$(LIBRARY_NAME)_CXXFLAGS += $(CXXFLAGS) $(COMMON_FLAGS)
${LIBRARY_NAME}_FILES = $(SOURCES_CXX) $(SOURCES_C)
include $(THEOS_MAKE_PATH)/library.mk
else
all: $(TARGET)
Libretro-Admin's avatar
Libretro-Admin committed
591
$(TARGET): $(OBJECTS)
Libretro-Admin's avatar
Libretro-Admin committed
592
ifeq ($(STATIC_LINKING), 1)
Libretro-Admin's avatar
Libretro-Admin committed
593
	$(AR) rcs $@ $(OBJECTS)
LLeny's avatar
LLeny committed
594
else
Libretro-Admin's avatar
Libretro-Admin committed
595
	$(LD) $(LINKOUT)$@ $(SHARED) $(OBJECTS) $(LDFLAGS) $(LIBS)
LLeny's avatar
LLeny committed
596
597
endif

Libretro-Admin's avatar
Libretro-Admin committed
598
clean-objs:
Libretro-Admin's avatar
Libretro-Admin committed
599
	rm -f $(OBJECTS)
LLeny's avatar
LLeny committed
600
601

clean:
Libretro-Admin's avatar
Libretro-Admin committed
602
	rm -f $(OBJECTS)
Libretro-Admin's avatar
Libretro-Admin committed
603
604
	rm -f $(TARGET)

Adrien Plazas's avatar
Adrien Plazas committed
605
606
607
608
609
610
611
install:
	install -D -m 755 $(TARGET) $(DESTDIR)$(libdir)/$(LIBRETRO_INSTALL_DIR)/$(TARGET)

uninstall:
	rm $(DESTDIR)$(libdir)/$(LIBRETRO_INSTALL_DIR)/$(TARGET)

.PHONY: clean clean-objs all install uninstall
612
endif