1DEBUG = 0 2HAVE_CHD = 1 3THREADED_DSP=0 4HAVE_CDROM = 0 5 6ifeq ($(platform),) 7platform = unix 8 ifeq ($(shell uname -a),) 9 platform = win 10 else ifneq ($(findstring Darwin,$(shell uname -a)),) 11 platform = osx 12 arch = intel 13 ifeq ($(shell uname -p),powerpc) 14 arch = ppc 15 endif 16 else ifneq ($(findstring MINGW,$(shell uname -a)),) 17 platform = win 18 endif 19endif 20 21# system platform 22system_platform = unix 23ifeq ($(shell uname -a),) 24 EXE_EXT = .exe 25 system_platform = win 26else ifneq ($(findstring Darwin,$(shell uname -a)),) 27 system_platform = osx 28 arch = intel 29 ifeq ($(shell uname -p),powerpc) 30 arch = ppc 31 endif 32else ifneq ($(findstring MINGW,$(shell uname -a)),) 33 system_platform = win 34endif 35 36TARGET_NAME := opera 37GIT_VERSION ?= " $(shell git rev-parse --short HEAD || echo unknown)" 38ifneq ($(GIT_VERSION)," unknown") 39 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" 40endif 41 42SPACE := 43SPACE := $(SPACE) $(SPACE) 44BACKSLASH := 45BACKSLASH := \$(BACKSLASH) 46filter_out1 = $(filter-out $(firstword $1),$1) 47filter_out2 = $(call filter_out1,$(call filter_out1,$1)) 48unixpath = $(subst \,/,$1) 49unixcygpath = /$(subst :,,$(call unixpath,$1)) 50 51ifneq (,$(findstring unix,$(platform))) 52 AR = ${CC_PREFIX}ar 53 54 TARGET := $(TARGET_NAME)_libretro.so 55 fpic := -fPIC 56 ifneq ($(findstring SunOS,$(shell uname -s)),) 57 SHARED := -shared -lpthread -lm -z defs 58 else 59 SHARED := -lpthread -lm -shared -Wl,--no-undefined -Wl,--version-script=link.T 60 ifneq ($(findstring Linux,$(shell uname -s)),) 61 HAVE_CDROM = 1 62 endif 63 endif 64 65 THREADED_DSP = 1 66 67 # Raspberry Pi 68 ifneq (,$(findstring rpi,$(platform))) 69 CFLAGS += -fomit-frame-pointer -ffast-math -DARM -marm -mfloat-abi=hard 70 71 # Pi (original) 72 ifneq (,$(findstring rpi1,$(platform))) 73 CFLAGS = -mcpu=cortex-a6j 74 # Pi2 75 else ifneq (,$(findstring rpi2,$(platform))) 76 CFLAGS = -mcpu=cortex-a7 77 # Pi3 78 else ifneq (,$(findstring rpi3,$(platform))) 79 CFLAGS = -mcpu=cortex-a53 80 # Pi4 81 else ifneq (,$(findstring rpi4,$(platform))) 82 CFLAGS = -mcpu=cortex-a72 83 endif 84 85 # ODROIDN2 86 else ifneq (,$(findstring CortexA73_G12B,$(platform))) 87 CFLAGS += -fomit-frame-pointer -ffast-math 88 CPUFLAGS += -march=armv8-a+crc -mfpu=neon-fp-armv8 -mcpu=cortex-a73 -mtune=cortex-a73.cortex-a53 89 90 # ODROIDs 91 else ifneq (,$(findstring odroid,$(platform))) 92 CFLAGS += -fomit-frame-pointer -ffast-math -DARM -marm -mfloat-abi=hard 93 94 # ODROID-C1 95 ifneq (,$(findstring odroidc,$(platform))) 96 CFLAGS += -mtune=cortex-a5 97 # ODROID-XU3 & ODROID-XU4 98 else ifneq (,$(findstring odroidxu,$(platform))) 99 CFLAGS += -march=armv7ve -mtune=cortex-a15.cortex-a7 100 # ODROID-U2, -U3, -X & -X2 101 else 102 CFLAGS += -mtune=cortex-a9 103 endif 104 endif 105 106# Classic Platforms #################### 107# Platform affix = classic_<ISA>_<µARCH> 108# Help at https://modmyclassic.com/comp 109 110# (armv7 a7, hard point, neon based) ### 111# NESC, SNESC, C64 mini 112else ifeq ($(platform), classic_armv7_a7) 113 TARGET := $(TARGET_NAME)_libretro.so 114 fpic := -fPIC 115 SHARED := -lpthread -lm -shared -Wl,--no-undefined -Wl,--version-script=link.T 116 CFLAGS += -Ofast \ 117 -flto=4 -fwhole-program -fuse-linker-plugin \ 118 -fdata-sections -ffunction-sections -Wl,--gc-sections \ 119 -fno-stack-protector -fno-ident -fomit-frame-pointer \ 120 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ 121 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ 122 -fmerge-all-constants -fno-math-errno \ 123 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard 124 HAVE_NEON = 1 125 ARCH = arm 126 THREADED_DSP = 1 127 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1) 128 CFLAGS += -march=armv7-a 129 else 130 CFLAGS += -march=armv7ve 131 # If gcc is 5.0 or later 132 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1) 133 LDFLAGS += -static-libgcc -static-libstdc++ 134 endif 135 endif 136####################################### 137 138# ARM 139else ifneq (,$(findstring armv,$(platform))) 140 AR = ${CC_PREFIX}ar 141 CC = ${CC_PREFIX}gcc 142 143 TARGET := $(TARGET_NAME)_libretro.so 144 fpic := -fPIC 145 SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T 146 147else ifeq ($(platform), osx) 148 TARGET := $(TARGET_NAME)_libretro.dylib 149 fpic := -fPIC 150 SHARED := -dynamiclib 151 152ifeq ($(arch),ppc) 153 FLAGS += -DMSB_FIRST 154 OLD_GCC = 1 155endif 156 OSXVER = `sw_vers -productVersion | cut -d. -f 2` 157 OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"` 158ifeq ($(OSX_LT_MAVERICKS),YES) 159 fpic += -mmacosx-version-min=10.1 160endif 161ifeq ($(CROSS_COMPILE),1) 162 TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT) 163 CFLAGS += $(TARGET_RULE) 164 LDFLAGS += $(TARGET_RULE) 165endif 166ifndef ($(NOUNIVERSAL)) 167 FLAGS += $(ARCHFLAGS) 168 LDFLAGS += $(ARCHFLAGS) 169endif 170 171# iOS 172else ifneq (,$(findstring ios,$(platform))) 173 174 TARGET := $(TARGET_NAME)_libretro_ios.dylib 175 fpic := -fPIC 176 SHARED := -dynamiclib 177 178ifeq ($(IOSSDK),) 179 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) 180endif 181ifeq ($(platform),ios-arm64) 182 CC = cc -arch arm64 -isysroot $(IOSSDK) 183else 184 CC = cc -arch armv7 -isysroot $(IOSSDK) 185endif 186ifeq ($(platform),$(filter $(platform),ios9 ios-arm64)) 187 SHARED += -miphoneos-version-min=8.0 188 CC += -miphoneos-version-min=8.0 189else 190 SHARED += -miphoneos-version-min=5.0 191 CC += -miphoneos-version-min=5.0 192endif 193else ifeq ($(platform), tvos-arm64) 194 195 TARGET := $(TARGET_NAME)_libretro_tvos.dylib 196 fpic := -fPIC 197 SHARED := -dynamiclib 198ifeq ($(IOSSDK),) 199 IOSSDK := $(shell xcodebuild -version -sdk appletvos Path) 200endif 201 202else ifeq ($(platform), theos_ios) 203DEPLOYMENT_IOSVERSION = 5.0 204TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION) 205ARCHS = armv7 armv7s 206TARGET_IPHONEOS_DEPLOYMENT_VERSION=$(DEPLOYMENT_IOSVERSION) 207THEOS_BUILD_DIR := objs 208include $(THEOS)/makefiles/common.mk 209 210LIBRARY_NAME = $(TARGET_NAME)_libretro_ios 211else ifeq ($(platform), qnx) 212 TARGET := $(TARGET_NAME)_libretro_$(platform).so 213 fpic := -fPIC 214 SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T 215 CC = qcc -Vgcc_ntoarmv7le 216else ifeq ($(platform), ps3) 217 TARGET := $(TARGET_NAME)_libretro_$(platform).a 218 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe 219 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe 220 STATIC_LINKING = 1 221 FLAGS += -DMSB_FIRST -D__CELLOS_LV2__ 222 OLD_GCC = 1 223else ifeq ($(platform), sncps3) 224 TARGET := $(TARGET_NAME)_libretro_ps3.a 225 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe 226 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe 227 STATIC_LINKING = 1 228 FLAGS += -DMSB_FIRST 229 NO_GCC = 1 230 231# PSP1 232else ifeq ($(platform), psp1) 233 TARGET := $(TARGET_NAME)_libretro_$(platform).a 234 CC = psp-gcc$(EXE_EXT) 235 AR = psp-ar$(EXE_EXT) 236 STATIC_LINKING = 1 237 FLAGS += -G0 238 239# Vita 240else ifeq ($(platform), vita) 241 TARGET := $(TARGET_NAME)_libretro_$(platform).a 242 CC = arm-vita-eabi-gcc$(EXE_EXT) 243 AR = arm-vita-eabi-ar$(EXE_EXT) 244 STATIC_LINKING = 1 245 FLAGS += -DVITA 246 247# CTR (3DS) 248else ifeq ($(platform), ctr) 249 TARGET := $(TARGET_NAME)_libretro_$(platform).a 250 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT) 251 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT) 252 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT) 253 FLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard 254 FLAGS += -Wall -mword-relocations 255 FLAGS += -fomit-frame-pointer -ffast-math 256 FLAGS += -DARM11 -D_3DS 257 STATIC_LINKING = 1 258 259# Nintendo Switch (libtransistor) 260else ifeq ($(platform), switch) 261 TARGET := $(TARGET_NAME)_libretro_$(platform).a 262 include $(LIBTRANSISTOR_HOME)/libtransistor.mk 263 STATIC_LINKING=1 264 265# Nintendo Switch (libnx) 266else ifeq ($(platform), libnx) 267 include $(DEVKITPRO)/libnx/switch_rules 268 EXT=a 269 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT) 270 DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL 271 CFLAGS := $(DEFINES) -g \ 272 -O2 \ 273 -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs 274 CFLAGS += $(INCDIRS) 275 CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX 276 CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 277 CFLAGS += -std=gnu11 278 # Static CHD workaround 279 CFLAGS += -Dintfstream_internal=intfstream_internal_core \ 280 -Dintfstream_internal_t=intfstream_internal_t_core \ 281 -Dintfstream_init=intfstream_init_core \ 282 -Dintfstream_resize=intfstream_resize_core \ 283 -Dintfstream_open=intfstream_open_core \ 284 -Dintfstream_read=intfstream_read_core \ 285 -Dintfstream_write=intfstream_write_core \ 286 -Dintfstream_gets=intfstream_gets_core \ 287 -Dintfstream_getc=intfstream_getc_core \ 288 -Dintfstream_seek=intfstream_seek_core \ 289 -Dintfstream_rewind=intfstream_rewind_core \ 290 -Dintfstream_tell=intfstream_tell_core \ 291 -Dintfstream_putc=intfstream_putc_core \ 292 -Dintfstream_close=intfstream_close_core \ 293 -Dintfstream_get_size=intfstream_get_size_core \ 294 -Dintfstream_flush=intfstream_flush_core \ 295 -Dintfstream_open_file=intfstream_open_file_core \ 296 -Dintfstream_open_memory=intfstream_open_memory_core \ 297 -Dintfstream_open_chd_track=intfstream_open_chd_track_core 298 STATIC_LINKING = 1 299 HAVE_CHD = 1 300 HAVE_LIBNX = 1 301 302# Emscripten 303else ifeq ($(platform), emscripten) 304 TARGET := $(TARGET_NAME)_libretro_$(platform).bc 305 STATIC_LINKING = 1 306 307# Windows MSVC 2003 Xbox 1 308else ifeq ($(platform), xbox1_msvc2003) 309TARGET := $(TARGET_NAME)_libretro_xdk1.lib 310CC = CL.exe 311LD = lib.exe 312 313export INCLUDE := $(XDK)/xbox/include 314export LIB := $(XDK)/xbox/lib 315PATH := $(call unixcygpath,$(XDK)/xbox/bin/vc71):$(PATH) 316PSS_STYLE :=2 317CFLAGS += -D_XBOX -D_XBOX1 318STATIC_LINKING = 1 319HAS_GCC := 0 320# Windows MSVC 2010 Xbox 360 321else ifeq ($(platform), xbox360_msvc2010) 322TARGET := $(TARGET_NAME)_libretro_xdk360.lib 323MSVCBINDIRPREFIX = $(XEDK)/bin/win32 324CC = "$(MSVCBINDIRPREFIX)/cl.exe" 325LD = "$(MSVCBINDIRPREFIX)/lib.exe" 326 327export INCLUDE := $(XEDK)/include/xbox 328export LIB := $(XEDK)/lib/xbox 329PSS_STYLE :=2 330FLAGS += -DMSB_FIRST 331CFLAGS += -D_XBOX -D_XBOX360 332STATIC_LINKING=1 333HAS_GCC := 0 334 335# Windows MSVC 2010 x64 336else ifeq ($(platform), windows_msvc2010_x64) 337 CC = cl.exe 338 339PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin/amd64"):$(PATH) 340PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE") 341LIB := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/lib/amd64") 342INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include") 343 344WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 345WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 346 347WindowsSdkDirInc := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include 348WindowsSdkDirInc ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')Include 349 350WindowsSDKIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include") 351WindowsSDKGlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\gl") 352WindowsSDKLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\x64") 353 354INCFLAGS_PLATFORM = -I"$(WindowsSDKIncludeDir)" 355export INCLUDE := $(INCLUDE);$(WindowsSDKIncludeDir);$(WindowsSDKGlIncludeDir) 356export LIB := $(LIB);$(WindowsSDKLibDir) 357TARGET := $(TARGET_NAME)_libretro.dll 358PSS_STYLE :=2 359LDFLAGS += -DLL 360WINDOWS_VERSION=1 361# Windows MSVC 2010 x86 362else ifeq ($(platform), windows_msvc2010_x86) 363 CC = cl.exe 364 365PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin"):$(PATH) 366PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE") 367LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/lib") 368INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include") 369 370WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 371WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 372 373WindowsSDKIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include") 374WindowsSDKGlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\gl") 375WindowsSDKLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib") 376 377INCFLAGS_PLATFORM = -I"$(WindowsSDKIncludeDir)" 378export INCLUDE := $(INCLUDE);$(WindowsSDKIncludeDir);$(WindowsSDKGlIncludeDir) 379export LIB := $(LIB);$(WindowsSDKLibDir) 380TARGET := $(TARGET_NAME)_libretro.dll 381PSS_STYLE :=2 382LDFLAGS += -DLL 383WINDOWS_VERSION=1 384 385# Windows MSVC 2005 x86 386else ifeq ($(platform), windows_msvc2005_x86) 387 CC = cl.exe 388 389PATH := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin"):$(PATH) 390PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../IDE") 391INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/include") 392LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS80COMNTOOLS)../../VC/lib") 393BIN := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin") 394 395WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3" -v "Install Dir" | grep -o '[A-Z]:\\.*') 396 397WindowsSDKIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include") 398WindowsSDKAtlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\atl") 399WindowsSDKCrtIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\crt") 400WindowsSDKGlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\gl") 401WindowsSDKMfcIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\mfc") 402WindowsSDKLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib") 403 404export INCLUDE := $(INCLUDE);$(WindowsSDKIncludeDir);$(WindowsSDKAtlIncludeDir);$(WindowsSDKCrtIncludeDir);$(WindowsSDKGlIncludeDir);$(WindowsSDKMfcIncludeDir);libretro-common/include/compat/msvc 405export LIB := $(LIB);$(WindowsSDKLibDir) 406TARGET := $(TARGET_NAME)_libretro.dll 407PSS_STYLE :=2 408LDFLAGS += -DLL 409CFLAGS += -D_CRT_SECURE_NO_DEPRECATE 410WINDOWS_VERSION=1 411 412# Windows MSVC 2003 x86 413else ifeq ($(platform), windows_msvc2003_x86) 414 CC = cl.exe 415 416PATH := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin"):$(PATH) 417PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../IDE") 418INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/include") 419LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS71COMNTOOLS)../../Vc7/lib") 420BIN := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin") 421 422WindowsSdkDir := $(INETSDK) 423 424export INCLUDE := $(INCLUDE);$(INETSDK)/Include;src/drivers/libretro/msvc/msvc-2005 425export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib 426TARGET := $(TARGET_NAME)_libretro.dll 427PSS_STYLE :=2 428LDFLAGS += -DLL 429CFLAGS += -D_CRT_SECURE_NO_DEPRECATE 430WINDOWS_VERSION=1 431 432# Windows MSVC 2017 all architectures 433else ifneq (,$(findstring windows_msvc2017,$(platform))) 434 435 NO_GCC := 1 436 CFLAGS += -DNOMINMAX 437 CXXFLAGS += -DNOMINMAX 438 WINDOWS_VERSION = 1 439 440 PlatformSuffix = $(subst windows_msvc2017_,,$(platform)) 441 ifneq (,$(findstring desktop,$(PlatformSuffix))) 442 WinPartition = desktop 443 MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -FS 444 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 445 LIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib 446 else ifneq (,$(findstring uwp,$(PlatformSuffix))) 447 WinPartition = uwp 448 MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WINDLL -D_UNICODE -DUNICODE -D__WRL_NO_DEFAULT_LIB__ -EHsc -FS 449 LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO 450 LIBS += WindowsApp.lib 451 endif 452 453 CFLAGS += $(MSVC2017CompileFlags) 454 CXXFLAGS += $(MSVC2017CompileFlags) 455 456 TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix)) 457 458 CC = cl.exe 459 CXX = cl.exe 460 LD = link.exe 461 462 reg_query = $(call filter_out2,$(subst $2,,$(shell reg query "$2" -v "$1" 2>nul))) 463 fix_path = $(subst $(SPACE),\ ,$(subst \,/,$1)) 464 465 ProgramFiles86w := $(shell cmd //c "echo %PROGRAMFILES(x86)%") 466 ProgramFiles86 := $(shell cygpath "$(ProgramFiles86w)") 467 468 WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0) 469 WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0) 470 WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0) 471 WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0) 472 WindowsSdkDir := $(WindowsSdkDir) 473 474 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) 475 WindowsSDKVersion := $(WindowsSDKVersion) 476 477 VsInstallBuildTools = $(ProgramFiles86)/Microsoft Visual Studio/2017/BuildTools 478 VsInstallEnterprise = $(ProgramFiles86)/Microsoft Visual Studio/2017/Enterprise 479 VsInstallProfessional = $(ProgramFiles86)/Microsoft Visual Studio/2017/Professional 480 VsInstallCommunity = $(ProgramFiles86)/Microsoft Visual Studio/2017/Community 481 482 VsInstallRoot ?= $(shell if [ -d "$(VsInstallBuildTools)" ]; then echo "$(VsInstallBuildTools)"; fi) 483 ifeq ($(VsInstallRoot), ) 484 VsInstallRoot = $(shell if [ -d "$(VsInstallEnterprise)" ]; then echo "$(VsInstallEnterprise)"; fi) 485 endif 486 ifeq ($(VsInstallRoot), ) 487 VsInstallRoot = $(shell if [ -d "$(VsInstallProfessional)" ]; then echo "$(VsInstallProfessional)"; fi) 488 endif 489 ifeq ($(VsInstallRoot), ) 490 VsInstallRoot = $(shell if [ -d "$(VsInstallCommunity)" ]; then echo "$(VsInstallCommunity)"; fi) 491 endif 492 VsInstallRoot := $(VsInstallRoot) 493 494 VcCompilerToolsVer := $(shell cat "$(VsInstallRoot)/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | grep -o '[0-9\.]*') 495 VcCompilerToolsDir := $(VsInstallRoot)/VC/Tools/MSVC/$(VcCompilerToolsVer) 496 497 WindowsSDKSharedIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\shared") 498 WindowsSDKUCRTIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\ucrt") 499 WindowsSDKUMIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\um") 500 WindowsSDKUCRTLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\ucrt\$(TargetArchMoniker)") 501 WindowsSDKUMLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\um\$(TargetArchMoniker)") 502 503 # For some reason the HostX86 compiler doesn't like compiling for x64 504 # ("no such file" opening a shared library), and vice-versa. 505 # Work around it for now by using the strictly x86 compiler for x86, and x64 for x64. 506 # NOTE: What about ARM? 507 ifneq (,$(findstring x64,$(TargetArchMoniker))) 508 VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX64 509 else 510 VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX86 511 endif 512 513 PATH := $(shell IFS=$$'\n'; cygpath "$(VCCompilerToolsBinDir)/$(TargetArchMoniker)"):$(PATH) 514 PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VsInstallRoot)/Common7/IDE") 515 INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/include") 516 LIB := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/lib/$(TargetArchMoniker)") 517 ifneq (,$(findstring uwp,$(PlatformSuffix))) 518 LIB := $(shell IFS=$$'\n'; cygpath -w "$(LIB)/store") 519 endif 520 521 export INCLUDE := $(INCLUDE);$(WindowsSDKSharedIncludeDir);$(WindowsSDKUCRTIncludeDir);$(WindowsSDKUMIncludeDir) 522 export LIB := $(LIB);$(WindowsSDKUCRTLibDir);$(WindowsSDKUMLibDir) 523 TARGET := $(TARGET_NAME)_libretro.dll 524 PSS_STYLE :=2 525 LDFLAGS += -DLL 526 527# Windows 528else 529 TARGET := $(TARGET_NAME)_libretro.dll 530 CC ?= gcc 531 SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T 532 LDFLAGS += -static-libgcc -static-libstdc++ -lwinmm 533WINDOWS_VERSION=1 534 HAVE_CDROM = 1 535endif 536 537CORE_DIR := . 538 539include $(CORE_DIR)/Makefile.common 540 541OBJECTS := $(SOURCES_C:.c=.o) 542 543OPT := -O2 544ifeq ($(DEBUG), 1) 545 ifneq (,$(findstring msvc,$(platform))) 546 OPT = -Od 547 CFLAGS += -Zi -D_DEBUG 548 CFLAGS += -MTd 549 else 550 OPT = -O0 551 CFLAGS += -ggdb -fno-omit-frame-pointer 552 endif 553 CFLAGS += -DDEBUG 554else 555 OPT = -O2 556 CFLAGS += -DNDEBUG 557 558 ifneq (,$(findstring msvc,$(platform))) 559 CFLAGS += -MT 560 endif 561endif 562 563CFLAGS += $(OPT) 564 565ifneq ($(SANITIZER),) 566 CFLAGS += -fsanitize=$(SANITIZER) 567 LDFLAGS += -fsanitize=$(SANITIZER) 568endif 569 570ifneq ($(C89_BUILD),) 571 CFLAGS += -std=c89 -ansi -pedantic 572endif 573 574ifneq ($(LTO),) 575 CFLAGS += -flto -fipa-pta 576 LDFLAGS += -flto -fipa-pta 577endif 578 579LDFLAGS += $(fpic) $(SHARED) 580FLAGS += $(fpic) 581FLAGS += $(INCFLAGS) $(INCFLAGS_PLATFORM) 582 583ifeq ($(OLD_GCC), 1) 584WARNINGS := -Wall 585else ifeq ($(NO_GCC), 1) 586WARNINGS := 587else ifneq (,$(findstring msvc,$(platform))) 588WARNINGS := 589else 590WARNINGS := -Wall \ 591 -Wno-sign-compare \ 592 -Wno-unused-variable \ 593 -Wno-unused-function \ 594 -Wno-uninitialized \ 595 -Wno-strict-aliasing \ 596 -Wno-overflow \ 597 -fno-strict-overflow 598endif 599 600FLAGS += $(COREDEFINES) -D__LIBRETRO__ $(WARNINGS) 601 602CFLAGS += $(FLAGS) 603 604OBJOUT = -o 605LINKOUT = -o 606 607ifneq (,$(findstring msvc,$(platform))) 608 OBJOUT = -Fo 609 LINKOUT = -out: 610ifeq ($(STATIC_LINKING),1) 611 LD ?= lib.exe 612 STATIC_LINKING=0 613else 614 LD = link.exe 615endif 616else 617 LD = $(CC) 618endif 619 620ifeq ($(platform), theos_ios) 621COMMON_FLAGS := -DIOS -DARM $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error 622$(LIBRARY_NAME)_CFLAGS += $(COMMON_FLAGS) $(CFLAGS) 623${LIBRARY_NAME}_FILES = $(SOURCES_C) 624include $(THEOS_MAKE_PATH)/library.mk 625else 626all: $(TARGET) 627$(TARGET): $(OBJECTS) 628ifeq ($(STATIC_LINKING), 1) 629 $(AR) rcs $@ $(OBJECTS) 630else ifneq (,$(findstring msvc,$(platform))) 631 $(LD) $(fpic) $(LINKOUT)$@ $^ $(LDFLAGS) $(LIBS) 632else 633 $(LD) $(fpic) $(LINKOUT) $@ $^ $(LDFLAGS) $(LIBS) 634endif 635 636%.o: %.c 637 $(CC) -c $(OBJOUT)$@ $< $(CFLAGS) 638 639clean: 640 rm -f $(TARGET) $(OBJECTS) 641 642.PHONY: clean 643endif 644 645print-%: 646 @echo '$*=$($*)' 647