#plain 'make' doesn't include the file that sets this. force it set anyways.
RETRODEFS ?= -D__LIBRETRO__
RETRODEFS += -DMINIMAL_CORE=2 -DM_CORE_GBA -DM_CORE_GB -DENABLE_VFS -DENABLE_DIRECTORIES

INCLUDES  += -I$(CORE_DIR)/src -I$(CORE_DIR)/src/arm -I$(CORE_DIR)/include -I$(CORE_DIR)/src/platform/libretro
RETRODEFS += -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DINLINE=inline -DCOLOR_16_BIT -DRESAMPLE_LIBRARY=2 -DM_PI=3.14159265358979323846 -DMGBA_STANDALONE
ifeq ($(platform), ps3)
RETRODEFS += -DPATH_MAX=1024
else
RETRODEFS += -DPATH_MAX=4096
endif
ifneq ($(TARGET_PLATFORM), android_arm64-v8a)
	RETRODEFS += -DSSIZE_MAX=2147483648
endif

ifeq ($(STATIC_LINKING), 1)
INCLUDES += -I$(CORE_DIR)/src/third-party/zlib \
				-I$(CORE_DIR)/libretro-build/include/libz
endif

ifneq ($(DEBUG), 1)
	RETRODEFS += -DNDEBUG
endif

ifneq ($(HAVE_VFS_FD),1)
RETRODEFS += -DENABLE_VFS_FILE
endif

ifeq  (,$(findstring win,$(platform)))
ifeq  (,$(findstring mingw,$(platform)))
ifneq ($(platform), vita)
ifneq ($(platform), ps3)
RETRODEFS += -DHAVE_LOCALTIME_R
endif
endif
endif
endif

ifneq ($(platform), ps2)
RETRODEFS += -DCOLOR_5_6_5
endif

SOURCES_C :=   $(CORE_DIR)/src/arm/arm.c \
					$(CORE_DIR)/src/arm/decoder.c \
					$(CORE_DIR)/src/arm/decoder-arm.c \
					$(CORE_DIR)/src/arm/decoder-thumb.c \
					$(CORE_DIR)/src/arm/isa-thumb.c \
					$(CORE_DIR)/src/arm/isa-arm.c \
					$(CORE_DIR)/src/core/bitmap-cache.c \
					$(CORE_DIR)/src/core/cache-set.c \
					$(CORE_DIR)/src/core/cheats.c \
					$(CORE_DIR)/src/core/config.c \
					$(CORE_DIR)/src/core/core.c \
					$(CORE_DIR)/src/core/interface.c \
					$(CORE_DIR)/src/core/lockstep.c \
					$(CORE_DIR)/src/core/log.c \
					$(CORE_DIR)/src/core/map-cache.c \
					$(CORE_DIR)/src/core/sync.c \
					$(CORE_DIR)/src/core/thread.c \
					$(CORE_DIR)/src/core/tile-cache.c \
					$(CORE_DIR)/src/core/core-serialize.c \
					$(CORE_DIR)/src/core/timing.c \
					$(CORE_DIR)/src/gb/audio.c \
					$(CORE_DIR)/src/gb/cheats.c \
					$(CORE_DIR)/src/gb/core.c \
					$(CORE_DIR)/src/gb/gb.c \
					$(CORE_DIR)/src/gb/io.c \
					$(CORE_DIR)/src/gb/mbc.c \
					$(CORE_DIR)/src/gb/mbc/huc-3.c \
					$(CORE_DIR)/src/gb/mbc/licensed.c \
					$(CORE_DIR)/src/gb/mbc/mbc.c \
					$(CORE_DIR)/src/gb/mbc/pocket-cam.c \
					$(CORE_DIR)/src/gb/mbc/tama5.c \
					$(CORE_DIR)/src/gb/mbc/unlicensed.c \
					$(CORE_DIR)/src/gb/memory.c \
					$(CORE_DIR)/src/gb/overrides.c \
					$(CORE_DIR)/src/gb/renderers/cache-set.c \
					$(CORE_DIR)/src/gb/renderers/software.c \
					$(CORE_DIR)/src/gb/serialize.c \
					$(CORE_DIR)/src/gb/sio.c \
					$(CORE_DIR)/src/gb/timer.c \
					$(CORE_DIR)/src/gb/video.c \
					$(CORE_DIR)/src/gba/audio.c \
					$(CORE_DIR)/src/gba/bios.c \
					$(CORE_DIR)/src/gba/cheats.c \
					$(CORE_DIR)/src/gba/cheats/gameshark.c \
					$(CORE_DIR)/src/gba/cheats/parv3.c \
					$(CORE_DIR)/src/gba/cheats/codebreaker.c \
					$(CORE_DIR)/src/gba/core.c \
					$(CORE_DIR)/src/gba/dma.c \
					$(CORE_DIR)/src/gba/gba.c \
					$(CORE_DIR)/src/gba/cart/gpio.c \
					$(CORE_DIR)/src/gba/cart/ereader.c \
					$(CORE_DIR)/src/gba/cart/unlicensed.c \
					$(CORE_DIR)/src/gba/hle-bios.c \
					$(CORE_DIR)/src/gba/input.c \
					$(CORE_DIR)/src/gba/io.c \
					$(CORE_DIR)/src/gba/cart/matrix.c \
					$(CORE_DIR)/src/gba/memory.c \
					$(CORE_DIR)/src/gba/overrides.c \
					$(CORE_DIR)/src/gba/renderers/cache-set.c \
					$(CORE_DIR)/src/gba/renderers/common.c \
					$(CORE_DIR)/src/gba/renderers/software-mode0.c \
					$(CORE_DIR)/src/gba/renderers/software-obj.c \
					$(CORE_DIR)/src/gba/renderers/software-bg.c \
					$(CORE_DIR)/src/gba/renderers/video-software.c \
					$(CORE_DIR)/src/gba/savedata.c \
					$(CORE_DIR)/src/gba/serialize.c \
					$(CORE_DIR)/src/gba/sio.c \
					$(CORE_DIR)/src/gba/sio/gbp.c \
					$(CORE_DIR)/src/gba/timer.c \
					$(CORE_DIR)/src/gba/cart/vfame.c \
					$(CORE_DIR)/src/gba/video.c \
					$(CORE_DIR)/src/platform/libretro/memory.c \
					$(CORE_DIR)/src/platform/libretro/libretro.c \
					$(CORE_DIR)/src/sm83/isa-sm83.c \
					$(CORE_DIR)/src/sm83/sm83.c \
					$(CORE_DIR)/src/third-party/inih/ini.c \
					$(CORE_DIR)/src/util/audio-buffer.c \
					$(CORE_DIR)/src/util/audio-resampler.c \
					$(CORE_DIR)/src/util/interpolator.c \
					$(CORE_DIR)/src/util/circle-buffer.c \
					$(CORE_DIR)/src/util/configuration.c \
					$(CORE_DIR)/src/util/formatting.c \
					$(CORE_DIR)/src/util/gbk-table.c \
					$(CORE_DIR)/src/util/geometry.c \
					$(CORE_DIR)/src/util/hash.c \
					$(CORE_DIR)/src/util/image.c \
					$(CORE_DIR)/src/util/md5.c \
					$(CORE_DIR)/src/util/sha1.c \
					$(CORE_DIR)/src/util/patch.c \
					$(CORE_DIR)/src/util/patch-ips.c \
					$(CORE_DIR)/src/util/patch-ups.c \
					$(CORE_DIR)/src/util/string.c \
					$(CORE_DIR)/src/util/table.c \
					$(CORE_DIR)/src/util/vector.c \
					$(CORE_DIR)/src/util/vfs.c \
					$(CORE_DIR)/src/util/vfs/vfs-mem.c \
					$(CORE_DIR)/src/util/crc32.c

ifeq ($(STATIC_LINKING), 1)
RETRODEFS += -DHAVE_CRC32
endif

ifeq ($(HAVE_VFS_FD),1)
RETRODEFS += -DENABLE_VFS_FD
ifeq ($(platform), vita)
SOURCES_C += $(CORE_DIR)/src/platform/psp2/sce-vfs.c
else ifeq ($(platform), ctr)
SOURCES_C += $(CORE_DIR)/src/platform/3ds/3ds-vfs.c
else
SOURCES_C += $(CORE_DIR)/src/util/vfs/vfs-fd.c
endif
else
SOURCES_C += $(CORE_DIR)/src/util/vfs/vfs-file.c
endif
