Experimental libretro extra inputs.
[SquirrelJME.git] / ratufacoat / makefilelibretro
blob23527193648819b1f5eafe5deb55172e18727ff5
1 # ---------------------------------------------------------------------------
2 # SquirrelJME
3 #     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
4 # ---------------------------------------------------------------------------
5 # SquirrelJME is under the Mozilla Public License Version 2.0.
6 # See license.mkd for licensing and copyright information.
7 # ---------------------------------------------------------------------------
8 # DESCRIPTION: Makefile specifically for SquirrelJME RatufaCoat on RetroArch.
10 ###### CORE DEFINED OPTIONS ######
11 CORE_DIR := .
12 BUILD_DIR = libretro
13 ##################################
15 DEBUG = 0
16 GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
17 STATIC_LINKING = 0
18 STATIC_LINKING_LINK = 0
19 OBJOUT = -o
21 ifeq ($(platform),linux-portable_x86)
22 include $(BUILD_DIR)/Makefile.linux-portable_x86
23 else ifeq ($(platform),linux-portable_x86_64)
24 include $(BUILD_DIR)/Makefile.linux-portable_x86_64
25 else ifeq ($(platform),linux_x86)
26 include $(BUILD_DIR)/Makefile.linux_x86
27 else ifeq ($(platform),linux_x86_64)
28 include $(BUILD_DIR)/Makefile.linux_x86_64
29 else ifeq ($(platform),osx_x86)
30 include $(BUILD_DIR)/Makefile.osx_x86
31 else ifeq ($(platform),osx_x86_64)
32 include $(BUILD_DIR)/Makefile.osx_x86_64
33 else ifeq ($(platform),mingw_x86)
34 include $(BUILD_DIR)/Makefile.mingw_x86
35 else ifeq ($(platform),mingw_x86_64)
36 include $(BUILD_DIR)/Makefile.mingw_x86_64
37 else ifeq ($(platform),ps3_ppc)
38 include $(BUILD_DIR)/Makefile.ps3_ppc
39 else ifeq ($(platform),vita_arm)
40 include $(BUILD_DIR)/Makefile.vita_arm
41 else ifeq ($(platform),wii_ppc)
42 include $(BUILD_DIR)/Makefile.wii_ppc
43 else ifeq ($(platform),windows_x86)
44 include $(BUILD_DIR)/Makefile.windows_x86
45 else ifeq ($(platform),windows_msvc2003_x86)
46 include $(BUILD_DIR)/Makefile.windows_msvc2003_x86
47 else ifeq ($(platform),windows_msvc2005_x86)
48 include $(BUILD_DIR)/Makefile.windows_msvc2005_x86
49 else ifeq ($(platform),windows_msvc2008_x86)
50 include $(BUILD_DIR)/Makefile.windows_msvc2008_x86
51 else ifeq ($(platform),windows_msvc2010_x86)
52 include $(BUILD_DIR)/Makefile.windows_msvc2010_x86
53 else ifeq ($(platform),windows_msvc2010_x64)
54 include $(BUILD_DIR)/Makefile.windows_msvc2010_x64
55 else ifeq ($(platform),windows_msvc2015_x64)
56 include $(BUILD_DIR)/Makefile.windows_msvc2015_x64
57 else ifeq ($(platform),windows_x86_64)
58 include $(BUILD_DIR)/Makefile.windows_x86_64
59 else
61 ifeq ($(platform),)
62 ifeq ($(shell uname -a),)
63         platform = win
64 else ifneq ($(findstring MINGW,$(shell uname -a)),)
65         platform = win
66 else ifneq ($(findstring Darwin,$(shell uname -a)),)
67         platform = osx
68 else ifneq ($(findstring win,$(shell uname -a)),)
69         platform = win
70 else
71         platform = unix
72 endif
73 endif
75 SPACE :=
76 SPACE := $(SPACE) $(SPACE)
77 BACKSLASH :=
78 BACKSLASH := \$(BACKSLASH)
79 filter_out1 = $(filter-out $(firstword $1),$1)
80 filter_out2 = $(call filter_out1,$(call filter_out1,$1))
81 unixpath = $(subst \,/,$1)
82 unixcygpath = /$(subst :,,$(call unixpath,$1))
84 # system platform
85 system_platform = unix
86 ifeq ($(shell uname -a),)
87         EXE_EXT = .exe
88         system_platform = win
89 else ifneq ($(findstring Darwin,$(shell uname -a)),)
90         system_platform = osx
92         # Architecture is not defined?
93         ifeq ($(arch),)
94                 # PowerPC?
95                 ifeq ($(shell uname -p),powerpc)
96                         arch = ppc
97                 else
98                         # ARM?
99                         ifeq ($(shell uname -p),arm)
100                                 arch = arm
102                         # Assume x86 otherwise
103                         else
104                                 arch = intel
105                         endif
106                 endif
107         endif
108 else ifneq ($(findstring MINGW,$(shell uname -a)),)
109         system_platform = win
110 endif
112 #CC             = gcc
113 TARGET_NAME     := squirreljme
114 LIBM            = -lm
116 ifeq ($(STATIC_LINKING),1)
117 EXT = a
119 ifeq ($(platform), unix)
120 PLAT = _unix
121 STATIC_LINKING = 1
122 STATIC_LINKING_LINK = 1
123 endif
124 endif
126 # UNIX
127 ifeq ($(platform), unix)
128         EXT    ?= so
129         TARGET := $(TARGET_NAME)_libretro$(PLAT).$(EXT)
130         fpic := -fPIC
131         SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T
132 ifneq ($(findstring Haiku,$(shell uname -a)),)
133                 LIBM :=
134 endif
136 # Linux (portable library)
137 else ifeq ($(platform), linux-portable)
138         EXT    ?= so
139         TARGET := $(TARGET_NAME)_libretro.$(EXT)
140         fpic := -fPIC -nostdlib
141         SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T
142         LIBM :=
144 # OS X
145 else ifeq ($(platform), osx)
146         EXT    ?= dylib
147         TARGET := $(TARGET_NAME)_libretro.$(EXT)
148         fpic := -fPIC
150 ifeq ($(arch),ppc)
151                 CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
152 endif
154 ifeq ($(arch),arm)
155                 CFLAGS += -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
156                 CPPFLAGS += -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
157                 CXXFLAGS += -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
158                 LDFLAGS += -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
159 endif
161         OSXVER = $(shell sw_vers -productVersion | cut -d. -f 2)
162         OSX_GT_MOJAVE = $(shell (( $(OSXVER) >= 14)) && echo "YES")
163 ifneq ($(OSX_GT_MOJAVE),YES)
164         #this breaks compiling on Mac OS Mojave
165         fpic += -mmacosx-version-min=10.1
166 endif
167         SHARED := -dynamiclib
169 # iOS
170 else ifneq (,$(findstring ios,$(platform)))
171         EXT    ?= dylib
172         TARGET := $(TARGET_NAME)_libretro_ios.$(EXT)
173         fpic := -fPIC
174         SHARED := -dynamiclib
176 ifeq ($(IOSSDK),)
177         IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
178 endif
180 ifeq ($(platform), ios-arm64)
181         CC = cc -arch arm64 -isysroot $(IOSSDK)
182 else
183         CC = cc -arch armv7 -isysroot $(IOSSDK)
184 endif
186         LD = armv7-apple-darwin11-ld
187         CFLAGS += -DIOS
188 ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
189 CC     += -miphoneos-version-min=8.0
190 CFLAGS += -miphoneos-version-min=8.0
191 else
192 CC     += -miphoneos-version-min=5.0
193 CFLAGS += -miphoneos-version-min=5.0
194 endif
196 # tvOS
197 else ifeq ($(platform), tvos-arm64)
198         EXT    ?= dylib
199         TARGET := $(TARGET_NAME)_libretro_tvos.$(EXT)
200         fpic := -fPIC
201         SHARED := -dynamiclib
202 ifeq ($(IOSSDK),)
203         IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
204 endif
205         CFLAGS += -DIOS
207 # Theos iOS
208 else ifeq ($(platform), theos_ios)
209         DEPLOYMENT_IOSVERSION = 5.0
210         TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION)
211         ARCHS = armv7 armv7s
212         TARGET_IPHONEOS_DEPLOYMENT_VERSION=$(DEPLOYMENT_IOSVERSION)
213         THEOS_BUILD_DIR := objs
214         include $(THEOS)/makefiles/common.mk
215         LIBRARY_NAME = $(TARGET_NAME)_libretro_ios
217 # QNX
218 else ifeq ($(platform), qnx)
219         EXT    ?= so
220         TARGET := $(TARGET_NAME)_libretro_qnx.$(EXT)
221         fpic := -fPIC
222         SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T
223         CC = qcc -Vgcc_ntoarmv7le
224         AR = qcc -Vgcc_ntoarmv7le
225         CFLAGS += -D__BLACKBERRY_QNX__
227 # PS3
228 else ifeq ($(platform), ps3)
229         EXT = a
230         TARGET := $(TARGET_NAME)_libretro_ps3.$(EXT)
231         CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
232         AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
233         CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
234         STATIC_LINKING = 1
235         STATIC_LINKING_LINK = 1
237 # PS3 (SNC)
238 else ifeq ($(platform), sncps3)
239         EXT = a
240         TARGET := $(TARGET_NAME)_libretro_ps3.$(EXT)
241         CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
242         AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
243         CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
244         STATIC_LINKING = 1
245         STATIC_LINKING_LINK = 1
247 # Lightweight PS3 Homebrew SDK
248 else ifeq ($(platform), psl1ght)
249         EXT = a
250         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
251         CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
252         AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
253         CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
254         STATIC_LINKING = 1
255         STATIC_LINKING_LINK = 1
257 # PSP
258 else ifeq ($(platform), psp1)
259         EXT = a
260         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
261         CC = psp-gcc$(EXE_EXT)
262         AR = psp-ar$(EXE_EXT)
263         CFLAGS += -DPSP -G0
264         STATIC_LINKING = 1
265         STATIC_LINKING_LINK = 1
267 # DOS
268 else ifeq ($(platform), dos)
269         EXT = a
270         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
271         CC = i686-pc-msdosdjgpp-gcc
272         AR = i686-pc-msdosdjgpp-ar
273         CFLAGS += -march=i386
274         STATIC_LINKING = 1
275         STATIC_LINKING_LINK = 1
277 # Vita
278 else ifeq ($(platform), vita)
279         EXT = a
280         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
281         CC = arm-vita-eabi-gcc$(EXE_EXT)
282         AR = arm-vita-eabi-ar$(EXE_EXT)
283         CFLAGS += -DVITA
284         STATIC_LINKING = 1
285         STATIC_LINKING_LINK = 1
287 # CTR (3DS)
288 else ifeq ($(platform), ctr)
289         EXT = a
290         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
291         CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
292         AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
293         CFLAGS += -DARM11 -D_3DS
294         CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard
295         CFLAGS += -Wall -mword-relocations
296         CFLAGS += -fomit-frame-pointer -ffast-math
297         CFLAGS += -D_3DS
298         STATIC_LINKING = 1
299         STATIC_LINKING_LINK = 1
301 # Raspberry Pi 2
302 else ifeq ($(platform), rpi2)
303         TARGET := $(TARGET_NAME)_libretro.so
304         fpic := -fPIC
305         SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T -Wl,--no-undefined
306         CFLAGS += -DARM
307         CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -funsafe-math-optimizations
308         CFLAGS += -fomit-frame-pointer -ffast-math
309         HAVE_NEON = 1
311 # Raspberry Pi 3
312 else ifeq ($(platform), rpi3)
313         TARGET := $(TARGET_NAME)_libretro.so
314         fpic := -fPIC
315         SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T -Wl,--no-undefined
316         CFLAGS += -DARM
317         CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -funsafe-math-optimizations
318         CFLAGS += -fomit-frame-pointer -ffast-math
319         HAVE_NEON = 1
321 # Classic Platforms ####################
322 # Platform affix = classic_<ISA>_<uARCH>
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,--version-script=$(BUILD_DIR)/link.T -Wl,--no-undefined
329         CFLAGS += -Ofast \
330                 -flto=4 -fwhole-program -fuse-linker-plugin \
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         ARCH = arm
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
352 # Xbox 360
353 else ifeq ($(platform), xenon)
354         EXT = a
355         TARGET := $(TARGET_NAME)_libretro_xenon360.$(EXT)
356         CC = xenon-gcc$(EXE_EXT)
357         AR = xenon-ar$(EXE_EXT)
358         CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
359         STATIC_LINKING = 1
360         STATIC_LINKING_LINK = 1
362 # Nintendo Game Cube
363 else ifeq ($(platform), ngc)
364         EXT = a
365         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
366         CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
367         AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
368         CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
369         CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
370         STATIC_LINKING = 1
371         STATIC_LINKING_LINK = 1
373 # Nintendo Wii
374 else ifeq ($(platform), wii)
375         EXT = a
376         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
377         CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
378         AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
379         CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
380         CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
381         STATIC_LINKING = 1
382         STATIC_LINKING_LINK = 1
384 # Nintendo WiiU
385 else ifeq ($(platform), wiiu)
386         EXT = a
387         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
388         CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
389         AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
390         CFLAGS += -DGEKKO -DHW_RVL -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
391         CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
392         STATIC_LINKING = 1
393         STATIC_LINKING_LINK = 1
395 # ARM
396 else ifneq (,$(findstring armv,$(platform)))
397         EXT    ?= so
398         TARGET := $(TARGET_NAME)_libretro.$(EXT)
399         SHARED := -shared -Wl,--no-undefined
400         fpic := -fPIC
401         CC   ?= gcc
402         ifneq (,$(findstring cortexa8,$(platform)))
403                 CFLAGS += -marm -mcpu=cortex-a8
404                 ASFLAGS += -mcpu=cortex-a8
405         else ifneq (,$(findstring cortexa9,$(platform)))
406                 CFLAGS += -marm -mcpu=cortex-a9
407                 ASFLAGS += -mcpu=cortex-a9
408         endif
409         CFLAGS += -marm
410         ifneq (,$(findstring neon,$(platform)))
411                 CFLAGS += -mfpu=neon
412                 ASFLAGS += -mfpu=neon
413                 HAVE_NEON = 1
414         endif
415         ifneq (,$(findstring softfloat,$(platform)))
416                 CFLAGS += -mfloat-abi=softfp
417                 ASFLAGS += -mfloat-abi=softfp
418         else ifneq (,$(findstring hardfloat,$(platform)))
419                 CFLAGS += -mfloat-abi=hard
420                 ASFLAGS += -mfloat-abi=hard
421         endif
422         CFLAGS += -DARM
424 # Emscripten
425 else ifeq ($(platform), emscripten)
426         TARGET := $(TARGET_NAME)_libretro_emscripten.bc
427         STATIC_LINKING = 1
428         AR = emar
430 # GCW0
431 else ifeq ($(platform), gcw0)
432         TARGET := $(TARGET_NAME)_libretro.so
433         CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
434         CXX = /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++
435         AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
436         SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T
437         fpic := -fPIC
438         CFLAGS += $(PTHREAD_FLAGS)
439         CFLAGS += -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float
441 else ifeq ($(platform), msvc)
442         OBJOUT = -Fo
444 # Nintendo Switch (libtransistor)
445 else ifeq ($(platform), switch)
446         EXT = a
447         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
448         include $(LIBTRANSISTOR_HOME)/libtransistor.mk
449         STATIC_LINKING = 1
450         STATIC_LINKING_LINK = 1
452 # Nintendo Switch (libnx)
453 else ifeq ($(platform), libnx)
454         include $(DEVKITPRO)/libnx/switch_rules
455         EXT = a
456         TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
457         DEFINES :=  -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL
458         CFLAGS :=   $(DEFINES) -g \
459                                 -O3 \
460                                 -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs
461         CFLAGS += $(INCDIRS)
462         CFLAGS += $(INCLUDE)  -D__SWITCH__ -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft
463         CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
464         CFLAGS += -std=gnu11
465         STATIC_LINKING = 1
466         STATIC_LINKING_LINK = 1
468 # Windows MSVC 2003 Xbox 1
469 else ifeq ($(platform), xbox1_msvc2003)
470         TARGET := $(TARGET_NAME)_libretro_xdk1.lib
471         CC   = CL.exe
472         CXX  = CL.exe
473         LD   = lib.exe
475         export INCLUDE := $(XDK)\xbox\include
476         export LIB := $(XDK)\xbox\lib
477         PATH := $(call unixcygpath,$(XDK)/xbox/bin/vc71):$(PATH)
479         PSS_STYLE :=2
480         CFLAGS   += -D_XBOX -D_XBOX1
481         CXXFLAGS += -D_XBOX -D_XBOX1
482         STATIC_LINKING = 1
483         STATIC_LINKING_LINK = 1
485 # PlayStation 2
486 else ifeq ($(platform), ps2)
487         TARGET := $(TARGET_NAME)_libretro_$(platform).a
488         CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT)
489         CXX = mips64r5900el-ps2-elf-g++$(EXE_EXT)
490         AR = mips64r5900el-ps2-elf-ar$(EXE_EXT)
491         CFLAGS += -Wall -DPS2 -DABGR1555 -DRENDER_GSKIT_PS2 -fsingle-precision-constant
492         CFLAGS += -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include  -I$(PS2DEV)/gsKit/include
493         STATIC_LINKING = 1
494         STATIC_LINKING_LINK = 1
496 # Windows
497 else
498         EXT    ?= dll
499         TARGET := $(TARGET_NAME)_libretro.$(EXT)
500         CC ?= gcc
501         SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=$(BUILD_DIR)/link.T
502         CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
503 endif
505 ifeq ($(STATIC_LINKING), 1)
506 SHARED=
507 fpic=
508 endif
510 ifeq ($(DEBUG), 1)
511         CFLAGS += -O0 -g
512 else
513         CFLAGS += -O2 -DNDEBUG
514         ifneq ($(GIT_VERSION), " unknown")
515                 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
516         endif
517 endif
519 include $(BUILD_DIR)/Makefile.common
521 OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o) $(SOURCES_ASM:.S=.o)
523 DEFINES += $(COREDEFINES)
525 ifeq ($(STATIC_LINKING), 1)
526         DEFINES += -DSTATIC_LINKING
527 endif
529 ifeq ($(platform), sncps3)
530         WARNINGS_DEFINES =
531         CODE_DEFINES =
532 else ifeq ($(platform), ios)
533         WARNINGS_DEFINES =
534         CODE_DEFINES =
535 else ifneq (,$(findstring msvc,$(platform)))
536         WARNING_DEFINES =
537         CODE_DEFINES =
538 else
539         WARNINGS_DEFINES = -Wall -W -Wno-unused-parameter -Wno-sign-compare -Wno-uninitialized
540         CODE_DEFINES = -fomit-frame-pointer
541 endif
543 COMMON_DEFINES += $(CODE_DEFINES) $(WARNINGS_DEFINES) $(fpic)
545 CFLAGS += $(DEFINES) $(COMMON_DEFINES)
546 CXXFLAGS += $(DEFINES) $(COMMON_DEFINES)
548 ifneq (,$(findstring msvc,$(platform)))
549         OBJOUT = -Fo
550         LINKOUT = -out:
551 ifeq ($(STATIC_LINKING),1)
552         LD ?= lib.exe
553         STATIC_LINKING=0
554 else
555         LD = link.exe
556 endif
557 else
558         OBJOUT   = -o
559         LINKOUT  = -o
560         LD = $(CC)
561 endif
563 ifeq ($(platform), theos_ios)
564 COMMON_FLAGS := -DIOS -DARM $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error
565 $(LIBRARY_NAME)_CFLAGS += $(COMMON_FLAGS)
566 ${LIBRARY_NAME}_FILES = $(SOURCES_C) $(SOURCES_CXX) $(SOURCES_ASM)
567 include $(THEOS_MAKE_PATH)/library.mk
568 else
569 all: $(TARGET)
571 $(TARGET): $(OBJECTS)
572         @echo "** BUILDING $(TARGET) FOR PLATFORM $(platform) $(arch) **"
573 ifeq ($(platform), emscripten)
574         $(AR) rcs $@ $(OBJECTS)
575 else ifeq ($(STATIC_LINKING_LINK), 1)
576 ifneq (,$(findstring msvc,$(platform)))
577         $(LD) $(LINKOUT)$@ $(OBJECTS)
578 else
579         $(AR) rcs $@ $(OBJECTS)
580 endif
581 else
582         $(CC) $(fpic) $(SHARED) $(INCFLAGS) $(LDFLAGS) $(OBJOUT)$@ $(OBJECTS) $(LIBM)
583 endif
585 %.o: %.c
586         $(CC) $(INCFLAGS) $(CFLAGS) -c $(OBJOUT)$@ $<
588 %.o: %.s
589         $(CC) $(INCFLAGS) $(CFLAGS) -c $(OBJOUT)$@ $<
591 clean-objs:
592         rm -rf $(OBJECTS)
594 clean:
595         rm -f $(OBJECTS) $(TARGET)
597 .PHONY: clean
598 endif
600 endif