prosystem-libretro/Makefile

457 lines
12 KiB
Makefile
Raw Normal View History

2014-08-08 09:01:40 +00:00
DEBUG = 0
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
endif
2014-08-08 09:01:40 +00:00
endif
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
2014-08-08 09:01:40 +00:00
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
2014-08-08 09:01:40 +00:00
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
2014-08-08 09:01:40 +00:00
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
2014-08-08 09:01:40 +00:00
endif
2017-11-08 11:10:01 +00:00
prefix := /usr
libdir := $(prefix)/lib
LIBRETRO_INSTALL_DIR := libretro
2014-08-08 09:01:40 +00:00
TARGET_NAME := prosystem
GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown")
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
2014-08-08 09:01:40 +00:00
# Unix
2014-08-08 09:01:40 +00:00
ifeq ($(platform), unix)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
CFLAGS+=-fsigned-char
# OS X
2014-08-08 09:01:40 +00:00
else ifeq ($(platform), osx)
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(arch),ppc)
FLAGS += -DMSB_FIRST
OLD_GCC = 1
endif
OSXVER = `sw_vers -productVersion | cut -d. -f 2`
OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
fpic += -mmacosx-version-min=10.1
2014-08-08 09:01:40 +00:00
# iOS
2015-10-15 14:26:19 +00:00
else ifneq (,$(findstring ios,$(platform)))
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
2017-09-29 15:31:46 +00:00
ifeq ($(platform),ios-arm64)
CC = clang -arch arm64 -isysroot $(IOSSDK)
else
CC = clang -arch armv7 -isysroot $(IOSSDK)
endif
ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
2015-10-15 14:26:19 +00:00
CC += -miphoneos-version-min=8.0
SHARED += -miphoneos-version-min=8.0
else
CC += -miphoneos-version-min=5.0
SHARED += -miphoneos-version-min=5.0
endif
2014-10-23 07:32:12 +00:00
# Theos
2014-12-23 18:18:17 +00:00
else ifeq ($(platform), theos_ios)
DEPLOYMENT_IOSVERSION = 5.0
TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION)
ARCHS = armv7 armv7s
TARGET_IPHONEOS_DEPLOYMENT_VERSION=$(DEPLOYMENT_IOSVERSION)
THEOS_BUILD_DIR := objs
include $(THEOS)/makefiles/common.mk
2014-12-23 18:18:17 +00:00
LIBRARY_NAME = $(TARGET_NAME)_libretro_ios
2014-12-23 18:18:17 +00:00
# QNX
2014-08-08 09:01:40 +00:00
else ifeq ($(platform), qnx)
2016-09-07 06:20:06 +00:00
TARGET := $(TARGET_NAME)_libretro_$(platform).so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
2014-08-08 09:01:40 +00:00
CC = qcc -Vgcc_ntoarmv7le
# PS3
2014-08-08 09:01:40 +00:00
else ifeq ($(platform), ps3)
2016-09-07 06:20:06 +00:00
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
STATIC_LINKING = 1
2014-08-08 09:01:40 +00:00
FLAGS += -DMSB_FIRST
OLD_GCC = 1
2016-05-29 07:23:41 +00:00
# Lightweight PS3 Homebrew SDK
else ifeq ($(platform), psl1ght)
2016-09-07 06:20:06 +00:00
TARGET := $(TARGET_NAME)_libretro_$(platform).a
2016-05-29 07:23:41 +00:00
CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
STATIC_LINKING = 1
FLAGS += -DMSB_FIRST
OLD_GCC = 1
# sncps3
2014-08-08 09:01:40 +00:00
else ifeq ($(platform), sncps3)
TARGET := $(TARGET_NAME)_libretro_ps3.a
CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
STATIC_LINKING = 1
2014-08-08 09:01:40 +00:00
FLAGS += -DMSB_FIRST
NO_GCC = 1
2016-12-25 17:47:03 +00:00
# Nintendo Game Cube
else ifeq ($(platform), ngc)
EXT=a
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
STATIC_LINKING=1
FLAGS += -DMSB_FIRST
# Nintendo Wii
else ifeq ($(platform), wii)
EXT=a
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
STATIC_LINKING=1
FLAGS += -DMSB_FIRST
2018-01-04 22:09:37 +00:00
# Nintendo Wii
else ifeq ($(platform), wiiu)
EXT=a
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
CFLAGS += -DGEKKO -DWIIU -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
STATIC_LINKING=1
FLAGS += -DMSB_FIRST
# Nintendo Switch (libtransistor)
else ifeq ($(platform), switch)
EXT=a
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
include $(LIBTRANSISTOR_HOME)/libtransistor.mk
STATIC_LINKING=1
# PSP
2014-08-08 09:01:40 +00:00
else ifeq ($(platform), psp1)
2016-09-07 06:20:06 +00:00
TARGET := $(TARGET_NAME)_libretro_$(platform).a
2014-08-08 09:01:40 +00:00
CC = psp-gcc$(EXE_EXT)
AR = psp-ar$(EXE_EXT)
STATIC_LINKING = 1
2015-07-23 20:06:10 +00:00
FLAGS += -G0
2015-08-31 20:16:34 +00:00
# Vita
else ifeq ($(platform), vita)
2016-09-07 06:20:06 +00:00
TARGET := $(TARGET_NAME)_libretro_$(platform).a
2015-08-31 20:16:34 +00:00
CC = arm-vita-eabi-gcc$(EXE_EXT)
AR = arm-vita-eabi-ar$(EXE_EXT)
STATIC_LINKING = 1
FLAGS += -DVITA
2015-09-10 04:19:20 +00:00
# CTR (3DS)
else ifeq ($(platform), ctr)
2016-09-07 06:20:06 +00:00
TARGET := $(TARGET_NAME)_libretro_$(platform).a
2015-09-10 04:19:20 +00:00
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
2018-01-14 17:40:20 +00:00
FLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard
FLAGS += -Wall -mword-relocations
FLAGS += -fomit-frame-pointer -ffast-math
2015-09-10 04:19:20 +00:00
FLAGS += -DARM11 -D_3DS
STATIC_LINKING = 1
2016-02-27 11:02:31 +00:00
# Raspberry Pi 1
else ifeq ($(platform), rpi1)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
CFLAGS+=-fsigned-char
FLAGS += -DARM11
FLAGS += -marm -march=armv6j -mfpu=vfp -mfloat-abi=hard
2016-02-27 11:02:31 +00:00
FLAGS += -fomit-frame-pointer -ffast-math
2016-02-25 14:40:07 +00:00
# Raspberry Pi 2
else ifeq ($(platform), rpi2)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
CFLAGS+=-fsigned-char
FLAGS += -DARM
FLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
FLAGS += -fomit-frame-pointer -ffast-math
# Raspberry Pi 3
else ifeq ($(platform), rpi3)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
CFLAGS+=-fsigned-char
FLAGS += -DARM
FLAGS += -marm -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
2016-02-25 14:40:07 +00:00
FLAGS += -fomit-frame-pointer -ffast-math
2016-09-07 06:20:06 +00:00
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_$(platform).bc
STATIC_LINKING = 1
2017-09-16 05:58:35 +00:00
# Windows MSVC 2003 Xbox 1
else ifeq ($(platform), xbox1_msvc2003)
TARGET := $(TARGET_NAME)_libretro_xdk1.lib
MSVCBINDIRPREFIX = $(XDK)/xbox/bin/vc71
CC = "$(MSVCBINDIRPREFIX)/CL.exe"
CXX = "$(MSVCBINDIRPREFIX)/CL.exe"
LD = "$(MSVCBINDIRPREFIX)/lib.exe"
export INCLUDE := $(XDK)/xbox/include
export LIB := $(XDK)/xbox/lib
PSS_STYLE :=2
CFLAGS += -D_XBOX -D_XBOX1
CXXFLAGS += -D_XBOX -D_XBOX1
STATIC_LINKING=1
HAS_GCC := 0
# Windows MSVC 2010 Xbox 360
else ifeq ($(platform), xbox360_msvc2010)
TARGET := $(TARGET_NAME)_libretro_xdk360.lib
MSVCBINDIRPREFIX = $(XEDK)/bin/win32
CC = "$(MSVCBINDIRPREFIX)/cl.exe"
CXX = "$(MSVCBINDIRPREFIX)/cl.exe"
LD = "$(MSVCBINDIRPREFIX)/lib.exe"
export INCLUDE := $(XEDK)/include/xbox
export LIB := $(XEDK)/lib/xbox
2017-09-16 07:30:08 +00:00
FLAGS += -DMSB_FIRST
2017-09-16 05:58:35 +00:00
PSS_STYLE :=2
CFLAGS += -D_XBOX -D_XBOX360
CXXFLAGS += -D_XBOX -D_XBOX360
STATIC_LINKING=1
HAS_GCC := 0
2017-07-02 20:47:42 +00:00
# Windows MSVC 2010 x64
else ifeq ($(platform), windows_msvc2010_x64)
CC = cl.exe
CXX = cl.exe
PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin/amd64"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include")
LIB := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/lib/amd64")
BIN := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin")
WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib/x64
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib/x64
export INCLUDE := $(INCLUDE)
export LIB := $(LIB);$(WindowsSdkDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
# Windows MSVC 2010 x86
else ifeq ($(platform), windows_msvc2010_x86)
CC = cl.exe
CXX = cl.exe
PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/lib")
BIN := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin")
WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib
export INCLUDE := $(INCLUDE)
export LIB := $(LIB);$(WindowsSdkDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
2017-08-05 12:49:34 +00:00
# Windows MSVC 2005 x86
else ifeq ($(platform), windows_msvc2005_x86)
CC = cl.exe
CXX = cl.exe
PATH := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/include")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS80COMNTOOLS)../../VC/lib")
BIN := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin")
WindowsSdkDir := $(INETSDK)
export INCLUDE := $(INCLUDE);$(INETSDK)/Include;libretro-common/include/compat/msvc
export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
CFLAGS += -D_CRT_SECURE_NO_DEPRECATE
2017-12-24 23:19:12 +00:00
# Windows MSVC 2003 x86
else ifeq ($(platform), windows_msvc2003_x86)
CC = cl.exe
CXX = cl.exe
PATH := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/include")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS71COMNTOOLS)../../Vc7/lib")
BIN := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin")
WindowsSdkDir := $(INETSDK)
export INCLUDE := $(INCLUDE);$(INETSDK)/Include;src/drivers/libretro/msvc/msvc-2005
export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
CFLAGS += -D_CRT_SECURE_NO_DEPRECATE
# Windows
2014-08-08 09:01:40 +00:00
else
TARGET := $(TARGET_NAME)_libretro.dll
CC = gcc
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
LDFLAGS += -static-libgcc -static-libstdc++ -lwinmm
2014-08-08 09:01:40 +00:00
endif
2015-08-07 02:03:01 +00:00
CORE_DIR := core
include Makefile.common
2015-08-31 20:16:34 +00:00
OBJECTS := $(SOURCES_C:.c=.o)
2014-08-08 09:01:40 +00:00
2017-09-16 05:58:35 +00:00
ifeq ($(DEBUG), 1)
ifneq (,$(findstring msvc,$(platform)))
ifeq ($(STATIC_LINKING),1)
CFLAGS += -MTd
CXXFLAGS += -MTd
else
CFLAGS += -MDd
CXXFLAGS += -MDd
endif
CFLAGS += -Od -Zi -DDEBUG -D_DEBUG
CXXFLAGS += -Od -Zi -DDEBUG -D_DEBUG
else
CFLAGS += -O0 -g -DDEBUG
CXXFLAGS += -O0 -g -DDEBUG
endif
else
ifneq (,$(findstring msvc,$(platform)))
ifeq ($(STATIC_LINKING),1)
CFLAGS += -MT
CXXFLAGS += -MT
else
CFLAGS += -MD
CXXFLAGS += -MD
endif
CFLAGS += -O2 -DNDEBUG
CXXFLAGS += -O2 -DNDEBUG
2014-08-08 09:01:40 +00:00
else
2017-09-16 05:58:35 +00:00
CFLAGS += -O2 -DNDEBUG
CXXFLAGS += -O2 -DNDEBUG
endif
2014-08-08 09:01:40 +00:00
endif
2014-12-19 07:48:49 +00:00
LDFLAGS += $(fpic) $(SHARED)
2014-08-08 09:01:40 +00:00
FLAGS += $(fpic)
FLAGS += $(INCFLAGS)
2014-08-08 09:01:40 +00:00
ifeq ($(OLD_GCC), 1)
WARNINGS := -Wall
else ifeq ($(NO_GCC), 1)
WARNINGS :=
2017-07-02 20:47:42 +00:00
else ifneq (,$(findstring msvc,$(platform)))
WARNINGS :=
2014-08-08 09:01:40 +00:00
else
WARNINGS := -Wall \
-Wno-sign-compare \
-Wno-unused-variable \
-Wno-unused-function \
-Wno-uninitialized \
-Wno-strict-aliasing \
-Wno-overflow \
-fno-strict-overflow
endif
FLAGS += -D__LIBRETRO__ $(WARNINGS)
2014-08-08 17:57:18 +00:00
CFLAGS += $(FLAGS)
2014-08-08 09:01:40 +00:00
2017-07-02 20:47:42 +00:00
ifneq (,$(findstring msvc,$(platform)))
OBJOUT = -Fo
LINKOUT = -out:
2017-09-16 05:58:35 +00:00
ifeq ($(STATIC_LINKING),1)
LD ?= lib.exe
STATIC_LINKING=0
else
2017-07-02 20:47:42 +00:00
LD = link.exe
2017-09-16 05:58:35 +00:00
endif
2017-07-02 20:47:42 +00:00
else
OBJOUT = -o
LINKOUT = -o
LD = $(CC)
endif
2014-12-23 18:18:17 +00:00
ifeq ($(platform), theos_ios)
COMMON_FLAGS := -DIOS $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error
$(LIBRARY_NAME)_CFLAGS += $(CFLAGS) $(COMMON_FLAGS)
2015-08-31 20:16:34 +00:00
${LIBRARY_NAME}_FILES = $(SOURCES_C)
2014-12-23 18:18:17 +00:00
include $(THEOS_MAKE_PATH)/library.mk
else
all: $(TARGET)
2014-08-08 09:01:40 +00:00
$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJECTS)
else
2017-07-02 20:47:42 +00:00
$(LD) $(LINKOUT)$@ $^ $(LDFLAGS)
2014-08-08 09:01:40 +00:00
endif
2017-07-02 20:47:42 +00:00
%.o: %.c
$(CC) -c $(OBJOUT)$@ $< $(CFLAGS)
2014-08-08 09:01:40 +00:00
clean:
rm -f $(TARGET) $(OBJECTS)
2017-11-08 11:10:01 +00:00
install:
install -D -m 755 $(TARGET) $(DESTDIR)$(libdir)/$(LIBRETRO_INSTALL_DIR)/$(TARGET)
uninstall:
rm $(DESTDIR)$(libdir)/$(LIBRETRO_INSTALL_DIR)/$(TARGET)
.PHONY: clean install uninstall
2014-12-23 18:18:17 +00:00
endif