Makefile.libretro 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. # Makefile for PicoDrive (libretro)
  2. SPACE :=
  3. SPACE := $(SPACE) $(SPACE)
  4. BACKSLASH :=
  5. BACKSLASH := \$(BACKSLASH)
  6. filter_out1 = $(filter-out $(firstword $1),$1)
  7. filter_out2 = $(call filter_out1,$(call filter_out1,$1))
  8. ifeq ($(platform),)
  9. platform = unix
  10. ifeq ($(shell uname -a),)
  11. platform = win
  12. else ifneq ($(findstring MINGW,$(shell uname -a)),)
  13. platform = win
  14. else ifneq ($(findstring Darwin,$(shell uname -a)),)
  15. platform = osx
  16. else ifneq ($(findstring win,$(shell uname -a)),)
  17. platform = win
  18. endif
  19. endif
  20. CC ?= gcc
  21. CXX ?= g++
  22. AS ?= as
  23. CC_AS ?= $(CC)
  24. CFLAGS ?=
  25. #libretro includes
  26. CFLAGS += -I platform/libretro/libretro-common/include
  27. CFLAGS += -I platform/libretro/libretro-common/include/compat
  28. CFLAGS += -I platform/libretro/libretro-common/include/encodings
  29. CFLAGS += -I platform/libretro/libretro-common/include/streams
  30. CFLAGS += -I platform/libretro/libretro-common/include/string
  31. CFLAGS += -I platform/libretro/libretro-common/include/vfs
  32. STATIC_LINKING:= 0
  33. TARGET_NAME := picodrive
  34. LIBM := -lm
  35. GIT_VERSION ?= $(shell git rev-parse --short HEAD || echo unknown)
  36. ifneq ($(GIT_VERSION),"unknown")
  37. CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
  38. endif
  39. fpic :=
  40. ifeq ($(STATIC_LINKING),1)
  41. EXT=a
  42. endif
  43. # Unix
  44. ifeq ($(platform), unix)
  45. EXT ?= so
  46. TARGET := $(TARGET_NAME)_libretro.$(EXT)
  47. fpic := -fPIC
  48. SHARED := -shared
  49. CFLAGS += -DFAMEC_NO_GOTOS
  50. ifneq ($(findstring SunOS,$(shell uname -a)),)
  51. CC=gcc
  52. endif
  53. # Portable Linux
  54. else ifeq ($(platform), linux-portable)
  55. EXT ?= so
  56. TARGET := $(TARGET_NAME)_libretro.$(EXT)
  57. SHARED := -shared -nostdlib
  58. fpic := -fPIC
  59. LIBM :=
  60. CFLAGS += -DFAMEC_NO_GOTOS
  61. # OS X
  62. else ifeq ($(platform), osx)
  63. EXT ?= dylib
  64. TARGET := $(TARGET_NAME)_libretro.$(EXT)
  65. SHARED := -dynamiclib
  66. fpic := -fPIC
  67. APPLE := 1
  68. ifeq ($(shell uname -p),powerpc)
  69. CFLAGS += -DHAVE_NO_LANGEXTRA
  70. CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
  71. endif
  72. OSXVER = `sw_vers -productVersion | cut -d. -f 2`
  73. OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
  74. SHARED += -mmacosx-version-min=10.6
  75. else ifeq ($(platform), staticios)
  76. TARGET := $(TARGET_NAME)_libretro_ios.a
  77. APPLE := 1
  78. ifeq ($(IOSSDK),)
  79. IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
  80. endif
  81. CC = clang -arch armv7 -arch arm64 -isysroot $(IOSSDK)
  82. CXX = clang++ -arch armv7 -arch arm64 -isysroot $(IOSSDK)
  83. CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
  84. CFLAGS += -marm
  85. CFLAGS += -DIOS
  86. CC += -miphoneos-version-min=8.0
  87. CXX += -miphoneos-version-min=8.0
  88. CC_AS += -miphoneos-version-min=8.0
  89. CFLAGS += -miphoneos-version-min=8.0
  90. STATIC_LINKING = 1
  91. # iOS
  92. else ifneq (,$(findstring ios,$(platform)))
  93. TARGET := $(TARGET_NAME)_libretro_ios.dylib
  94. SHARED := -dynamiclib
  95. fpic := -fPIC
  96. APPLE := 1
  97. ifeq ($(IOSSDK),)
  98. IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
  99. endif
  100. ifeq ($(platform),ios-arm64)
  101. CC = clang -arch arm64 -isysroot $(IOSSDK)
  102. CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
  103. CFLAGS += -marm -DARM -D__aarch64__=1
  104. else
  105. CC = clang -arch armv7 -isysroot $(IOSSDK)
  106. CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
  107. CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
  108. CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
  109. ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
  110. NO_ARM_ASM = 1
  111. endif
  112. CFLAGS += -DIOS
  113. ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
  114. CC += -miphoneos-version-min=8.0
  115. CXX += -miphoneos-version-min=8.0
  116. CC_AS += -miphoneos-version-min=8.0
  117. CFLAGS += -miphoneos-version-min=8.0
  118. else
  119. CC += -miphoneos-version-min=5.0
  120. CXX += -miphoneos-version-min=5.0
  121. CC_AS += -miphoneos-version-min=5.0
  122. CFLAGS += -miphoneos-version-min=5.0
  123. endif
  124. # tvOS
  125. else ifeq ($(platform), tvos-arm64)
  126. TARGET := $(TARGET_NAME)_libretro_tvos.dylib
  127. SHARED := -dynamiclib
  128. fpic := -fPIC
  129. APPLE := 1
  130. ifeq ($(IOSSDK),)
  131. IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
  132. endif
  133. CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
  134. CC = clang -arch arm64 -isysroot $(IOSSDK)
  135. CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
  136. CFLAGS += -marm -DARM -D__aarch64__=1
  137. CFLAGS += -DIOS
  138. # PS3
  139. else ifeq ($(platform), ps3)
  140. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  141. CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
  142. AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
  143. CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
  144. STATIC_LINKING = 1
  145. NO_MMAP = 1
  146. # sncps3
  147. else ifeq ($(platform), sncps3)
  148. ARCH = powerpc
  149. TARGET := $(TARGET_NAME)_libretro_ps3.a
  150. CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
  151. AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
  152. CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
  153. STATIC_LINKING = 1
  154. NO_MMAP = 1
  155. # Lightweight PS3 Homebrew SDK
  156. else ifeq ($(platform), psl1ght)
  157. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  158. CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
  159. AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
  160. CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
  161. STATIC_LINKING = 1
  162. NO_MMAP = 1
  163. # PSP
  164. else ifeq ($(platform), psp1)
  165. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  166. CC = psp-gcc$(EXE_EXT)
  167. AR = psp-ar$(EXE_EXT)
  168. CFLAGS += -G0 -ftracer
  169. CFLAGS += -DPSP
  170. STATIC_LINKING = 1
  171. NO_MMAP = 1
  172. asm_render = 1
  173. # PS2
  174. else ifeq ($(platform), ps2)
  175. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  176. CC = ee-gcc$(EXE_EXT)
  177. AR = ee-ar$(EXE_EXT)
  178. CFLAGS += -Wall -DPS2 -DUSE_BGR555 -DFAMEC_NO_GOTOS -DRENDER_GSKIT_PS2 -fsingle-precision-constant
  179. CFLAGS += -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include
  180. CFLAGS += -DHAVE_NO_LANGEXTRA
  181. STATIC_LINKING = 1
  182. NO_MMAP = 1
  183. asm_render = 1
  184. OBJS += platform/ps2/asm.o
  185. # CTR (3DS)
  186. else ifeq ($(platform), ctr)
  187. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  188. CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
  189. CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
  190. AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
  191. CFLAGS += -DARM11 -D_3DS
  192. CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp
  193. CFLAGS += -Wall -mword-relocations
  194. CFLAGS += -fomit-frame-pointer -ffast-math
  195. STATIC_LINKING = 1
  196. NO_MMAP = 1
  197. OBJS += platform/libretro/3ds/3ds_utils.o platform/libretro/3ds/utils.o
  198. # Raspberry Pi (original model) Raspbian
  199. else ifeq ($(platform), raspberrypi)
  200. CFLAGS += -marm -mfpu=vfp -mfloat-abi=hard -march=armv6j
  201. CFLAGS += -Wall -mword-relocations
  202. CFLAGS += -fomit-frame-pointer -ffast-math
  203. TARGET := $(TARGET_NAME)_libretro.so
  204. SHARED := -shared
  205. fpic := -fPIC
  206. # Vita
  207. else ifeq ($(platform), vita)
  208. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  209. CC = arm-vita-eabi-gcc$(EXE_EXT)
  210. AR = arm-vita-eabi-ar$(EXE_EXT)
  211. CFLAGS += -DVITA
  212. CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=hard -ffast-math
  213. CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
  214. CFLAGS += -mword-relocations -fno-unwind-tables
  215. CFLAGS += -fno-optimize-sibling-calls
  216. STATIC_LINKING = 1
  217. NO_MMAP = 1
  218. # Xbox 360
  219. else ifeq ($(platform), xenon)
  220. TARGET := $(TARGET_NAME)_libretro_xenon360.a
  221. CC = xenon-gcc$(EXE_EXT)
  222. AR = xenon-ar$(EXE_EXT)
  223. CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
  224. # Nintendo Game Cube
  225. else ifeq ($(platform), ngc)
  226. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  227. CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
  228. AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
  229. CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
  230. # Nintendo Wii
  231. else ifeq ($(platform), wii)
  232. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  233. CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
  234. AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
  235. CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
  236. # Nintendo Wii U
  237. else ifeq ($(platform), wiiu)
  238. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  239. CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
  240. CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
  241. AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
  242. COMMONFLAGS += -DGEKKO -DWIIU -DHW_RVL -mwup -mcpu=750 -meabi -mhard-float -D__POWERPC__ -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1 -I./deps/include/
  243. COMMONFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
  244. # Nintendo Switch (libtransistor)
  245. else ifeq ($(platform), switch)
  246. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  247. include $(LIBTRANSISTOR_HOME)/libtransistor.mk
  248. STATIC_LINKING=1
  249. NO_MMAP = 1
  250. # Nintendo Switch (libnx)
  251. else ifeq ($(platform), libnx)
  252. include $(DEVKITPRO)/libnx/switch_rules
  253. TARGET := $(TARGET_NAME)_libretro_$(platform).a
  254. CFLAGS += -O3 -fomit-frame-pointer -ffast-math -I$(DEVKITPRO)/libnx/include/ -fPIE -Wl,--allow-multiple-definition
  255. CFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs
  256. CFLAGS += -D__SWITCH__ -DHAVE_LIBNX
  257. CFLAGS += -DARM -D__aarch64__=1 -march=armv8-a -mtune=cortex-a57 -mtp=soft -ffast-math -mcpu=cortex-a57+crc+fp+simd -ffunction-sections
  258. CFLAGS += -Ifrontend/switch -ftree-vectorize
  259. STATIC_LINKING=1
  260. # QNX
  261. else ifeq ($(platform), qnx)
  262. TARGET := $(TARGET_NAME)_libretro_$(platform).so
  263. fpic := -fPIC
  264. CC = qcc -Vgcc_ntoarmv7le
  265. CC_AS = $(CC)
  266. CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
  267. ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
  268. ARCH = arm
  269. # (armv7 a7, hard point, neon based) ###
  270. # NESC, SNESC, C64 mini
  271. else ifeq ($(platform), classic_armv7_a7)
  272. TARGET := $(TARGET_NAME)_libretro.so
  273. fpic := -fPIC
  274. SHARED := -shared -Wl,--no-undefined,-Bsymbolic
  275. CFLAGS += -Ofast \
  276. -flto=4 -fwhole-program -fuse-linker-plugin \
  277. -fdata-sections -ffunction-sections -Wl,--gc-sections \
  278. -fno-stack-protector -fno-ident -fomit-frame-pointer \
  279. -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
  280. -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
  281. -fmerge-all-constants -fno-math-errno \
  282. -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
  283. CXXFLAGS += $(CFLAGS)
  284. CPPFLAGS += $(CFLAGS)
  285. ASFLAGS += $(CFLAGS)
  286. HAVE_NEON = 1
  287. BUILTIN_GPU = neon
  288. ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
  289. CFLAGS += -march=armv7-a
  290. else
  291. CFLAGS += -march=armv7ve
  292. # If gcc is 5.0 or later
  293. ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
  294. LDFLAGS += -static-libgcc -static-libstdc++
  295. endif
  296. endif
  297. # (armv8 a35, hard point, neon based) ###
  298. # Playstation Classic
  299. else ifeq ($(platform), classic_armv8_a35)
  300. TARGET := $(TARGET_NAME)_libretro.so
  301. fpic := -fPIC
  302. SHARED := -shared -Wl,--no-undefined,-Bsymbolic
  303. CFLAGS += -Ofast \
  304. -flto -fwhole-program -fuse-linker-plugin \
  305. -fdata-sections -ffunction-sections -Wl,--gc-sections \
  306. -fno-stack-protector -fno-ident -fomit-frame-pointer \
  307. -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
  308. -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
  309. -fmerge-all-constants -fno-math-errno -fno-strict-aliasing \
  310. -marm -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
  311. CXXFLAGS += $(CFLAGS)
  312. CPPFLAGS += $(CFLAGS)
  313. ASFLAGS += $(CFLAGS)
  314. HAVE_NEON = 1
  315. BUILTIN_GPU = neon
  316. CFLAGS += -march=armv8-a
  317. LDFLAGS += -static-libgcc -static-libstdc++
  318. #######################################
  319. # ARM-64
  320. else ifeq ($(platform), arm64)
  321. EXT ?= so
  322. TARGET := $(TARGET_NAME)_libretro.$(EXT)
  323. ARCH = aarch64
  324. fpic := -fPIC
  325. SHARED := -shared
  326. CFLAGS += -DFAMEC_NO_GOTOS
  327. # AARCH64 generic
  328. else ifeq ($(platform), aarch64)
  329. TARGET := $(TARGET_NAME)_libretro.so
  330. ARCH = aarch64
  331. fpic := -fPIC
  332. SHARED := -shared
  333. CFLAGS += -DFAMEC_NO_GOTOS
  334. # ARM
  335. else ifneq (,$(findstring armv,$(platform)))
  336. TARGET := $(TARGET_NAME)_libretro.so
  337. SHARED := -shared -Wl,--no-undefined,-Bsymbolic
  338. fpic := -fPIC
  339. ifneq (,$(findstring cortexa5,$(platform)))
  340. CFLAGS += -marm -mcpu=cortex-a5
  341. ASFLAGS += -mcpu=cortex-a5
  342. else ifneq (,$(findstring cortexa8,$(platform)))
  343. CFLAGS += -marm -mcpu=cortex-a8
  344. ASFLAGS += -mcpu=cortex-a8
  345. else ifneq (,$(findstring cortexa9,$(platform)))
  346. CFLAGS += -marm -mcpu=cortex-a9
  347. ASFLAGS += -mcpu=cortex-a9
  348. else ifneq (,$(findstring cortexa15a7,$(platform)))
  349. CFLAGS += -marm -mcpu=cortex-a15.cortex-a7
  350. ASFLAGS += -mcpu=cortex-a15.cortex-a7
  351. else
  352. CFLAGS += -marm
  353. endif
  354. ifneq (,$(findstring neon,$(platform)))
  355. CFLAGS += -mfpu=neon
  356. ASFLAGS += -mfpu=neon
  357. endif
  358. ifneq (,$(findstring softfloat,$(platform)))
  359. CFLAGS += -mfloat-abi=softfp
  360. ASFLAGS += -mfloat-abi=softfp
  361. else ifneq (,$(findstring hardfloat,$(platform)))
  362. CFLAGS += -mfloat-abi=hard
  363. ASFLAGS += -mfloat-abi=hard
  364. endif
  365. ifeq (,$(findstring armasm,$(platform)))
  366. NO_ARM_ASM = 1
  367. endif
  368. # Emscripten
  369. else ifeq ($(platform), emscripten)
  370. TARGET := $(TARGET_NAME)_libretro_$(platform).bc
  371. ARCH = unknown
  372. # GCW0
  373. else ifeq ($(platform), gcw0)
  374. TARGET := $(TARGET_NAME)_libretro.so
  375. CC = mipsel-linux-gcc
  376. AR = mipsel-linux-ar
  377. SHARED := -shared -nostdlib
  378. fpic := -fPIC
  379. LIBM :=
  380. CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float
  381. # Windows MSVC 2017 all architectures
  382. else ifneq (,$(findstring windows_msvc2017,$(platform)))
  383. NO_GCC := 1
  384. PlatformSuffix = $(subst windows_msvc2017_,,$(platform))
  385. ifneq (,$(findstring desktop,$(PlatformSuffix)))
  386. WinPartition = desktop
  387. MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -FS
  388. 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
  389. LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
  390. else ifneq (,$(findstring uwp,$(PlatformSuffix)))
  391. WinPartition = uwp
  392. MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WINDLL -D_UNICODE -DUNICODE -D__WRL_NO_DEFAULT_LIB__ -EHsc -FS
  393. LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO
  394. LDLIBS += WindowsApp.lib
  395. endif
  396. ARCH = x86_64
  397. SHARED :=
  398. LIBM :=
  399. USE_LIBRETRO_VFS = 1
  400. NO_ALIGN_FUNCTIONS = 1
  401. CFLAGS += -DHAVE_VSNPRINTF
  402. CFLAGS += $(MSVC2017CompileFlags)
  403. CXXFLAGS += $(MSVC2017CompileFlags)
  404. TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix))
  405. CC = cl.exe
  406. CXX = cl.exe
  407. LD = link.exe
  408. reg_query = $(call filter_out2,$(subst $2,,$(shell reg query "$2" -v "$1" 2>nul)))
  409. fix_path = $(subst $(SPACE),\ ,$(subst \,/,$1))
  410. ProgramFiles86w := $(shell cmd //c "echo %PROGRAMFILES(x86)%")
  411. ProgramFiles86 := $(shell cygpath "$(ProgramFiles86w)")
  412. WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
  413. WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
  414. WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
  415. WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
  416. WindowsSdkDir := $(WindowsSdkDir)
  417. 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)
  418. WindowsSDKVersion := $(WindowsSDKVersion)
  419. VsInstallBuildTools = $(ProgramFiles86)/Microsoft Visual Studio/2017/BuildTools
  420. VsInstallEnterprise = $(ProgramFiles86)/Microsoft Visual Studio/2017/Enterprise
  421. VsInstallProfessional = $(ProgramFiles86)/Microsoft Visual Studio/2017/Professional
  422. VsInstallCommunity = $(ProgramFiles86)/Microsoft Visual Studio/2017/Community
  423. VsInstallRoot ?= $(shell if [ -d "$(VsInstallBuildTools)" ]; then echo "$(VsInstallBuildTools)"; fi)
  424. ifeq ($(VsInstallRoot), )
  425. VsInstallRoot = $(shell if [ -d "$(VsInstallEnterprise)" ]; then echo "$(VsInstallEnterprise)"; fi)
  426. endif
  427. ifeq ($(VsInstallRoot), )
  428. VsInstallRoot = $(shell if [ -d "$(VsInstallProfessional)" ]; then echo "$(VsInstallProfessional)"; fi)
  429. endif
  430. ifeq ($(VsInstallRoot), )
  431. VsInstallRoot = $(shell if [ -d "$(VsInstallCommunity)" ]; then echo "$(VsInstallCommunity)"; fi)
  432. endif
  433. VsInstallRoot := $(VsInstallRoot)
  434. VcCompilerToolsVer := $(shell cat "$(VsInstallRoot)/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | grep -o '[0-9\.]*')
  435. VcCompilerToolsDir := $(VsInstallRoot)/VC/Tools/MSVC/$(VcCompilerToolsVer)
  436. WindowsSDKSharedIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\shared")
  437. WindowsSDKUCRTIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\ucrt")
  438. WindowsSDKUMIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\um")
  439. WindowsSDKUCRTLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\ucrt\$(TargetArchMoniker)")
  440. WindowsSDKUMLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\um\$(TargetArchMoniker)")
  441. # For some reason the HostX86 compiler doesn't like compiling for x64
  442. # ("no such file" opening a shared library), and vice-versa.
  443. # Work around it for now by using the strictly x86 compiler for x86, and x64 for x64.
  444. # NOTE: What about ARM?
  445. ifneq (,$(findstring x64,$(TargetArchMoniker)))
  446. VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX64
  447. else
  448. VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX86
  449. endif
  450. PATH := $(shell IFS=$$'\n'; cygpath "$(VCCompilerToolsBinDir)/$(TargetArchMoniker)"):$(PATH)
  451. PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VsInstallRoot)/Common7/IDE")
  452. INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/include")
  453. LIB := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/lib/$(TargetArchMoniker)")
  454. ifneq (,$(findstring uwp,$(PlatformSuffix)))
  455. LIB := $(shell IFS=$$'\n'; cygpath -w "$(LIB)/store")
  456. endif
  457. export INCLUDE := $(INCLUDE);$(WindowsSDKSharedIncludeDir);$(WindowsSDKUCRTIncludeDir);$(WindowsSDKUMIncludeDir)
  458. export LIB := $(LIB);$(WindowsSDKUCRTLibDir);$(WindowsSDKUMLibDir)
  459. TARGET := $(TARGET_NAME)_libretro.dll
  460. PSS_STYLE :=2
  461. LDFLAGS += -DLL
  462. # Windows
  463. else
  464. TARGET := $(TARGET_NAME)_libretro.dll
  465. CC = gcc
  466. fpic := -fPIC
  467. SHARED := -shared -static-libgcc -static-libstdc++
  468. CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
  469. endif
  470. CFLAGS += -DNO_ZLIB -D__LIBRETRO__
  471. ifeq ($(USE_LIBRETRO_VFS),1)
  472. NO_MMAP = 1
  473. CFLAGS += -DUSE_LIBRETRO_VFS
  474. endif
  475. ifeq ($(NO_MMAP),1)
  476. CFLAGS += -DNO_MMAP
  477. endif
  478. ifeq ($(NO_ARM_ASM),1)
  479. use_cyclone = 0
  480. use_fame = 1
  481. use_drz80 = 0
  482. use_cz80 = 1
  483. use_svpdrc = 0
  484. asm_memory = 0
  485. asm_render = 0
  486. asm_ym2612 = 0
  487. asm_misc = 0
  488. asm_cdmemory = 0
  489. asm_mix = 0
  490. asm_32xdraw = 0
  491. asm_32xmemory = 0
  492. endif
  493. CFLAGS += $(fpic)
  494. ifeq ($(findstring Haiku,$(shell uname -a)),)
  495. LDLIBS += $(LIBM)
  496. endif
  497. SHARED ?= -shared
  498. LDFLAGS += $(SHARED) $(fpic)
  499. ifeq ($(ARCH),)
  500. ARCH = $(shell $(CC) -dumpmachine | awk -F '-' '{print $$1}')
  501. endif
  502. PLATFORM = libretro
  503. NO_CONFIG_MAK = yes
  504. OBJOUT = -o
  505. LINKOUT = -o
  506. ifneq (,$(findstring msvc,$(platform)))
  507. CFLAGS += -wd4702 -wd4711 -wd4202 -wd4101
  508. endif
  509. ifeq ($(DEBUG), 1)
  510. ifneq (,$(findstring msvc,$(platform)))
  511. ifeq ($(STATIC_LINKING),1)
  512. CFLAGS += -MTd
  513. CXXFLAGS += -MTd
  514. else
  515. CFLAGS += -MDd
  516. CXXFLAGS += -MDd
  517. endif
  518. CFLAGS += -Od -Zi -DDEBUG -D_DEBUG
  519. CXXFLAGS += -Od -Zi -DDEBUG -D_DEBUG
  520. else
  521. CFLAGS += -O0 -g -DDEBUG
  522. CXXFLAGS += -O0 -g -DDEBUG
  523. endif
  524. else
  525. ifneq (,$(findstring msvc,$(platform)))
  526. ifeq ($(STATIC_LINKING),1)
  527. CFLAGS += -MT
  528. CXXFLAGS += -MT
  529. else
  530. CFLAGS += -MD
  531. CXXFLAGS += -MD
  532. endif
  533. CFLAGS += -O2 -DNDEBUG
  534. CXXFLAGS += -O2 -DNDEBUG
  535. else
  536. CFLAGS += -O3 -DNDEBUG
  537. CXXFLAGS += -O3 -DNDEBUG
  538. endif
  539. endif
  540. ifneq (,$(findstring msvc,$(platform)))
  541. OBJOUT = -Fo
  542. LINKOUT = -out:
  543. ifeq ($(STATIC_LINKING),1)
  544. LD ?= lib.exe
  545. STATIC_LINKING=0
  546. else
  547. LD = link.exe
  548. endif
  549. else
  550. LD = $(CC)
  551. endif
  552. include Makefile