1 # Makefile for PicoDrive (libretro)
4 SPACE := $(SPACE) $(SPACE)
6 BACKSLASH := \$(BACKSLASH)
7 filter_out1 = $(filter-out $(firstword $1),$1)
8 filter_out2 = $(call filter_out1,$(call filter_out1,$1))
12 ifeq ($(shell uname -a),)
14 else ifneq ($(findstring MINGW,$(shell uname -a)),)
16 else ifneq ($(findstring Darwin,$(shell uname -a)),)
18 else ifneq ($(findstring win,$(shell uname -a)),)
30 CFLAGS += -I platform/libretro/libretro-common/include
31 CFLAGS += -I platform/libretro/libretro-common/include/compat
32 CFLAGS += -I platform/libretro/libretro-common/include/encodings
33 CFLAGS += -I platform/libretro/libretro-common/include/formats
34 CFLAGS += -I platform/libretro/libretro-common/include/streams
35 CFLAGS += -I platform/libretro/libretro-common/include/string
36 CFLAGS += -I platform/libretro/libretro-common/include/vfs
40 STATIC_LINKING_LINK:= 0
42 TARGET_NAME := picodrive
44 GIT_REVISION ?= -$(shell git rev-parse --short HEAD || echo ???)
45 CFLAGS += -DREVISION=\"$(GIT_REVISION)\"
49 ifeq ($(STATIC_LINKING),1)
54 ifeq ($(platform), unix)
56 TARGET := $(TARGET_NAME)_libretro.$(EXT)
59 CFLAGS += -DFAMEC_NO_GOTOS
60 ifneq ($(findstring SunOS,$(shell uname -a)),)
65 else ifneq (,$(findstring x86,$(platform)))
66 TARGET := $(TARGET_NAME)_libretro.so
70 CFLAGS += -DFAMEC_NO_GOTOS
73 else ifeq ($(platform), aarch64)
74 TARGET := $(TARGET_NAME)_libretro.so
78 CFLAGS += -DFAMEC_NO_GOTOS
81 else ifeq ($(platform), linux-portable)
83 TARGET := $(TARGET_NAME)_libretro.$(EXT)
84 SHARED := -shared -nostdlib
87 CFLAGS += -DFAMEC_NO_GOTOS
90 else ifeq ($(platform), osx)
92 TARGET := $(TARGET_NAME)_libretro.$(EXT)
97 ifeq ($(CROSS_COMPILE),1)
98 TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
99 CFLAGS += $(TARGET_RULE)
100 CPPFLAGS += $(TARGET_RULE)
101 CXXFLAGS += $(TARGET_RULE)
102 LDFLAGS += $(TARGET_RULE)
105 ifndef ($(NOUNIVERSAL))
106 CFLAGS += $(ARCHFLAGS)
107 LDFLAGS += $(ARCHFLAGS)
109 CFLAGS += -DUINT8=uint8_t -DUINT16=uint16_t -DUINT32=uint32_t -DINT8=int8_t -DINT16=int16_t -DINT32=int32_t
111 else ifeq ($(platform), staticios)
112 TARGET := $(TARGET_NAME)_libretro_ios.a
115 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
117 CC = clang -arch armv7 -arch arm64 -isysroot $(IOSSDK)
118 CXX = clang++ -arch armv7 -arch arm64 -isysroot $(IOSSDK)
119 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
123 CC += -miphoneos-version-min=8.0
124 CXX += -miphoneos-version-min=8.0
125 CC_AS += -miphoneos-version-min=8.0
126 CFLAGS += -miphoneos-version-min=8.0
129 STATIC_LINKING_LINK = 1
132 else ifneq (,$(findstring ios,$(platform)))
133 TARGET := $(TARGET_NAME)_libretro_ios.dylib
134 SHARED := -dynamiclib
139 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
141 ifeq ($(platform),ios-arm64)
142 CC = clang -arch arm64 -isysroot $(IOSSDK)
143 CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
144 CFLAGS += -marm -DARM -D__aarch64__=1
146 CC = clang -arch armv7 -isysroot $(IOSSDK)
147 CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
148 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
149 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
150 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
155 ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
156 MINVERSION = -miphoneos-version-min=8.0
158 MINVERSION = -miphoneos-version-min=5.0
162 CC_AS += $(MINVERSION)
163 CFLAGS += $(MINVERSION)
166 else ifeq ($(platform), tvos-arm64)
167 TARGET := $(TARGET_NAME)_libretro_tvos.dylib
168 SHARED := -dynamiclib
172 IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
174 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
175 CC = cc -arch arm64 -isysroot $(IOSSDK)
176 CXX = c++ -arch arm64 -isysroot $(IOSSDK)
177 CFLAGS += -marm -DARM -D__aarch64__=1
180 # Lightweight PS3 Homebrew SDK
181 else ifneq (,$(filter $(platform), ps3 psl1ght))
182 TARGET := $(TARGET_NAME)_libretro_$(platform).a
183 CC = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)gcc$(EXE_EXT)
184 AR = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)ar$(EXE_EXT)
185 CFLAGS += -DFAMEC_NO_GOTOS -D__PS3__
187 STATIC_LINKING_LINK = 1
188 ifeq ($(platform), psl1ght)
189 FLAGS += -D__PSL1GHT__
193 else ifeq ($(platform), psp1)
195 TARGET := $(TARGET_NAME)_libretro_$(platform).a
196 CC = psp-gcc$(EXE_EXT)
197 AR = psp-ar$(EXE_EXT)
198 CFLAGS += -DPSP -G0 -ftracer
199 CFLAGS += -I$(shell psp-config --pspsdk-path)/include
201 STATIC_LINKING_LINK = 1
204 else ifeq ($(platform), ps2)
206 TARGET := $(TARGET_NAME)_libretro_$(platform).a
207 CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT)
208 AR = mips64r5900el-ps2-elf-ar$(EXE_EXT)
209 CFLAGS += -Wall -DPS2 -D_EE -DUSE_BGR555 -DFAMEC_NO_GOTOS -DRENDER_GSKIT_PS2 -fsingle-precision-constant
210 CFLAGS += -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include
212 STATIC_LINKING_LINK = 1
215 else ifeq ($(platform), ctr)
216 TARGET := $(TARGET_NAME)_libretro_$(platform).a
217 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
218 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
219 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
220 CFLAGS += -DARM11 -D_3DS
221 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp
222 CFLAGS += -Wall -mword-relocations
223 CFLAGS += -fomit-frame-pointer -ffast-math
225 STATIC_LINKING_LINK = 1
227 OBJS += platform/libretro/3ds/3ds_utils.o platform/libretro/3ds/utils.o
230 else ifneq (,$(findstring rpi,$(platform)))
231 CFLAGS += -Wall -mword-relocations
232 CFLAGS += -fomit-frame-pointer -ffast-math
234 TARGET := $(TARGET_NAME)_libretro.so
238 ifneq (,$(findstring rpi1,$(platform)))
239 CFLAGS += -marm -mfpu=vfp -mfloat-abi=hard -march=armv6j
240 else ifneq (,$(findstring rpi2,$(platform)))
241 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
242 else ifneq (,$(findstring rpi3,$(platform)))
243 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
247 else ifeq ($(platform), vita)
248 TARGET := $(TARGET_NAME)_libretro_$(platform).a
249 CC = arm-vita-eabi-gcc$(EXE_EXT)
250 AR = arm-vita-eabi-ar$(EXE_EXT)
252 CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=hard -ffast-math
253 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
254 CFLAGS += -mword-relocations -fno-unwind-tables
255 CFLAGS += -fno-optimize-sibling-calls
257 STATIC_LINKING_LINK = 1
260 else ifeq ($(platform), xenon)
261 TARGET := $(TARGET_NAME)_libretro_xenon360.a
262 CC = xenon-gcc$(EXE_EXT)
263 AR = xenon-ar$(EXE_EXT)
264 CFLAGS += -D__LIBXENON__ -m32
267 else ifeq ($(platform), ngc)
268 TARGET := $(TARGET_NAME)_libretro_$(platform).a
269 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
270 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
271 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float
273 STATIC_LINKING_LINK = 1
276 else ifeq ($(platform), wii)
277 TARGET := $(TARGET_NAME)_libretro_$(platform).a
278 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
279 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
280 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -ffat-lto-objects
282 STATIC_LINKING_LINK = 1
285 else ifeq ($(platform), wiiu)
286 TARGET := $(TARGET_NAME)_libretro_$(platform).a
287 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
288 CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
289 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
290 CFLAGS += -DGEKKO -DWIIU -DHW_RVL -DHW_WUP -mwup -mcpu=750 -meabi -mhard-float
292 STATIC_LINKING_LINK = 1
294 # Nintendo Switch (libtransistor)
295 else ifeq ($(platform), switch)
296 TARGET := $(TARGET_NAME)_libretro_$(platform).a
297 include $(LIBTRANSISTOR_HOME)/libtransistor.mk
299 STATIC_LINKING_LINK = 1
301 # Nintendo Switch (libnx)
302 else ifeq ($(platform), libnx)
303 include $(DEVKITPRO)/libnx/switch_rules
304 TARGET := $(TARGET_NAME)_libretro_$(platform).a
305 CFLAGS += -O3 -fomit-frame-pointer -ffast-math -I$(DEVKITPRO)/libnx/include/ -fPIE -Wl,--allow-multiple-definition
306 CFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs
307 CFLAGS += -D__SWITCH__ -DHAVE_LIBNX
308 CFLAGS += -DARM -D__aarch64__=1 -march=armv8-a -mtune=cortex-a57 -mtp=soft -ffast-math -mcpu=cortex-a57+crc+fp+simd -ffunction-sections
309 CFLAGS += -Ifrontend/switch -ftree-vectorize
311 STATIC_LINKING_LINK = 1
314 else ifeq ($(platform), qnx)
316 TARGET := $(TARGET_NAME)_libretro_$(platform).so
318 CC = qcc -Vgcc_ntoarmv7le
320 CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
321 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
323 # (armv7 a7, hard point, neon based) ###
324 # NESC, SNESC, C64 mini
325 else ifeq ($(platform), classic_armv7_a7)
326 TARGET := $(TARGET_NAME)_libretro.so
328 SHARED := -shared -Wl,--no-undefined,-Bsymbolic
330 -flto=4 -fuse-linker-plugin \
331 -fdata-sections -ffunction-sections -Wl,--gc-sections \
332 -fno-stack-protector -fno-ident -fomit-frame-pointer \
333 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
334 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
335 -fmerge-all-constants -fno-math-errno \
336 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
337 CXXFLAGS += $(CFLAGS)
338 CPPFLAGS += $(CFLAGS)
342 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
343 CFLAGS += -march=armv7-a
345 CFLAGS += -march=armv7ve
346 # If gcc is 5.0 or later
347 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
348 LDFLAGS += -static-libgcc -static-libstdc++
352 # (armv8 a35, hard point, neon based) ###
353 # Playstation Classic
354 else ifeq ($(platform), classic_armv8_a35)
355 TARGET := $(TARGET_NAME)_libretro.so
357 SHARED := -shared -Wl,--no-undefined,-Bsymbolic
359 -flto -fuse-linker-plugin \
360 -fdata-sections -ffunction-sections -Wl,--gc-sections \
361 -fno-stack-protector -fno-ident -fomit-frame-pointer \
362 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
363 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
364 -fmerge-all-constants -fno-math-errno -fno-strict-aliasing \
365 -marm -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
366 CXXFLAGS += $(CFLAGS)
367 CPPFLAGS += $(CFLAGS)
371 CFLAGS += -march=armv8-a
372 LDFLAGS += -static-libgcc -static-libstdc++
374 #######################################
377 else ifeq ($(platform), arm64)
379 TARGET := $(TARGET_NAME)_libretro.$(EXT)
383 CFLAGS += -DFAMEC_NO_GOTOS
386 else ifeq ($(platform), aarch64)
387 TARGET := $(TARGET_NAME)_libretro.so
391 CFLAGS += -DFAMEC_NO_GOTOS
394 else ifneq (,$(findstring armv,$(platform)))
395 TARGET := $(TARGET_NAME)_libretro.so
396 SHARED := -shared -Wl,--no-undefined,-Bsymbolic
398 ifneq (,$(findstring cortexa5,$(platform)))
399 CFLAGS += -marm -mcpu=cortex-a5
400 ASFLAGS += -mcpu=cortex-a5
401 else ifneq (,$(findstring cortexa8,$(platform)))
402 CFLAGS += -marm -mcpu=cortex-a8
403 ASFLAGS += -mcpu=cortex-a8
404 else ifneq (,$(findstring cortexa9,$(platform)))
405 CFLAGS += -marm -mcpu=cortex-a9
406 ASFLAGS += -mcpu=cortex-a9
407 else ifneq (,$(findstring cortexa15a7,$(platform)))
408 CFLAGS += -marm -mcpu=cortex-a15.cortex-a7
409 ASFLAGS += -mcpu=cortex-a15.cortex-a7
413 ifneq (,$(findstring neon,$(platform)))
415 ASFLAGS += -mfpu=neon
417 ifneq (,$(findstring softfloat,$(platform)))
418 CFLAGS += -mfloat-abi=softfp
419 ASFLAGS += -mfloat-abi=softfp
420 else ifneq (,$(findstring hardfloat,$(platform)))
421 CFLAGS += -mfloat-abi=hard
422 ASFLAGS += -mfloat-abi=hard
424 ifeq (,$(findstring armasm,$(platform)))
429 else ifeq ($(platform), emscripten)
430 TARGET := $(TARGET_NAME)_libretro_$(platform).bc
436 else ifeq ($(platform), rs90)
437 TARGET := $(TARGET_NAME)_libretro.so
438 ifeq (,$(shell command -v $(RS90_PREFIX)mipsel-rs90-linux-uclibc-gcc 2>/dev/null))
439 # locate the toolchain for buildbot if it isn't in path or prefix not set
440 RS90_PREFIX = /opt/rs90-toolchain/usr/bin/
442 CC = $(RS90_PREFIX)mipsel-linux-gcc
443 AR = $(RS90_PREFIX)mipsel-linux-ar
444 SHARED := -shared -nostdlib
447 CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32 -D__GCW0__
448 # clear_cache uses SYNCI instead of a syscall
449 CFLAGS += -DMIPS_USE_SYNCI
453 else ifeq ($(platform), gcw0)
454 TARGET := $(TARGET_NAME)_libretro.so
455 ifeq (,$(shell command -v $(GCW0_PREFIX)mipsel-gcw0-linux-uclibc-gcc 2>/dev/null))
456 # locate the toolchain for buildbot if it isn't in path or prefix not set
457 GCW0_PREFIX = /opt/gcw0-toolchain/usr/bin/
459 CC = $(GCW0_PREFIX)mipsel-linux-gcc
460 AR = $(GCW0_PREFIX)mipsel-linux-ar
461 SHARED := -shared -nostdlib
464 CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float -D__GCW0__
465 # clear_cache uses SYNCI instead of a syscall
466 CFLAGS += -DMIPS_USE_SYNCI
469 else ifeq ($(platform), retrofw)
470 TARGET := $(TARGET_NAME)_libretro.so
471 ifeq (,$(shell command -v $(GCW0_PREFIX)mipsel-gcw0-linux-uclibc-gcc 2>/dev/null))
472 # locate the toolchain for buildbot if it isn't in path or prefix not set
473 GCW0_PREFIX = /opt/retrofw-toolchain/usr/bin/
475 CC = $(GCW0_PREFIX)mipsel-linux-gcc
476 AR = $(GCW0_PREFIX)mipsel-linux-ar
477 SHARED := -shared -nostdlib
480 CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32 -mhard-float -D__GCW0__
481 # clear_cache uses SYNCI instead of a syscall
482 CFLAGS += -DMIPS_USE_SYNCI
485 else ifeq ($(platform), miyoo)
486 TARGET := $(TARGET_NAME)_libretro.so
487 CC = /opt/miyoo/usr/bin/arm-linux-gcc
488 AR = /opt/miyoo/usr/bin/arm-linux-ar
489 SHARED := -shared -nostdlib
492 CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -D__GCW0__
496 # Windows MSVC 2017 all architectures
497 else ifneq (,$(findstring windows_msvc2017,$(platform)))
500 PlatformSuffix = $(subst windows_msvc2017_,,$(platform))
501 ifneq (,$(findstring desktop,$(PlatformSuffix)))
502 WinPartition = desktop
503 MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -FS
504 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
505 LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
506 else ifneq (,$(findstring uwp,$(PlatformSuffix)))
508 MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WINDLL -D_UNICODE -DUNICODE -D__WRL_NO_DEFAULT_LIB__ -EHsc -FS
509 LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO
510 LDLIBS += WindowsApp.lib
516 NO_ALIGN_FUNCTIONS = 1
518 CFLAGS += -DHAVE_VSNPRINTF
519 CFLAGS += $(MSVC2017CompileFlags)
520 CXXFLAGS += $(MSVC2017CompileFlags)
522 TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix))
528 reg_query = $(call filter_out2,$(subst $2,,$(shell reg query "$2" -v "$1" 2>nul)))
529 fix_path = $(subst $(SPACE),\ ,$(subst \,/,$1))
531 ProgramFiles86w := $(shell cmd //c "echo %PROGRAMFILES(x86)%")
532 ProgramFiles86 := $(shell cygpath "$(ProgramFiles86w)")
534 WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
535 WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
536 WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
537 WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
538 WindowsSdkDir := $(WindowsSdkDir)
540 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)
541 WindowsSDKVersion := $(WindowsSDKVersion)
543 VsInstallBuildTools = $(ProgramFiles86)/Microsoft Visual Studio/2017/BuildTools
544 VsInstallEnterprise = $(ProgramFiles86)/Microsoft Visual Studio/2017/Enterprise
545 VsInstallProfessional = $(ProgramFiles86)/Microsoft Visual Studio/2017/Professional
546 VsInstallCommunity = $(ProgramFiles86)/Microsoft Visual Studio/2017/Community
548 VsInstallRoot ?= $(shell if [ -d "$(VsInstallBuildTools)" ]; then echo "$(VsInstallBuildTools)"; fi)
549 ifeq ($(VsInstallRoot), )
550 VsInstallRoot = $(shell if [ -d "$(VsInstallEnterprise)" ]; then echo "$(VsInstallEnterprise)"; fi)
552 ifeq ($(VsInstallRoot), )
553 VsInstallRoot = $(shell if [ -d "$(VsInstallProfessional)" ]; then echo "$(VsInstallProfessional)"; fi)
555 ifeq ($(VsInstallRoot), )
556 VsInstallRoot = $(shell if [ -d "$(VsInstallCommunity)" ]; then echo "$(VsInstallCommunity)"; fi)
558 VsInstallRoot := $(VsInstallRoot)
560 VcCompilerToolsVer := $(shell cat "$(VsInstallRoot)/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | grep -o '[0-9\.]*')
561 VcCompilerToolsDir := $(VsInstallRoot)/VC/Tools/MSVC/$(VcCompilerToolsVer)
563 WindowsSDKSharedIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\shared")
564 WindowsSDKUCRTIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\ucrt")
565 WindowsSDKUMIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\um")
566 WindowsSDKUCRTLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\ucrt\$(TargetArchMoniker)")
567 WindowsSDKUMLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\um\$(TargetArchMoniker)")
569 # For some reason the HostX86 compiler doesn't like compiling for x64
570 # ("no such file" opening a shared library), and vice-versa.
571 # Work around it for now by using the strictly x86 compiler for x86, and x64 for x64.
572 # NOTE: What about ARM?
573 ifneq (,$(findstring x64,$(TargetArchMoniker)))
574 VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX64
576 VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX86
579 PATH := $(shell IFS=$$'\n'; cygpath "$(VCCompilerToolsBinDir)/$(TargetArchMoniker)"):$(PATH)
580 PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VsInstallRoot)/Common7/IDE")
581 INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/include")
582 LIB := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/lib/$(TargetArchMoniker)")
583 ifneq (,$(findstring uwp,$(PlatformSuffix)))
584 LIB := $(shell IFS=$$'\n'; cygpath -w "$(LIB)/store")
587 export INCLUDE := $(INCLUDE);$(WindowsSDKSharedIncludeDir);$(WindowsSDKUCRTIncludeDir);$(WindowsSDKUMIncludeDir)
588 export LIB := $(LIB);$(WindowsSDKUCRTLibDir);$(WindowsSDKUMLibDir)
589 TARGET := $(TARGET_NAME)_libretro.dll
595 TARGET := $(TARGET_NAME)_libretro.dll
598 SHARED := -shared -static-libgcc -static-libstdc++
599 CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
603 CFLAGS += -D__LIBRETRO__
605 ifeq ($(USE_LIBRETRO_VFS),1)
606 CFLAGS += -DUSE_LIBRETRO_VFS
609 ifeq ($(LOW_MEMORY), 1)
610 CFLAGS += -DLOW_MEMORY
613 ifeq ($(NO_ARM_ASM),1)
631 # turn off DRCs on Apple OSes. It needs signing and notarizing on the
632 # later versions, which picodrive isn't supporting right now.
639 ifeq ($(findstring Haiku,$(shell uname -a)),)
644 LDFLAGS += $(SHARED) $(fpic)
647 ARCH = $(shell $(CC) $(CFLAGS) -dumpmachine | awk -F '-' '{print $$1}')
655 ifneq (,$(findstring msvc,$(platform)))
656 CFLAGS += -wd4702 -wd4711 -wd4202 -wd4101
660 ifneq (,$(findstring msvc,$(platform)))
661 ifeq ($(STATIC_LINKING),1)
669 CFLAGS += -Od -Zi -DDEBUG -D_DEBUG
670 CXXFLAGS += -Od -Zi -DDEBUG -D_DEBUG
672 CFLAGS += -O0 -g -DDEBUG
673 CXXFLAGS += -O0 -g -DDEBUG
676 ifneq (,$(findstring msvc,$(platform)))
677 ifeq ($(STATIC_LINKING),1)
685 CFLAGS += -O2 -DNDEBUG
686 CXXFLAGS += -O2 -DNDEBUG
688 CFLAGS += -O3 -DNDEBUG
689 CXXFLAGS += -O3 -DNDEBUG
693 ifneq (,$(findstring msvc,$(platform)))
696 ifeq ($(STATIC_LINKING),1)
710 ifeq ($(platform), osx)
711 pico/cd/libchdr/src/libchdr_chd.o: CFLAGS += -D__MACTYPES__=1