Libretro: Makefile for buildbot (#301)

This commit is contained in:
Andrés 2018-01-05 23:12:20 -05:00 committed by SourMesen
parent 21412c488d
commit f3cac34aed
5 changed files with 426 additions and 7 deletions

272
Libretro/Makefile Normal file
View file

@ -0,0 +1,272 @@
STATIC_LINKING := 0
AR := ar
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
else ifneq ($(findstring win,$(shell uname -a)),)
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
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
LIBRETRO_DIR += .
SEVENZIP_DIR += ../SevenZip
LUA_DIR += ../Lua
CORE_DIR += ../Core
UTIL_DIR += ../Utilities
TARGET_NAME := mesen
LIBM = -lm
ifeq ($(ARCHFLAGS),)
ifeq ($(archs),ppc)
ARCHFLAGS = -arch ppc -arch ppc64
else
ARCHFLAGS = -arch i386 -arch x86_64
endif
endif
ifeq ($(platform), osx)
ifndef ($(NOUNIVERSAL))
CXXFLAGS += $(ARCHFLAGS)
LFLAGS += $(ARCHFLAGS)
endif
endif
ifeq ($(STATIC_LINKING), 1)
EXT := a
endif
ifeq ($(platform), unix)
EXT ?= so
TARGET := $(TARGET_NAME)_libretro.$(EXT)
fpic := -fPIC -pthread
SHARED := -shared -Wl,--version-script=$(LIBRETRO_DIR)/link.T -Wl,--no-undefined
else ifeq ($(platform), linux-portable)
TARGET := $(TARGET_NAME)_libretro.$(EXT)
fpic := -fPIC -nostdlib
SHARED := -shared -Wl,--version-script=$(LIBRETRO_DIR)/link.T
LIBM :=
else ifneq (,$(findstring osx,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
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
DEFINES := -DIOS
CC = cc -arch armv7 -isysroot $(IOSSDK)
ifeq ($(platform),ios9)
CC += -miphoneos-version-min=8.0
CXXFLAGS += -miphoneos-version-min=8.0
else
CC += -miphoneos-version-min=5.0
CXXFLAGS += -miphoneos-version-min=5.0
endif
else ifneq (,$(findstring qnx,$(platform)))
TARGET := $(TARGET_NAME)_libretro_qnx.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=$(LIBRETRO_DIR)/link.T -Wl,--no-undefined
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
fpic := -fPIC
SHARED := -shared -Wl,--version-script=$(LIBRETRO_DIR)/link.T -Wl,--no-undefined
else ifeq ($(platform), vita)
TARGET := $(TARGET_NAME)_vita.a
CC = arm-vita-eabi-gcc
AR = arm-vita-eabi-ar
CXXFLAGS += -Wl,-q -Wall -O3
STATIC_LINKING = 1
# Windows MSVC 2017 all architectures
else ifneq (,$(findstring windows_msvc2017,$(platform)))
PlatformSuffix = $(subst windows_msvc2017_,,$(platform))
ifneq (,$(findstring desktop,$(PlatformSuffix)))
WinPartition = desktop
MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -FS -MP -GL -W0 -Gy -Zc:wchar_t -Gm- -Ox -Ob2 -sdl- -Zc:inline -fp:precise -DLIBRETRO -DWIN32 -D_CONSOLE -D_LIB -D_UNICODE -DUNICODE -errorReport:prompt -WX- -Zc:forScope -Gd -Oy -Oi -MT -EHsc -Ot -diagnostics:classic
LDFLAGS += -MANIFEST -LTCG:incremental -NXCOMPAT -DYNAMICBASE -OPT:REF -INCREMENTAL:NO -SUBSYSTEM:WINDOWS -MANIFESTUAC:"level='asInvoker' uiAccess='false'" -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1
LIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
else ifneq (,$(findstring uwp,$(PlatformSuffix)))
WinPartition = uwp
MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -DWINDLL -D_UNICODE -DUNICODE -DWRL_NO_DEFAULT_LIB -FS
LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO
LIBS += WindowsApp.lib
endif
CFLAGS += $(MSVC2017CompileFlags)
CXXFLAGS += $(MSVC2017CompileFlags)
TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix))
CC = cl.exe
CXX = cl.exe
reg_query = $(call filter_out2,$(subst $2,,$(shell reg query "$2" -v "$1" 2>nul)))
fix_path = $(subst $(SPACE),\ ,$(subst \,/,$1))
ProgramFiles86w := $(shell cmd /c "echo %PROGRAMFILES(x86)%")
ProgramFiles86 := $(shell cygpath "$(ProgramFiles86w)")
WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
WindowsSdkDir := $(WindowsSdkDir)
WindowsSDKVersion ?= $(firstword $(foreach folder,$(subst $(subst \,/,$(WindowsSdkDir)Include/),,$(wildcard $(call fix_path,$(WindowsSdkDir)Include\*))),$(if $(wildcard $(call fix_path,$(WindowsSdkDir)Include/$(folder)/um/Windows.h)),$(folder),)))$(BACKSLASH)
WindowsSDKVersion := $(WindowsSDKVersion)
VsInstallBuildTools = $(ProgramFiles86)/Microsoft Visual Studio/2017/BuildTools
VsInstallEnterprise = $(ProgramFiles86)/Microsoft Visual Studio/2017/Enterprise
VsInstallProfessional = $(ProgramFiles86)/Microsoft Visual Studio/2017/Professional
VsInstallCommunity = $(ProgramFiles86)/Microsoft Visual Studio/2017/Community
VsInstallRoot ?= $(shell if [ -d "$(VsInstallBuildTools)" ]; then echo "$(VsInstallBuildTools)"; fi)
ifeq ($(VsInstallRoot), )
VsInstallRoot = $(shell if [ -d "$(VsInstallEnterprise)" ]; then echo "$(VsInstallEnterprise)"; fi)
endif
ifeq ($(VsInstallRoot), )
VsInstallRoot = $(shell if [ -d "$(VsInstallProfessional)" ]; then echo "$(VsInstallProfessional)"; fi)
endif
ifeq ($(VsInstallRoot), )
VsInstallRoot = $(shell if [ -d "$(VsInstallCommunity)" ]; then echo "$(VsInstallCommunity)"; fi)
endif
VsInstallRoot := $(VsInstallRoot)
VcCompilerToolsVer := $(shell cat "$(VsInstallRoot)/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | grep -o '[0-9\.]*')
VcCompilerToolsDir := $(VsInstallRoot)/VC/Tools/MSVC/$(VcCompilerToolsVer)
WindowsSDKSharedIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\shared")
WindowsSDKUCRTIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\ucrt")
WindowsSDKUMIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\um")
WindowsSDKUCRTLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\ucrt\$(TargetArchMoniker)")
WindowsSDKUMLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\um\$(TargetArchMoniker)")
# For some reason the HostX86 compiler doesn't like compiling for x64
# ("no such file" opening a shared library), and vice-versa.
# Work around it for now by using the strictly x86 compiler for x86, and x64 for x64.
# NOTE: What about ARM?
ifneq (,$(findstring x64,$(TargetArchMoniker)))
VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX64
else
VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX86
endif
PATH := $(shell IFS=$$'\n'; cygpath "$(VCCompilerToolsBinDir)/$(TargetArchMoniker)"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VsInstallRoot)/Common7/IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/include")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/lib/$(TargetArchMoniker)")
export INCLUDE := $(INCLUDE);$(WindowsSDKSharedIncludeDir);$(WindowsSDKUCRTIncludeDir);$(WindowsSDKUMIncludeDir)
export LIB := $(LIB);$(WindowsSDKUCRTLibDir);$(WindowsSDKUMLibDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
LIBM :=
else
CC = gcc
CXX = g++
TARGET := $(TARGET_NAME)_libretro.dll
SHARED := -shared -s -Wl,--version-script=$(LIBRETRO_DIR)/link.T -Wl,--no-undefined
endif
LDFLAGS += $(LIBM)
ifeq ($(LTO),true)
CFLAGS += -flto
CXXFLAGS += -flto
LD = g++
endif
ifeq ($(DEBUG), 1)
ifneq (,$(findstring msvc,$(platform)))
CFLAGS += -MTd -Od -Zi -DDEBUG -D_DEBUG
CXXFLAGS += -MTd -Od -Zi -DDEBUG -D_DEBUG
else
CFLAGS += -O0 -g
CXXFLAGS += -O0 -g
endif
else
ifneq (,$(findstring msvc,$(platform)))
CFLAGS += -MT -O2 -DNDEBUG
CXXFLAGS += -MT -O2 -DNDEBUG
else
CFLAGS += -O3
CXXFLAGS += -O3
endif
endif
ifneq (,$(findstring msvc,$(platform)))
OBJOUT = -Fo
LINKOUT = -out:
ifeq ($(STATIC_LINKING),1)
LD ?= lib.exe
STATIC_LINKING=0
else
LD = link.exe
endif
else
OBJOUT = -o
LINKOUT = -o
LD = $(CC)
endif
include Makefile.common
OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o)
CFLAGS += -Wall -D LIBRETRO $(fpic)
CXXFLAGS += -Wall -D LIBRETRO $(fpic) -std=c++17
all: $(TARGET)
$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
ifneq (,$(findstring msvc,$(platform)))
$(LD) $(LINKOUT)$@ $(OBJECTS)
else
$(AR) rcs $@ $(OBJECTS)
endif
else
$(LD) $(fpic) $(SHARED) $(INCLUDES) $(LINKOUT)$@ $(OBJECTS) $(LDFLAGS)
endif
%.o: %.c
$(CC) $(CFLAGS) $(fpic) -c $< $(OBJOUT)$@
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(fpic) -c $< $(OBJOUT)$@
clean:
rm -f $(OBJECTS) $(TARGET)
.PHONY: clean
print-%:
@echo '$*=$($*)'

148
Libretro/Makefile.common Normal file
View file

@ -0,0 +1,148 @@
SOURCES_C := $(SEVENZIP_DIR)/7zAlloc.c \
$(SEVENZIP_DIR)/7zArcIn.c \
$(SEVENZIP_DIR)/7zBuf.c \
$(SEVENZIP_DIR)/7zCrc.c \
$(SEVENZIP_DIR)/7zCrcOpt.c \
$(SEVENZIP_DIR)/7zDec.c \
$(SEVENZIP_DIR)/7zFile.c \
$(SEVENZIP_DIR)/7zMemBuffer.c \
$(SEVENZIP_DIR)/7zStream.c \
$(SEVENZIP_DIR)/Bcj2.c \
$(SEVENZIP_DIR)/Bra.c \
$(SEVENZIP_DIR)/Bra86.c \
$(SEVENZIP_DIR)/BraIA64.c \
$(SEVENZIP_DIR)/CpuArch.c \
$(SEVENZIP_DIR)/Delta.c \
$(SEVENZIP_DIR)/Lzma2Dec.c \
$(SEVENZIP_DIR)/LzmaDec.c \
$(SEVENZIP_DIR)/Ppmd7.c \
$(SEVENZIP_DIR)/Ppmd7Dec.c \
$(SEVENZIP_DIR)/Precomp.c \
SOURCES_CXX := $(LIBRETRO_DIR)/libretro.cpp \
$(CORE_DIR)/APU.cpp \
$(CORE_DIR)/ApuLengthCounter.cpp \
$(CORE_DIR)/Assembler.cpp \
$(CORE_DIR)/AutomaticRomTest.cpp \
$(CORE_DIR)/AutoSaveManager.cpp \
$(CORE_DIR)/AviRecorder.cpp \
$(CORE_DIR)/BaseControlDevice.cpp \
$(CORE_DIR)/BaseMapper.cpp \
$(CORE_DIR)/BaseRenderer.cpp \
$(CORE_DIR)/BaseVideoFilter.cpp \
$(CORE_DIR)/BatteryManager.cpp \
$(CORE_DIR)/BisqwitNtscFilter.cpp \
$(CORE_DIR)/BizhawkMovie.cpp \
$(CORE_DIR)/Breakpoint.cpp \
$(CORE_DIR)/CheatManager.cpp \
$(CORE_DIR)/CodeDataLogger.cpp \
$(CORE_DIR)/CodeRunner.cpp \
$(CORE_DIR)/Console.cpp \
$(CORE_DIR)/ControlManager.cpp \
$(CORE_DIR)/CPU.cpp \
$(CORE_DIR)/CrossFeedFilter.cpp \
$(CORE_DIR)/Debugger.cpp \
$(CORE_DIR)/DebugHud.cpp \
$(CORE_DIR)/DefaultVideoFilter.cpp \
$(CORE_DIR)/DeltaModulationChannel.cpp \
$(CORE_DIR)/Disassembler.cpp \
$(CORE_DIR)/DisassemblyInfo.cpp \
$(CORE_DIR)/EmulationSettings.cpp \
$(CORE_DIR)/ExpressionEvaluator.cpp \
$(CORE_DIR)/FceuxMovie.cpp \
$(CORE_DIR)/FDS.cpp \
$(CORE_DIR)/GameClient.cpp \
$(CORE_DIR)/GameClientConnection.cpp \
$(CORE_DIR)/GameConnection.cpp \
$(CORE_DIR)/GameDatabase.cpp \
$(CORE_DIR)/GameServer.cpp \
$(CORE_DIR)/GameServerConnection.cpp \
$(CORE_DIR)/HdAudioDevice.cpp \
$(CORE_DIR)/HdNesPack.cpp \
$(CORE_DIR)/HdPackBuilder.cpp \
$(CORE_DIR)/HdPackLoader.cpp \
$(CORE_DIR)/HdVideoFilter.cpp \
$(CORE_DIR)/iNesLoader.cpp \
$(CORE_DIR)/KeyManager.cpp \
$(CORE_DIR)/LabelManager.cpp \
$(CORE_DIR)/MapperFactory.cpp \
$(CORE_DIR)/MemoryAccessCounter.cpp \
$(CORE_DIR)/MemoryDumper.cpp \
$(CORE_DIR)/MemoryManager.cpp \
$(CORE_DIR)/MesenMovie.cpp \
$(CORE_DIR)/MessageManager.cpp \
$(CORE_DIR)/MovieManager.cpp \
$(CORE_DIR)/MovieRecorder.cpp \
$(CORE_DIR)/NsfMapper.cpp \
$(CORE_DIR)/NtscFilter.cpp \
$(CORE_DIR)/OggMixer.cpp \
$(CORE_DIR)/OggReader.cpp \
$(CORE_DIR)/PPU.cpp \
$(CORE_DIR)/Profiler.cpp \
$(CORE_DIR)/RecordedRomTest.cpp \
$(CORE_DIR)/ReverbFilter.cpp \
$(CORE_DIR)/RewindData.cpp \
$(CORE_DIR)/RewindManager.cpp \
$(CORE_DIR)/RomLoader.cpp \
$(CORE_DIR)/RotateFilter.cpp \
$(CORE_DIR)/SaveStateManager.cpp \
$(CORE_DIR)/ScaleFilter.cpp \
$(CORE_DIR)/ScriptHost.cpp \
$(CORE_DIR)/ScriptingContext.cpp \
$(CORE_DIR)/ShortcutKeyHandler.cpp \
$(CORE_DIR)/Snapshotable.cpp \
$(CORE_DIR)/SoundMixer.cpp \
$(CORE_DIR)/stdafx.cpp \
$(CORE_DIR)/StereoDelayFilter.cpp \
$(CORE_DIR)/StereoPanningFilter.cpp \
$(CORE_DIR)/TraceLogger.cpp \
$(CORE_DIR)/UnifLoader.cpp \
$(CORE_DIR)/VideoDecoder.cpp \
$(CORE_DIR)/VideoHud.cpp \
$(CORE_DIR)/VideoRenderer.cpp \
$(CORE_DIR)/VirtualFile.cpp \
$(CORE_DIR)/VsControlManager.cpp \
$(CORE_DIR)/WaveRecorder.cpp \
$(UTIL_DIR)/ArchiveReader.cpp \
$(UTIL_DIR)/AutoResetEvent.cpp \
$(UTIL_DIR)/AviWriter.cpp \
$(UTIL_DIR)/blip_buf.cpp \
$(UTIL_DIR)/BpsPatcher.cpp \
$(UTIL_DIR)/CamstudioCodec.cpp \
$(UTIL_DIR)/CRC32.cpp \
$(UTIL_DIR)/FolderUtilities.cpp \
$(UTIL_DIR)/HexUtilities.cpp \
$(UTIL_DIR)/IpsPatcher.cpp \
$(UTIL_DIR)/md5.cpp \
$(UTIL_DIR)/miniz.cpp \
$(UTIL_DIR)/nes_ntsc.cpp \
$(UTIL_DIR)/PlatformUtilities.cpp \
$(UTIL_DIR)/PNGHelper.cpp \
$(UTIL_DIR)/sha1.cpp \
$(UTIL_DIR)/SimpleLock.cpp \
$(UTIL_DIR)/Socket.cpp \
$(UTIL_DIR)/stb_vorbis.cpp \
$(UTIL_DIR)/stdafx.cpp \
$(UTIL_DIR)/SZReader.cpp \
$(UTIL_DIR)/Timer.cpp \
$(UTIL_DIR)/UpsPatcher.cpp \
$(UTIL_DIR)/UTF8Util.cpp \
$(UTIL_DIR)/ZipReader.cpp \
$(UTIL_DIR)/ZipWriter.cpp \
$(UTIL_DIR)/ZmbvCodec.cpp \
$(UTIL_DIR)/HQX/hq2x.cpp \
$(UTIL_DIR)/HQX/hq3x.cpp \
$(UTIL_DIR)/HQX/hq4x.cpp \
$(UTIL_DIR)/HQX/init.cpp \
$(UTIL_DIR)/KreedSaiEagle/2xSai.cpp \
$(UTIL_DIR)/KreedSaiEagle/Super2xSai.cpp \
$(UTIL_DIR)/KreedSaiEagle/SuperEagle.cpp \
$(UTIL_DIR)/Scale2x/scale2x.cpp \
$(UTIL_DIR)/Scale2x/scale3x.cpp \
$(UTIL_DIR)/Scale2x/scalebit.cpp \
$(UTIL_DIR)/xBRZ/xbrz.cpp \
#LUAOBJ=$(patsubst Lua/%.c,Lua/$(OBJFOLDER)/%.o,$(wildcard Lua/*.c))
#COREOBJ=$(patsubst Core/%.cpp,Core/$(OBJFOLDER)/%.o,$(wildcard Core/*.cpp))
#UTILOBJ=$(patsubst Utilities/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/*.cpp)) $(patsubst Utilities/HQX/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/HQX/*.cpp)) $(patsubst Utilities/xBRZ/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/xBRZ/*.cpp)) $(patsubst Utilities/KreedSaiEagle/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/KreedSaiEagle/*.cpp)) $(patsubst Utilities/Scale2x/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/Scale2x/*.cpp))

5
Libretro/link.T Normal file
View file

@ -0,0 +1,5 @@
{
global: retro_*;
local: *;
};

View file

@ -1,7 +1 @@
#pragma once
#if _WIN32 || _WIN64
#pragma comment(lib, "Core.lib")
#pragma comment(lib, "Utilities.lib")
#pragma comment(lib, "SevenZip.lib")
#endif

View file

@ -11,7 +11,7 @@ namespace utf8 {
static std::string encode(const std::u16string &wstr);
};
#ifdef _WIN32
#if defined(_WIN32) && !defined(LIBRETRO)
class ifstream : public std::ifstream
{
public: