2446536b |
1 | # Makefile for PicoDrive (libretro) |
2 | |
61d76999 |
3 | SPACE := |
4 | SPACE := $(SPACE) $(SPACE) |
5 | BACKSLASH := |
6 | BACKSLASH := \$(BACKSLASH) |
7 | filter_out1 = $(filter-out $(firstword $1),$1) |
8 | filter_out2 = $(call filter_out1,$(call filter_out1,$1)) |
9 | |
2446536b |
10 | ifeq ($(platform),) |
7612bf90 |
11 | platform = unix |
12 | ifeq ($(shell uname -a),) |
13 | platform = win |
14 | else ifneq ($(findstring MINGW,$(shell uname -a)),) |
15 | platform = win |
16 | else ifneq ($(findstring Darwin,$(shell uname -a)),) |
17 | platform = osx |
7612bf90 |
18 | else ifneq ($(findstring win,$(shell uname -a)),) |
19 | platform = win |
20 | endif |
2446536b |
21 | endif |
22 | |
23 | CC ?= gcc |
24 | CXX ?= g++ |
25 | AS ?= as |
26 | CC_AS ?= $(CC) |
27 | CFLAGS ?= |
28 | |
61d76999 |
29 | #libretro includes |
30 | CFLAGS += -I platform/libretro/libretro-common/include |
31 | CFLAGS += -I platform/libretro/libretro-common/include/compat |
32 | CFLAGS += -I platform/libretro/libretro-common/include/encodings |
5f9901e0 |
33 | CFLAGS += -I platform/libretro/libretro-common/include/formats |
61d76999 |
34 | CFLAGS += -I platform/libretro/libretro-common/include/streams |
35 | CFLAGS += -I platform/libretro/libretro-common/include/string |
36 | CFLAGS += -I platform/libretro/libretro-common/include/vfs |
37 | |
73bda1ad |
38 | USE_LIBRETRO_VFS := 1 |
a5085db3 |
39 | STATIC_LINKING:= 0 |
40 | STATIC_LINKING_LINK:= 0 |
41 | LOW_MEMORY := 0 |
2446536b |
42 | TARGET_NAME := picodrive |
7612bf90 |
43 | LIBM := -lm |
ab43a4b2 |
44 | GIT_REVISION ?= -$(shell git rev-parse --short HEAD || echo ???) |
6bd90c96 |
45 | CFLAGS += -DREVISION=\"$(GIT_REVISION)\" |
2446536b |
46 | |
7612bf90 |
47 | fpic := |
48 | |
49 | ifeq ($(STATIC_LINKING),1) |
50 | EXT=a |
51 | endif |
52 | |
53 | # Unix |
2446536b |
54 | ifeq ($(platform), unix) |
7612bf90 |
55 | EXT ?= so |
56 | TARGET := $(TARGET_NAME)_libretro.$(EXT) |
6b67b6aa |
57 | fpic := -fPIC |
7612bf90 |
58 | SHARED := -shared |
7612bf90 |
59 | CFLAGS += -DFAMEC_NO_GOTOS |
61d76999 |
60 | ifneq ($(findstring SunOS,$(shell uname -a)),) |
61 | CC=gcc |
62 | endif |
7612bf90 |
63 | |
a5085db3 |
64 | # x86/x86_64 generic |
65 | else ifneq (,$(findstring x86,$(platform))) |
66 | TARGET := $(TARGET_NAME)_libretro.so |
e8ca1082 |
67 | ARCH := x86 |
a5085db3 |
68 | fpic := -fPIC |
69 | SHARED := -shared |
a5085db3 |
70 | CFLAGS += -DFAMEC_NO_GOTOS |
71 | |
72 | # AARCH64 generic |
73 | else ifeq ($(platform), aarch64) |
74 | TARGET := $(TARGET_NAME)_libretro.so |
75 | ARCH = aarch64 |
76 | fpic := -fPIC |
77 | SHARED := -shared |
a5085db3 |
78 | CFLAGS += -DFAMEC_NO_GOTOS |
79 | |
7612bf90 |
80 | # Portable Linux |
81 | else ifeq ($(platform), linux-portable) |
82 | EXT ?= so |
83 | TARGET := $(TARGET_NAME)_libretro.$(EXT) |
84 | SHARED := -shared -nostdlib |
6b67b6aa |
85 | fpic := -fPIC |
7612bf90 |
86 | LIBM := |
7612bf90 |
87 | CFLAGS += -DFAMEC_NO_GOTOS |
88 | |
89 | # OS X |
2446536b |
90 | else ifeq ($(platform), osx) |
7612bf90 |
91 | EXT ?= dylib |
92 | TARGET := $(TARGET_NAME)_libretro.$(EXT) |
93 | SHARED := -dynamiclib |
6b67b6aa |
94 | fpic := -fPIC |
7612bf90 |
95 | APPLE := 1 |
a5085db3 |
96 | |
97 | ifeq ($(CROSS_COMPILE),1) |
98 | TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT) |
99 | CFLAGS += $(TARGET_RULE) |
100 | CPPFLAGS += $(TARGET_RULE) |
101 | CXXFLAGS += $(TARGET_RULE) |
102 | LDFLAGS += $(TARGET_RULE) |
103 | endif |
104 | |
105 | ifndef ($(NOUNIVERSAL)) |
106 | CFLAGS += $(ARCHFLAGS) |
107 | LDFLAGS += $(ARCHFLAGS) |
108 | endif |
109 | CFLAGS += -DUINT8=uint8_t -DUINT16=uint16_t -DUINT32=uint32_t -DINT8=int8_t -DINT16=int16_t -DINT32=int32_t |
7612bf90 |
110 | |
111 | else ifeq ($(platform), staticios) |
112 | TARGET := $(TARGET_NAME)_libretro_ios.a |
113 | APPLE := 1 |
114 | ifeq ($(IOSSDK),) |
115 | IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) |
116 | endif |
117 | CC = clang -arch armv7 -arch arm64 -isysroot $(IOSSDK) |
118 | CXX = clang++ -arch armv7 -arch arm64 -isysroot $(IOSSDK) |
119 | CC_AS = perl ./tools/gas-preprocessor.pl $(CC) |
120 | CFLAGS += -marm |
121 | CFLAGS += -DIOS |
122 | |
123 | CC += -miphoneos-version-min=8.0 |
124 | CXX += -miphoneos-version-min=8.0 |
125 | CC_AS += -miphoneos-version-min=8.0 |
126 | CFLAGS += -miphoneos-version-min=8.0 |
7612bf90 |
127 | |
128 | STATIC_LINKING = 1 |
a5085db3 |
129 | STATIC_LINKING_LINK = 1 |
7612bf90 |
130 | |
131 | # iOS |
132 | else ifneq (,$(findstring ios,$(platform))) |
a5085db3 |
133 | TARGET := $(TARGET_NAME)_libretro_ios.dylib |
134 | SHARED := -dynamiclib |
135 | fpic := -fPIC |
136 | APPLE := 1 |
137 | MINVERSION := |
7612bf90 |
138 | ifeq ($(IOSSDK),) |
139 | IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) |
140 | endif |
61d76999 |
141 | ifeq ($(platform),ios-arm64) |
142 | CC = clang -arch arm64 -isysroot $(IOSSDK) |
143 | CXX = clang++ -arch arm64 -isysroot $(IOSSDK) |
144 | CFLAGS += -marm -DARM -D__aarch64__=1 |
145 | else |
146 | CC = clang -arch armv7 -isysroot $(IOSSDK) |
147 | CXX = clang++ -arch armv7 -isysroot $(IOSSDK) |
148 | CC_AS = perl ./tools/gas-preprocessor.pl $(CC) |
149 | CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm |
150 | ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon |
151 | NO_ARM_ASM = 1 |
152 | endif |
7612bf90 |
153 | CFLAGS += -DIOS |
154 | |
61d76999 |
155 | ifeq ($(platform),$(filter $(platform),ios9 ios-arm64)) |
a5085db3 |
156 | MINVERSION = -miphoneos-version-min=8.0 |
7612bf90 |
157 | else |
a5085db3 |
158 | MINVERSION = -miphoneos-version-min=5.0 |
7612bf90 |
159 | endif |
a5085db3 |
160 | CC += $(MINVERSION) |
161 | CXX += $(MINVERSION) |
162 | CC_AS += $(MINVERSION) |
163 | CFLAGS += $(MINVERSION) |
7612bf90 |
164 | |
61d76999 |
165 | # tvOS |
166 | else ifeq ($(platform), tvos-arm64) |
167 | TARGET := $(TARGET_NAME)_libretro_tvos.dylib |
168 | SHARED := -dynamiclib |
169 | fpic := -fPIC |
170 | APPLE := 1 |
a5085db3 |
171 | ifeq ($(IOSSDK),) |
172 | IOSSDK := $(shell xcodebuild -version -sdk appletvos Path) |
173 | endif |
174 | CC_AS = perl ./tools/gas-preprocessor.pl $(CC) |
175 | CC = cc -arch arm64 -isysroot $(IOSSDK) |
176 | CXX = c++ -arch arm64 -isysroot $(IOSSDK) |
61d76999 |
177 | CFLAGS += -marm -DARM -D__aarch64__=1 |
178 | CFLAGS += -DIOS |
179 | |
7612bf90 |
180 | # Lightweight PS3 Homebrew SDK |
a5085db3 |
181 | else ifneq (,$(filter $(platform), ps3 psl1ght)) |
7612bf90 |
182 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
a5085db3 |
183 | CC = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)gcc$(EXE_EXT) |
184 | AR = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)ar$(EXE_EXT) |
185 | CFLAGS += -DFAMEC_NO_GOTOS -D__PS3__ |
7612bf90 |
186 | STATIC_LINKING = 1 |
a5085db3 |
187 | STATIC_LINKING_LINK = 1 |
a5085db3 |
188 | ifeq ($(platform), psl1ght) |
189 | FLAGS += -D__PSL1GHT__ |
190 | endif |
61d76999 |
191 | |
7612bf90 |
192 | # PSP |
2446536b |
193 | else ifeq ($(platform), psp1) |
d35a9295 |
194 | ARCH = mipsel |
03d5f510 |
195 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
196 | CC = psp-gcc$(EXE_EXT) |
197 | AR = psp-ar$(EXE_EXT) |
a5085db3 |
198 | CFLAGS += -DPSP -G0 -ftracer |
199 | CFLAGS += -I$(shell psp-config --pspsdk-path)/include |
03d5f510 |
200 | STATIC_LINKING = 1 |
a5085db3 |
201 | STATIC_LINKING_LINK = 1 |
03d5f510 |
202 | |
61d76999 |
203 | # PS2 |
204 | else ifeq ($(platform), ps2) |
d35a9295 |
205 | ARCH = mipsel |
61d76999 |
206 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
a5085db3 |
207 | CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT) |
208 | AR = mips64r5900el-ps2-elf-ar$(EXE_EXT) |
209 | CFLAGS += -Wall -DPS2 -D_EE -DUSE_BGR555 -DFAMEC_NO_GOTOS -DRENDER_GSKIT_PS2 -fsingle-precision-constant |
61d76999 |
210 | CFLAGS += -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include |
61d76999 |
211 | STATIC_LINKING = 1 |
a5085db3 |
212 | STATIC_LINKING_LINK = 1 |
61d76999 |
213 | |
7612bf90 |
214 | # CTR (3DS) |
215 | else ifeq ($(platform), ctr) |
03d5f510 |
216 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
217 | CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT) |
218 | CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT) |
219 | AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT) |
220 | CFLAGS += -DARM11 -D_3DS |
221 | CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp |
222 | CFLAGS += -Wall -mword-relocations |
223 | CFLAGS += -fomit-frame-pointer -ffast-math |
224 | STATIC_LINKING = 1 |
a5085db3 |
225 | STATIC_LINKING_LINK = 1 |
03d5f510 |
226 | |
61d76999 |
227 | OBJS += platform/libretro/3ds/3ds_utils.o platform/libretro/3ds/utils.o |
7612bf90 |
228 | |
a5085db3 |
229 | # Raspberry Pi |
230 | else ifneq (,$(findstring rpi,$(platform))) |
03d5f510 |
231 | CFLAGS += -Wall -mword-relocations |
232 | CFLAGS += -fomit-frame-pointer -ffast-math |
233 | |
234 | TARGET := $(TARGET_NAME)_libretro.so |
235 | SHARED := -shared |
236 | fpic := -fPIC |
a5085db3 |
237 | |
238 | ifneq (,$(findstring rpi1,$(platform))) |
239 | CFLAGS += -marm -mfpu=vfp -mfloat-abi=hard -march=armv6j |
240 | else ifneq (,$(findstring rpi2,$(platform))) |
241 | CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard |
242 | else ifneq (,$(findstring rpi3,$(platform))) |
243 | CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard |
244 | endif |
7612bf90 |
245 | |
246 | # Vita |
247 | else ifeq ($(platform), vita) |
248 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
249 | CC = arm-vita-eabi-gcc$(EXE_EXT) |
250 | AR = arm-vita-eabi-ar$(EXE_EXT) |
251 | CFLAGS += -DVITA |
252 | CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=hard -ffast-math |
253 | CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops |
254 | CFLAGS += -mword-relocations -fno-unwind-tables |
255 | CFLAGS += -fno-optimize-sibling-calls |
256 | STATIC_LINKING = 1 |
a5085db3 |
257 | STATIC_LINKING_LINK = 1 |
7612bf90 |
258 | |
259 | # Xbox 360 |
2446536b |
260 | else ifeq ($(platform), xenon) |
7612bf90 |
261 | TARGET := $(TARGET_NAME)_libretro_xenon360.a |
262 | CC = xenon-gcc$(EXE_EXT) |
263 | AR = xenon-ar$(EXE_EXT) |
a5085db3 |
264 | CFLAGS += -D__LIBXENON__ -m32 |
7612bf90 |
265 | |
266 | # Nintendo Game Cube |
2446536b |
267 | else ifeq ($(platform), ngc) |
7612bf90 |
268 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
269 | CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) |
270 | AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) |
a5085db3 |
271 | CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float |
f6b8bcc7 |
272 | STATIC_LINKING = 1 |
a5085db3 |
273 | STATIC_LINKING_LINK = 1 |
7612bf90 |
274 | |
275 | # Nintendo Wii |
2446536b |
276 | else ifeq ($(platform), wii) |
7612bf90 |
277 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
278 | CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) |
279 | AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) |
8cca3182 |
280 | CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -ffat-lto-objects |
f6b8bcc7 |
281 | STATIC_LINKING = 1 |
a5085db3 |
282 | STATIC_LINKING_LINK = 1 |
7612bf90 |
283 | |
61d76999 |
284 | # Nintendo Wii U |
285 | else ifeq ($(platform), wiiu) |
286 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
287 | CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) |
288 | CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT) |
289 | AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) |
a5085db3 |
290 | CFLAGS += -DGEKKO -DWIIU -DHW_RVL -DHW_WUP -mwup -mcpu=750 -meabi -mhard-float |
f6b8bcc7 |
291 | STATIC_LINKING = 1 |
a5085db3 |
292 | STATIC_LINKING_LINK = 1 |
61d76999 |
293 | |
294 | # Nintendo Switch (libtransistor) |
295 | else ifeq ($(platform), switch) |
296 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
297 | include $(LIBTRANSISTOR_HOME)/libtransistor.mk |
298 | STATIC_LINKING=1 |
a5085db3 |
299 | STATIC_LINKING_LINK = 1 |
61d76999 |
300 | |
301 | # Nintendo Switch (libnx) |
302 | else ifeq ($(platform), libnx) |
303 | include $(DEVKITPRO)/libnx/switch_rules |
304 | TARGET := $(TARGET_NAME)_libretro_$(platform).a |
305 | CFLAGS += -O3 -fomit-frame-pointer -ffast-math -I$(DEVKITPRO)/libnx/include/ -fPIE -Wl,--allow-multiple-definition |
306 | CFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs |
307 | CFLAGS += -D__SWITCH__ -DHAVE_LIBNX |
308 | CFLAGS += -DARM -D__aarch64__=1 -march=armv8-a -mtune=cortex-a57 -mtp=soft -ffast-math -mcpu=cortex-a57+crc+fp+simd -ffunction-sections |
309 | CFLAGS += -Ifrontend/switch -ftree-vectorize |
310 | STATIC_LINKING=1 |
a5085db3 |
311 | STATIC_LINKING_LINK = 1 |
61d76999 |
312 | |
7612bf90 |
313 | # QNX |
2446536b |
314 | else ifeq ($(platform), qnx) |
d35a9295 |
315 | ARCH = arm |
7612bf90 |
316 | TARGET := $(TARGET_NAME)_libretro_$(platform).so |
6b67b6aa |
317 | fpic := -fPIC |
7612bf90 |
318 | CC = qcc -Vgcc_ntoarmv7le |
319 | CC_AS = $(CC) |
320 | CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp |
321 | ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp |
7612bf90 |
322 | |
61d76999 |
323 | # (armv7 a7, hard point, neon based) ### |
324 | # NESC, SNESC, C64 mini |
325 | else ifeq ($(platform), classic_armv7_a7) |
326 | TARGET := $(TARGET_NAME)_libretro.so |
327 | fpic := -fPIC |
328 | SHARED := -shared -Wl,--no-undefined,-Bsymbolic |
329 | CFLAGS += -Ofast \ |
36b2f293 |
330 | -flto=4 -fuse-linker-plugin \ |
61d76999 |
331 | -fdata-sections -ffunction-sections -Wl,--gc-sections \ |
332 | -fno-stack-protector -fno-ident -fomit-frame-pointer \ |
333 | -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ |
334 | -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ |
335 | -fmerge-all-constants -fno-math-errno \ |
336 | -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard |
337 | CXXFLAGS += $(CFLAGS) |
338 | CPPFLAGS += $(CFLAGS) |
339 | ASFLAGS += $(CFLAGS) |
340 | HAVE_NEON = 1 |
341 | BUILTIN_GPU = neon |
342 | ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1) |
343 | CFLAGS += -march=armv7-a |
344 | else |
345 | CFLAGS += -march=armv7ve |
346 | # If gcc is 5.0 or later |
347 | ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1) |
348 | LDFLAGS += -static-libgcc -static-libstdc++ |
349 | endif |
350 | endif |
351 | |
352 | # (armv8 a35, hard point, neon based) ### |
353 | # Playstation Classic |
354 | else ifeq ($(platform), classic_armv8_a35) |
355 | TARGET := $(TARGET_NAME)_libretro.so |
356 | fpic := -fPIC |
357 | SHARED := -shared -Wl,--no-undefined,-Bsymbolic |
358 | CFLAGS += -Ofast \ |
36b2f293 |
359 | -flto -fuse-linker-plugin \ |
61d76999 |
360 | -fdata-sections -ffunction-sections -Wl,--gc-sections \ |
361 | -fno-stack-protector -fno-ident -fomit-frame-pointer \ |
362 | -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ |
363 | -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ |
364 | -fmerge-all-constants -fno-math-errno -fno-strict-aliasing \ |
365 | -marm -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard |
366 | CXXFLAGS += $(CFLAGS) |
367 | CPPFLAGS += $(CFLAGS) |
368 | ASFLAGS += $(CFLAGS) |
369 | HAVE_NEON = 1 |
370 | BUILTIN_GPU = neon |
371 | CFLAGS += -march=armv8-a |
372 | LDFLAGS += -static-libgcc -static-libstdc++ |
373 | |
374 | ####################################### |
375 | |
376 | # ARM-64 |
377 | else ifeq ($(platform), arm64) |
378 | EXT ?= so |
379 | TARGET := $(TARGET_NAME)_libretro.$(EXT) |
380 | ARCH = aarch64 |
381 | fpic := -fPIC |
382 | SHARED := -shared |
61d76999 |
383 | CFLAGS += -DFAMEC_NO_GOTOS |
384 | |
385 | # AARCH64 generic |
386 | else ifeq ($(platform), aarch64) |
387 | TARGET := $(TARGET_NAME)_libretro.so |
388 | ARCH = aarch64 |
389 | fpic := -fPIC |
390 | SHARED := -shared |
61d76999 |
391 | CFLAGS += -DFAMEC_NO_GOTOS |
392 | |
7612bf90 |
393 | # ARM |
087a176d |
394 | else ifneq (,$(findstring armv,$(platform))) |
7612bf90 |
395 | TARGET := $(TARGET_NAME)_libretro.so |
396 | SHARED := -shared -Wl,--no-undefined,-Bsymbolic |
6b67b6aa |
397 | fpic := -fPIC |
7612bf90 |
398 | ifneq (,$(findstring cortexa5,$(platform))) |
399 | CFLAGS += -marm -mcpu=cortex-a5 |
400 | ASFLAGS += -mcpu=cortex-a5 |
401 | else ifneq (,$(findstring cortexa8,$(platform))) |
402 | CFLAGS += -marm -mcpu=cortex-a8 |
403 | ASFLAGS += -mcpu=cortex-a8 |
404 | else ifneq (,$(findstring cortexa9,$(platform))) |
405 | CFLAGS += -marm -mcpu=cortex-a9 |
406 | ASFLAGS += -mcpu=cortex-a9 |
407 | else ifneq (,$(findstring cortexa15a7,$(platform))) |
408 | CFLAGS += -marm -mcpu=cortex-a15.cortex-a7 |
409 | ASFLAGS += -mcpu=cortex-a15.cortex-a7 |
410 | else |
411 | CFLAGS += -marm |
412 | endif |
413 | ifneq (,$(findstring neon,$(platform))) |
414 | CFLAGS += -mfpu=neon |
415 | ASFLAGS += -mfpu=neon |
416 | endif |
417 | ifneq (,$(findstring softfloat,$(platform))) |
418 | CFLAGS += -mfloat-abi=softfp |
419 | ASFLAGS += -mfloat-abi=softfp |
420 | else ifneq (,$(findstring hardfloat,$(platform))) |
421 | CFLAGS += -mfloat-abi=hard |
422 | ASFLAGS += -mfloat-abi=hard |
423 | endif |
03d5f510 |
424 | ifeq (,$(findstring armasm,$(platform))) |
425 | NO_ARM_ASM = 1 |
7612bf90 |
426 | endif |
7612bf90 |
427 | |
428 | # Emscripten |
429 | else ifeq ($(platform), emscripten) |
430 | TARGET := $(TARGET_NAME)_libretro_$(platform).bc |
03d5f510 |
431 | ARCH = unknown |
7612bf90 |
432 | |
a5085db3 |
433 | STATIC_LINKING = 1 |
434 | |
435 | # RS90 |
436 | else ifeq ($(platform), rs90) |
437 | TARGET := $(TARGET_NAME)_libretro.so |
438 | ifeq (,$(shell command -v $(RS90_PREFIX)mipsel-rs90-linux-uclibc-gcc 2>/dev/null)) |
439 | # locate the toolchain for buildbot if it isn't in path or prefix not set |
440 | RS90_PREFIX = /opt/rs90-toolchain/usr/bin/ |
441 | endif |
442 | CC = $(RS90_PREFIX)mipsel-linux-gcc |
443 | AR = $(RS90_PREFIX)mipsel-linux-ar |
444 | SHARED := -shared -nostdlib |
445 | fpic := -fPIC |
446 | LIBM := |
447 | CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32 -D__GCW0__ |
448 | # clear_cache uses SYNCI instead of a syscall |
449 | CFLAGS += -DMIPS_USE_SYNCI |
450 | LOW_MEMORY = 1 |
451 | |
7612bf90 |
452 | # GCW0 |
453 | else ifeq ($(platform), gcw0) |
454 | TARGET := $(TARGET_NAME)_libretro.so |
5d900cc4 |
455 | ifeq (,$(shell command -v $(GCW0_PREFIX)mipsel-gcw0-linux-uclibc-gcc 2>/dev/null)) |
456 | # locate the toolchain for buildbot if it isn't in path or prefix not set |
457 | GCW0_PREFIX = /opt/gcw0-toolchain/usr/bin/ |
458 | endif |
459 | CC = $(GCW0_PREFIX)mipsel-linux-gcc |
460 | AR = $(GCW0_PREFIX)mipsel-linux-ar |
7612bf90 |
461 | SHARED := -shared -nostdlib |
6b67b6aa |
462 | fpic := -fPIC |
7612bf90 |
463 | LIBM := |
a5085db3 |
464 | CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float -D__GCW0__ |
465 | # clear_cache uses SYNCI instead of a syscall |
466 | CFLAGS += -DMIPS_USE_SYNCI |
467 | |
468 | # RETROFW |
469 | else ifeq ($(platform), retrofw) |
470 | TARGET := $(TARGET_NAME)_libretro.so |
471 | ifeq (,$(shell command -v $(GCW0_PREFIX)mipsel-gcw0-linux-uclibc-gcc 2>/dev/null)) |
472 | # locate the toolchain for buildbot if it isn't in path or prefix not set |
473 | GCW0_PREFIX = /opt/retrofw-toolchain/usr/bin/ |
474 | endif |
475 | CC = $(GCW0_PREFIX)mipsel-linux-gcc |
476 | AR = $(GCW0_PREFIX)mipsel-linux-ar |
477 | SHARED := -shared -nostdlib |
478 | fpic := -fPIC |
479 | LIBM := |
480 | CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32 -mhard-float -D__GCW0__ |
481 | # clear_cache uses SYNCI instead of a syscall |
482 | CFLAGS += -DMIPS_USE_SYNCI |
483 | |
484 | # MIYOO |
485 | else ifeq ($(platform), miyoo) |
486 | TARGET := $(TARGET_NAME)_libretro.so |
487 | CC = /opt/miyoo/usr/bin/arm-linux-gcc |
488 | AR = /opt/miyoo/usr/bin/arm-linux-ar |
489 | SHARED := -shared -nostdlib |
490 | fpic := -fPIC |
491 | LIBM := |
a5085db3 |
492 | CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -D__GCW0__ |
493 | HAVE_ARMv6 = 0 |
494 | LOW_MEMORY = 1 |
61d76999 |
495 | |
496 | # Windows MSVC 2017 all architectures |
497 | else ifneq (,$(findstring windows_msvc2017,$(platform))) |
498 | NO_GCC := 1 |
499 | |
500 | PlatformSuffix = $(subst windows_msvc2017_,,$(platform)) |
501 | ifneq (,$(findstring desktop,$(PlatformSuffix))) |
502 | WinPartition = desktop |
503 | MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -FS |
504 | LDFLAGS += -MANIFEST -LTCG:incremental -NXCOMPAT -DYNAMICBASE -DEBUG -OPT:REF -INCREMENTAL:NO -SUBSYSTEM:WINDOWS -MANIFESTUAC:"level='asInvoker' uiAccess='false'" -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 |
505 | LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib |
506 | else ifneq (,$(findstring uwp,$(PlatformSuffix))) |
507 | WinPartition = uwp |
508 | MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WINDLL -D_UNICODE -DUNICODE -D__WRL_NO_DEFAULT_LIB__ -EHsc -FS |
509 | LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO |
510 | LDLIBS += WindowsApp.lib |
511 | endif |
512 | |
513 | ARCH = x86_64 |
514 | SHARED := |
515 | LIBM := |
61d76999 |
516 | NO_ALIGN_FUNCTIONS = 1 |
517 | |
518 | CFLAGS += -DHAVE_VSNPRINTF |
519 | CFLAGS += $(MSVC2017CompileFlags) |
520 | CXXFLAGS += $(MSVC2017CompileFlags) |
521 | |
522 | TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix)) |
523 | |
524 | CC = cl.exe |
525 | CXX = cl.exe |
526 | LD = link.exe |
527 | |
528 | reg_query = $(call filter_out2,$(subst $2,,$(shell reg query "$2" -v "$1" 2>nul))) |
529 | fix_path = $(subst $(SPACE),\ ,$(subst \,/,$1)) |
530 | |
531 | ProgramFiles86w := $(shell cmd //c "echo %PROGRAMFILES(x86)%") |
532 | ProgramFiles86 := $(shell cygpath "$(ProgramFiles86w)") |
533 | |
534 | WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0) |
535 | WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0) |
536 | WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0) |
537 | WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0) |
538 | WindowsSdkDir := $(WindowsSdkDir) |
539 | |
540 | WindowsSDKVersion ?= $(firstword $(foreach folder,$(subst $(subst \,/,$(WindowsSdkDir)Include/),,$(wildcard $(call fix_path,$(WindowsSdkDir)Include\*))),$(if $(wildcard $(call fix_path,$(WindowsSdkDir)Include/$(folder)/um/Windows.h)),$(folder),)))$(BACKSLASH) |
541 | WindowsSDKVersion := $(WindowsSDKVersion) |
542 | |
543 | VsInstallBuildTools = $(ProgramFiles86)/Microsoft Visual Studio/2017/BuildTools |
544 | VsInstallEnterprise = $(ProgramFiles86)/Microsoft Visual Studio/2017/Enterprise |
545 | VsInstallProfessional = $(ProgramFiles86)/Microsoft Visual Studio/2017/Professional |
546 | VsInstallCommunity = $(ProgramFiles86)/Microsoft Visual Studio/2017/Community |
547 | |
548 | VsInstallRoot ?= $(shell if [ -d "$(VsInstallBuildTools)" ]; then echo "$(VsInstallBuildTools)"; fi) |
549 | ifeq ($(VsInstallRoot), ) |
550 | VsInstallRoot = $(shell if [ -d "$(VsInstallEnterprise)" ]; then echo "$(VsInstallEnterprise)"; fi) |
551 | endif |
552 | ifeq ($(VsInstallRoot), ) |
553 | VsInstallRoot = $(shell if [ -d "$(VsInstallProfessional)" ]; then echo "$(VsInstallProfessional)"; fi) |
554 | endif |
555 | ifeq ($(VsInstallRoot), ) |
556 | VsInstallRoot = $(shell if [ -d "$(VsInstallCommunity)" ]; then echo "$(VsInstallCommunity)"; fi) |
557 | endif |
558 | VsInstallRoot := $(VsInstallRoot) |
559 | |
560 | VcCompilerToolsVer := $(shell cat "$(VsInstallRoot)/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | grep -o '[0-9\.]*') |
561 | VcCompilerToolsDir := $(VsInstallRoot)/VC/Tools/MSVC/$(VcCompilerToolsVer) |
562 | |
563 | WindowsSDKSharedIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\shared") |
564 | WindowsSDKUCRTIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\ucrt") |
565 | WindowsSDKUMIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\um") |
566 | WindowsSDKUCRTLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\ucrt\$(TargetArchMoniker)") |
567 | WindowsSDKUMLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\um\$(TargetArchMoniker)") |
568 | |
569 | # For some reason the HostX86 compiler doesn't like compiling for x64 |
570 | # ("no such file" opening a shared library), and vice-versa. |
571 | # Work around it for now by using the strictly x86 compiler for x86, and x64 for x64. |
572 | # NOTE: What about ARM? |
573 | ifneq (,$(findstring x64,$(TargetArchMoniker))) |
574 | VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX64 |
575 | else |
576 | VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX86 |
577 | endif |
578 | |
579 | PATH := $(shell IFS=$$'\n'; cygpath "$(VCCompilerToolsBinDir)/$(TargetArchMoniker)"):$(PATH) |
580 | PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VsInstallRoot)/Common7/IDE") |
581 | INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/include") |
582 | LIB := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/lib/$(TargetArchMoniker)") |
583 | ifneq (,$(findstring uwp,$(PlatformSuffix))) |
584 | LIB := $(shell IFS=$$'\n'; cygpath -w "$(LIB)/store") |
585 | endif |
586 | |
587 | export INCLUDE := $(INCLUDE);$(WindowsSDKSharedIncludeDir);$(WindowsSDKUCRTIncludeDir);$(WindowsSDKUMIncludeDir) |
588 | export LIB := $(LIB);$(WindowsSDKUCRTLibDir);$(WindowsSDKUMLibDir) |
589 | TARGET := $(TARGET_NAME)_libretro.dll |
590 | PSS_STYLE :=2 |
591 | LDFLAGS += -DLL |
7612bf90 |
592 | |
7612bf90 |
593 | # Windows |
2446536b |
594 | else |
7612bf90 |
595 | TARGET := $(TARGET_NAME)_libretro.dll |
a5085db3 |
596 | CC ?= gcc |
7612bf90 |
597 | fpic := -fPIC |
598 | SHARED := -shared -static-libgcc -static-libstdc++ |
599 | CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ |
600 | |
601 | endif |
602 | |
3a770905 |
603 | CFLAGS += -D__LIBRETRO__ |
61d76999 |
604 | |
605 | ifeq ($(USE_LIBRETRO_VFS),1) |
61d76999 |
606 | CFLAGS += -DUSE_LIBRETRO_VFS |
607 | endif |
7612bf90 |
608 | |
a5085db3 |
609 | ifeq ($(LOW_MEMORY), 1) |
610 | CFLAGS += -DLOW_MEMORY |
611 | endif |
612 | |
03d5f510 |
613 | ifeq ($(NO_ARM_ASM),1) |
614 | use_cyclone = 0 |
713e3a1c |
615 | use_fame = 1 |
03d5f510 |
616 | use_drz80 = 0 |
713e3a1c |
617 | use_cz80 = 1 |
35984c21 |
618 | use_svpdrc = 0 |
03d5f510 |
619 | |
620 | asm_memory = 0 |
621 | asm_render = 0 |
622 | asm_ym2612 = 0 |
623 | asm_misc = 0 |
624 | asm_cdmemory = 0 |
625 | asm_mix = 0 |
626 | asm_32xdraw = 0 |
627 | asm_32xmemory = 0 |
34e7fb0b |
628 | endif |
087a176d |
629 | |
0995d4a7 |
630 | ifeq ($(APPLE),1) |
631 | # turn off DRCs on Apple OSes. It needs signing and notarizing on the |
632 | # later versions, which picodrive isn't supporting right now. |
633 | use_sh2drc = 0 |
634 | use_svpdrc = 0 |
635 | endif |
636 | |
7612bf90 |
637 | CFLAGS += $(fpic) |
638 | |
639 | ifeq ($(findstring Haiku,$(shell uname -a)),) |
640 | LDLIBS += $(LIBM) |
641 | endif |
642 | |
2446536b |
643 | SHARED ?= -shared |
7612bf90 |
644 | LDFLAGS += $(SHARED) $(fpic) |
2446536b |
645 | |
03d5f510 |
646 | ifeq ($(ARCH),) |
b29bf88c |
647 | ARCH = $(shell $(CC) -dumpmachine | awk -F '-' '{print $$1}') |
648 | endif |
2446536b |
649 | PLATFORM = libretro |
650 | NO_CONFIG_MAK = yes |
651 | |
61d76999 |
652 | OBJOUT = -o |
653 | LINKOUT = -o |
654 | |
655 | ifneq (,$(findstring msvc,$(platform))) |
656 | CFLAGS += -wd4702 -wd4711 -wd4202 -wd4101 |
657 | endif |
658 | |
659 | ifeq ($(DEBUG), 1) |
660 | ifneq (,$(findstring msvc,$(platform))) |
661 | ifeq ($(STATIC_LINKING),1) |
662 | CFLAGS += -MTd |
663 | CXXFLAGS += -MTd |
664 | else |
665 | CFLAGS += -MDd |
666 | CXXFLAGS += -MDd |
667 | endif |
668 | |
669 | CFLAGS += -Od -Zi -DDEBUG -D_DEBUG |
670 | CXXFLAGS += -Od -Zi -DDEBUG -D_DEBUG |
671 | else |
672 | CFLAGS += -O0 -g -DDEBUG |
673 | CXXFLAGS += -O0 -g -DDEBUG |
674 | endif |
675 | else |
676 | ifneq (,$(findstring msvc,$(platform))) |
677 | ifeq ($(STATIC_LINKING),1) |
678 | CFLAGS += -MT |
679 | CXXFLAGS += -MT |
680 | else |
681 | CFLAGS += -MD |
682 | CXXFLAGS += -MD |
683 | endif |
684 | |
685 | CFLAGS += -O2 -DNDEBUG |
686 | CXXFLAGS += -O2 -DNDEBUG |
687 | else |
688 | CFLAGS += -O3 -DNDEBUG |
689 | CXXFLAGS += -O3 -DNDEBUG |
690 | endif |
691 | endif |
692 | |
693 | ifneq (,$(findstring msvc,$(platform))) |
694 | OBJOUT = -Fo |
695 | LINKOUT = -out: |
696 | ifeq ($(STATIC_LINKING),1) |
697 | LD ?= lib.exe |
698 | STATIC_LINKING=0 |
699 | else |
700 | LD = link.exe |
701 | endif |
702 | else |
703 | LD = $(CC) |
704 | endif |
705 | |
3a770905 |
706 | PLATFORM_ZLIB ?= 1 |
707 | |
2446536b |
708 | include Makefile |
a5085db3 |
709 | |
710 | ifeq ($(platform), osx) |
711 | pico/cd/libchdr/src/libchdr_chd.o: CFLAGS += -D__MACTYPES__=1 |
36b2f293 |
712 | endif |