Merge pull request #243 from retro-wertz/unai_fixes
[pcsx_rearmed.git] / Makefile.libretro
index c1e4051..2d88b70 100644 (file)
@@ -1,6 +1,7 @@
 # Makefile for PCSX ReARMed (libretro)
 
 DEBUG=0
+WANT_ZLIB=1
 
 ifeq ($(platform),)
        platform = unix
@@ -26,9 +27,16 @@ GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
 ifneq ($(GIT_VERSION)," unknown")
        CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
 endif
+ifneq ($(WANT_ZLIB),1)
 LIBZ := -lz
+endif
 LIBPTHREAD := -lpthread
+ifneq ($(findstring Haiku,$(shell uname -s)),)
+LIBDL := -lroot -lnetwork
+else
 LIBDL := -ldl
+endif
+LIBM := -lm
 MMAP_WIN32=0
 EXTRA_LDFLAGS =
 
@@ -36,6 +44,9 @@ EXTRA_LDFLAGS =
 ifeq ($(platform), unix)
        TARGET := $(TARGET_NAME)_libretro.so
        fpic := -fPIC
+ifneq ($(findstring SunOS,$(shell uname -s)),)
+       CC = gcc
+endif
 
 else ifeq ($(platform), linux-portable)
        TARGET := $(TARGET_NAME)_libretro.so
@@ -44,16 +55,22 @@ else ifeq ($(platform), linux-portable)
        LIBZ :=
        LIBPTHREAD :=
        LIBDL :=
+       LIBM :=
        NO_UNDEF_CHECK = 1
 
 # OS X
 else ifeq ($(platform), osx)
+       USE_DYNAREC ?= 1
        TARGET := $(TARGET_NAME)_libretro.dylib
        fpic := -fPIC
        fpic += -mmacosx-version-min=10.1
+ifeq ($(USE_DYNAREC),0)
+       # Override
+       TARGET := $(TARGET_NAME)_interpreter_libretro.dylib
+endif
 
 # iOS
-else ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
+else ifeq ($(platform),$(filter $(platform),ios-arm64))
     ARCH := arm64
     USE_DYNAREC = 0
     HAVE_NEON = 0
@@ -63,8 +80,8 @@ else ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
 else ifneq (,$(findstring ios,$(platform)))
        ARCH := arm
        USE_DYNAREC ?= 1
-    HAVE_NEON = 1
-    BUILTIN_GPU = neon
+       HAVE_NEON = 1
+       BUILTIN_GPU = neon
        TARGET := $(TARGET_NAME)_libretro_ios.dylib
 ifeq ($(USE_DYNAREC),0)
        # Override
@@ -160,7 +177,7 @@ else ifeq ($(platform), ctr)
        CFLAGS += -Werror=implicit-function-declaration
 
 #      CFLAGS += -DPCSX
-#      BUILTIN_GPU = unai
+       BUILTIN_GPU = unai
        USE_DYNAREC = 1
        DRC_CACHE_BASE = 0
        ARCH = arm
@@ -205,6 +222,7 @@ else ifeq ($(platform), qnx)
        MAIN_LDLIBS += -lsocket
        LIBPTHREAD :=
        LIBDL :=
+       LIBM :=
 
 #Raspberry Pi 2
 else ifeq ($(platform), rpi2)
@@ -228,6 +246,41 @@ else ifeq ($(platform), rpi3)
        BUILTIN_GPU = neon
        USE_DYNAREC = 1
 
+# Classic Platforms ####################
+# Platform affix = classic_<ISA>_<µARCH>
+# Help at https://modmyclassic.com/comp
+
+# (armv7 a7, hard point, neon based) ### 
+# NESC, SNESC, C64 mini 
+else ifeq ($(platform), classic_armv7_a7)
+       TARGET := $(TARGET_NAME)_libretro.so
+       fpic := -fPIC
+       CFLAGS += -Ofast \
+       -flto=4 -fwhole-program -fuse-linker-plugin \
+       -fdata-sections -ffunction-sections -Wl,--gc-sections \
+       -fno-stack-protector -fno-ident -fomit-frame-pointer \
+       -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
+       -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
+       -fmerge-all-constants -fno-math-errno \
+       -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
+       CXXFLAGS += $(CFLAGS)
+       CPPFLAGS += $(CFLAGS)
+       ASFLAGS += $(CFLAGS)
+       HAVE_NEON = 1
+       ARCH = arm
+       BUILTIN_GPU = neon
+       USE_DYNAREC = 1
+       ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
+         CFLAGS += -march=armv7-a
+       else
+         CFLAGS += -march=armv7ve
+         # If gcc is 5.0 or later
+         ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
+           LDFLAGS += -static-libgcc -static-libstdc++
+         endif
+       endif
+#######################################
+
 # ARM
 else ifneq (,$(findstring armv,$(platform)))
        TARGET := $(TARGET_NAME)_libretro.so
@@ -236,6 +289,10 @@ else ifneq (,$(findstring armv,$(platform)))
        ifneq (,$(findstring cortexa8,$(platform)))
                CFLAGS += -marm -mcpu=cortex-a8
                ASFLAGS += -mcpu=cortex-a8
+       else ifneq (,$(findstring cortexa7,$(platform)))
+               CFLAGS += -marm -mcpu=cortex-a7
+               ASFLAGS += -mcpu=cortex-a7
+               LIBZ :=
        else ifneq (,$(findstring cortexa9,$(platform)))
                CFLAGS += -marm -mcpu=cortex-a9
                ASFLAGS += -mcpu=cortex-a9
@@ -268,11 +325,12 @@ else
        MAIN_LDLIBS += -lws2_32
        LIBPTHREAD :=
        LIBDL :=
+       LIBM :=
 endif
 
 CFLAGS += $(fpic)
 MAIN_LDFLAGS += -shared
-MAIN_LDLIBS += $(LIBPTHREAD) $(LIBDL) $(LIBZ)
+MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
 
 # try to autodetect stuff for the lazy
 ifndef ARCH
@@ -303,13 +361,14 @@ SOUND_DRIVERS = libretro
 PLUGINS =
 NO_CONFIG_MAK = yes
 
-libretro_all: all
-ifeq ($(platform),ios)
-ifeq ($(USE_DYNAREC),1)
-       make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
-       make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
-endif
-endif
+# what does this do
+#libretro_all: all
+#ifeq ($(platform),ios)
+#ifeq ($(USE_DYNAREC),1)
+#      make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
+#      make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
+#endif
+#endif
 
 include Makefile