$(LD) ?= $(CC)
TARGET ?= PicoDrive
+ASAN ?= 0
DEBUG ?= 0
CFLAGS += -I$(PWD)
CYCLONE_CC ?= gcc
endif
endif
+ifeq "$(ASAN)" "1"
+ CFLAGS += -fsanitize=address -fsanitize=leak -fsanitize=bounds -fno-omit-frame-pointer -fno-common -O1 -g
+ LDLIBS += -fsanitize=address -fsanitize=leak -fsanitize=bounds -static-libasan
+else
ifeq "$(DEBUG)" "0"
CFLAGS += -O3 -DNDEBUG
+endif
endif
LD = $(CC)
OBJOUT ?= -o
LINKOUT ?= -o
endif
+
+chkCCflag = $(shell n=/dev/null; echo $(1) | tr " " "\n" | while read f; do \
+ $(CC) $$f -x c -c $$n -o $$n 2>$$n && echo "_$$f" | tr -d _; done)
+
ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","gp2x" "opendingux" "miyoo" "rpi1"))
# very small caches, avoid optimization options making the binary much bigger
-CFLAGS += -finline-limit=42 -fno-unroll-loops -fno-ipa-cp -ffast-math
-# this gets you about 20% better execution speed on 32bit arm/mips
-CFLAGS += -fno-common -fno-stack-protector -fno-guess-branch-probability -fno-caller-saves -fno-regmove
-# Ouf, very old gcc toolchains (pre 4.6) don't have this option:
-CFLAGS += $(shell echo | $(CC) -ftree-loop-if-convert -x c -c -o /dev/null - 2>/dev/null && echo xfno-tree-loop-if-convert | tr x -)
+CFLAGS += -fno-common -fno-stack-protector -finline-limit=42 -fno-unroll-loops -ffast-math
+ifneq ($(call chkCCflag, -fipa-ra),) # gcc >= 5
+CFLAGS += $(call chkCCflag, -flto -fipa-pta -fipa-ra)
+else
+# these improve execution speed on 32bit arm/mips with gcc pre-5 toolchains
+CFLAGS += -fno-ipa-cp -fno-caller-saves -fno-guess-branch-probability -fno-regmove
+# very old gcc toolchains may not have these options
+CFLAGS += $(call chkCCflag, -fno-tree-loop-if-convert -fipa-pta)
+endif
+endif
+
+# revision info from repository if this not a tagged release
+ifeq "$(shell git describe --tags --exact-match HEAD 2>/dev/null)" ""
+REVISION ?= -$(shell git rev-parse --short HEAD || echo ???)
endif
+CFLAGS += -DREVISION=\"$(REVISION)\"
# default settings
use_libchdr ?= 1
LOW_MEMORY := 0
TARGET_NAME := picodrive
LIBM := -lm
-GIT_VERSION ?= $(shell git rev-parse --short HEAD || echo unknown)
-ifneq ($(GIT_VERSION),"unknown")
- CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
-endif
+REVISION ?= -$(shell git rev-parse --short HEAD || echo ???)
+
fpic :=
ARCH := 86
fpic := -fPIC
SHARED := -shared
- DONT_COMPILE_IN_ZLIB = 1
CFLAGS += -DFAMEC_NO_GOTOS
# AARCH64 generic
ARCH = aarch64
fpic := -fPIC
SHARED := -shared
- DONT_COMPILE_IN_ZLIB = 1
CFLAGS += -DFAMEC_NO_GOTOS
# Portable Linux
SHARED := -shared -nostdlib
fpic := -fPIC
LIBM :=
- DONT_COMPILE_IN_ZLIB = 1
CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -D__GCW0__
HAVE_ARMv6 = 0
LOW_MEMORY = 1
endif
-CFLAGS += -DNO_ZLIB -D__LIBRETRO__
+CFLAGS += -D__LIBRETRO__
ifeq ($(USE_LIBRETRO_VFS),1)
CFLAGS += -DUSE_LIBRETRO_VFS
LD = $(CC)
endif
+PLATFORM_ZLIB ?= 1
+
include Makefile
ifeq ($(platform), osx)
{
memset(info, 0, sizeof(*info));
info->library_name = "PicoDrive";
-#ifndef GIT_VERSION
-#define _GIT_VERSION ""
-#else
-#define _GIT_VERSION "-" GIT_VERSION
-#endif
- info->library_version = VERSION _GIT_VERSION;
+ info->library_version = VERSION;
info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|chd|sms|gg|sg|sc|m3u|68k|sgd|pco";
info->need_fullpath = true;
}