Makefile.libretro 20 KB

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