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