vemulator-libretro/Makefile

204 lines
4.7 KiB
Makefile
Raw Permalink Normal View History

2018-02-14 18:19:48 +00:00
STATIC_LINKING := 0
2020-10-08 01:48:23 +00:00
CORE_DIR := .
2018-02-14 18:19:48 +00:00
2021-03-27 07:14:41 +00:00
CFLAGS :=
2021-11-17 20:46:42 +00:00
CXXFLAGS :=
2021-03-27 07:14:41 +00:00
2021-03-27 07:12:26 +00:00
# platform
2018-02-14 18:19:48 +00:00
ifeq ($(platform),)
platform = unix
2021-03-27 07:12:26 +00:00
ifeq ($(shell uname -s),)
2018-02-14 18:19:48 +00:00
platform = win
2021-03-27 07:12:26 +00:00
else ifneq ($(findstring MINGW,$(shell uname -s)),)
2018-02-14 18:19:48 +00:00
platform = win
2021-03-27 07:12:26 +00:00
else ifneq ($(findstring Darwin,$(shell uname -s)),)
2018-02-14 18:19:48 +00:00
platform = osx
2021-03-27 07:12:26 +00:00
else ifneq ($(findstring win,$(shell uname -s)),)
2018-02-14 18:19:48 +00:00
platform = win
endif
endif
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
ifeq ($(shell uname -p),arm)
arch = arm
endif
2018-02-14 18:19:48 +00:00
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
TARGET_NAME := vemulator
LIBM = -lm
ifeq ($(STATIC_LINKING), 1)
EXT := a
endif
ifneq ($(findstring unix,$(platform)),)
2018-02-14 18:19:48 +00:00
EXT ?= so
TARGET := $(TARGET_NAME)_libretro.$(EXT)
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
else ifeq ($(platform), linux-portable)
TARGET := $(TARGET_NAME)_libretro.$(EXT)
fpic := -fPIC -nostdlib
SHARED := -shared -Wl,--version-script=link.T
LIBM :=
2021-03-27 07:01:09 +00:00
else ifeq ($(platform), osx)
2018-02-14 18:19:48 +00:00
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(CROSS_COMPILE),1)
TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
CFLAGS += $(TARGET_RULE)
CPPFLAGS += $(TARGET_RULE)
CXXFLAGS += $(TARGET_RULE)
LDFLAGS += $(TARGET_RULE)
endif
CFLAGS += $(ARCHFLAGS)
LFLAGS += $(ARCHFLAGS)
2018-02-14 18:19:48 +00:00
else ifneq (,$(findstring ios,$(platform)))
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
2021-03-12 04:12:46 +00:00
MINVERSION :=
2018-02-14 18:19:48 +00:00
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
2021-03-12 04:12:46 +00:00
ifeq ($(platform),ios-arm64)
CC = cc -arch arm64 -isysroot $(IOSSDK)
CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
else
CC = cc -arch armv7 -isysroot $(IOSSDK)
CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
endif
ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
MINVERSION = -miphoneos-version-min=8.0
2018-02-14 18:19:48 +00:00
else
2021-03-12 04:12:46 +00:00
MINVERSION = -miphoneos-version-min=5.0
2018-02-14 18:19:48 +00:00
endif
2021-03-12 04:12:46 +00:00
CFLAGS += $(MINVERSION)
CXXFLAGS += $(MINVERSION)
LDFLAGS += $(MINVERSION)
2021-03-12 04:12:46 +00:00
else ifeq ($(platform), tvos-arm64)
TARGET := $(TARGET_NAME)_libretro_tvos.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
endif
2021-11-17 20:46:42 +00:00
CFLAGS += -DIOS
2021-03-12 04:12:46 +00:00
CXXFLAGS += -DIOS
CC = cc -arch arm64 -isysroot $(IOSSDK)
CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
2018-02-14 18:19:48 +00:00
else ifneq (,$(findstring qnx,$(platform)))
TARGET := $(TARGET_NAME)_libretro_qnx.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
else ifeq ($(platform), vita)
2020-10-08 02:24:52 +00:00
TARGET := $(TARGET_NAME)_libretro_$(platform).a
2020-10-08 02:22:41 +00:00
CC ?= arm-vita-eabi-gcc
CXX ?= arm-vita-eabi-g++
AR ?= arm-vita-eabi-ar
2021-11-17 20:46:42 +00:00
CFLAGS += -Wl,-q -Wall
CXXFLAGS += -Wl,-q -Wall
STATIC_LINKING = 1
2023-03-10 22:26:22 +00:00
else ifeq ($(platform), miyoo)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
CC = /opt/miyoo/usr/bin/arm-linux-gcc
CXX = /opt/miyoo/usr/bin/arm-linux-g++
AR = /opt/miyoo/usr/bin/arm-linux-ar
PLATFORM_DEFINES += -D_GNU_SOURCE
CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s
2018-02-14 18:19:48 +00:00
else
2020-10-08 01:48:23 +00:00
CC ?= gcc
CXX ?= g++
2018-02-14 18:19:48 +00:00
TARGET := $(TARGET_NAME)_libretro.dll
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined
endif
LDFLAGS += $(LIBM)
ifeq ($(DEBUG), 1)
2021-11-17 20:46:42 +00:00
CXXFLAGS += -O0 -g
2018-02-14 18:19:48 +00:00
else
2021-11-17 20:46:42 +00:00
CXXFLAGS += -O3
2018-02-14 18:19:48 +00:00
endif
2020-10-08 01:48:23 +00:00
include Makefile.common
2021-11-17 20:46:42 +00:00
OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o)
CFLAGS += -Wall -pedantic $(fpic)
CFLAGS += $(INCFLAGS) $(INCFLAGS_PLATFORM)
CXXFLAGS += -Wall -pedantic $(fpic)
CXXFLAGS += $(INCFLAGS) $(INCFLAGS_PLATFORM)
2018-02-14 18:19:48 +00:00
ifneq (,$(findstring qnx,$(platform)))
2021-11-17 20:46:42 +00:00
CXXFLAGS += -Wc,-std=c++98
2018-02-14 18:19:48 +00:00
else
2021-11-17 20:46:42 +00:00
CXXFLAGS += -std=c++98
2018-02-14 18:19:48 +00:00
endif
2020-10-08 03:04:38 +00:00
OBJOUT = -o
LINKOUT = -o
ifneq (,$(findstring msvc,$(platform)))
OBJOUT = -Fo
LINKOUT = -out:
ifeq ($(STATIC_LINKING),1)
LD ?= lib.exe
STATIC_LINKING=0
else
LD = link.exe
endif
else
LD = $(CXX)
endif
2020-10-08 01:48:23 +00:00
all: $(TARGET)
2018-02-14 18:19:48 +00:00
2020-10-08 01:48:23 +00:00
$(TARGET): $(OBJECTS)
2018-02-14 18:19:48 +00:00
ifeq ($(STATIC_LINKING), 1)
2020-10-08 01:48:23 +00:00
$(AR) rcs $@ $(OBJECTS)
2018-02-14 18:19:48 +00:00
else
2020-10-08 03:04:38 +00:00
$(LD) $(fpic) $(SHARED) $(LINKOUT)$@ $(OBJECTS) $(LDFLAGS)
2018-02-14 18:19:48 +00:00
endif
2020-10-08 01:48:23 +00:00
%.o: %.cpp
2021-11-17 20:46:42 +00:00
$(CXX) $(INCLUDES) $(CXXFLAGS) $(fpic) -c $(OBJOUT)$@ $<
2020-10-08 01:48:23 +00:00
%.o: %.c
2020-10-08 03:04:38 +00:00
$(CC) $(INCLUDES) $(CFLAGS) $(fpic) -c $(OBJOUT)$@ $<
2020-10-08 01:48:23 +00:00
2018-02-14 18:19:48 +00:00
clean:
2021-11-17 21:18:14 +00:00
rm -f $(TARGET) $(OBJECTS)
2018-02-14 18:19:48 +00:00
.PHONY: clean