Mesen/makefile

142 lines
6.3 KiB
Makefile
Raw Normal View History

2016-12-17 23:17:34 -05:00
#Welcome to what must be the most terrible makefile ever (but hey, it works)
#Both clang & gcc work fine - clang seems to output faster code
#The only external dependency is SDL2 - everything else is pretty standard.
#Run "make" to build, "make run" to run
#----------------------
#Platform Configuration
#----------------------
2016-12-22 18:44:54 -05:00
#To specify whether you want to build for x86 or x64:
#"MESENPLATFORM=x86 make" or "MESENPLATFORM=x64 make"
#Default is x64
2016-12-17 23:17:34 -05:00
#-----------------------
# Link Time Optimization
#-----------------------
2018-03-24 12:14:39 -04:00
#LTO is supported for clang and gcc (but only seems to help for clang?)
#LTO gives a 25-30% performance boost, so use it whenever you can
#Usage: LTO=true make
2018-01-04 23:09:07 -05:00
MESENFLAGS=
libretro : MESENFLAGS=-D LIBRETRO
2016-12-17 23:17:34 -05:00
CPPC=clang++
2018-03-24 11:22:43 -04:00
GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 $(MESENFLAGS) -Wno-parentheses -Wno-switch
2016-12-17 23:17:34 -05:00
CC=clang
2018-01-04 23:09:07 -05:00
CCOPTIONS=-fPIC -Wall -O3 $(MESENFLAGS)
2016-12-17 23:17:34 -05:00
2016-12-22 18:44:54 -05:00
ifeq ($(MESENPLATFORM),x86)
MESENPLATFORM=x86
GCCOPTIONS += -m32
CCOPTIONS += -m32
else
MESENPLATFORM=x64
GCCOPTIONS += -m64
CCOPTIONS += -m64
endif
ifeq ($(LTO),true)
CCOPTIONS += -flto
GCCOPTIONS += -flto
endif
2016-12-22 18:44:54 -05:00
OBJFOLDER=obj.$(MESENPLATFORM)
SHAREDLIB=libMesenCore.$(MESENPLATFORM).dll
2018-01-04 23:09:07 -05:00
LIBRETROLIB=mesen_libretro.$(MESENPLATFORM).so
2016-12-22 18:44:54 -05:00
RELEASEFOLDER=bin/$(MESENPLATFORM)/Release
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))
LINUXOBJ=$(patsubst Linux/%.cpp,Linux/$(OBJFOLDER)/%.o,$(wildcard Linux/*.cpp))
SEVENZIPOBJ=$(patsubst SevenZip/%.c,SevenZip/$(OBJFOLDER)/%.o,$(wildcard SevenZip/*.c))
LUAOBJ=$(patsubst Lua/%.c,Lua/$(OBJFOLDER)/%.o,$(wildcard Lua/*.c))
ifeq ($(SYSTEM_LIBEVDEV), true)
LIBEVDEVLIB=$(shell pkg-config --libs libevdev)
LIBEVDEVINC=$(shell pkg-config --cflags libevdev)
else
LIBEVDEVOBJ=$(patsubst Linux/libevdev/%.c,Linux/$(OBJFOLDER)/%.o,$(wildcard Linux/libevdev/*.c))
LIBEVDEVINC=-I../
endif
SDL2LIB=$(shell sdl2-config --libs)
SDL2INC=$(shell sdl2-config --cflags)
FSLIB=-lstdc++fs
2016-12-17 23:17:34 -05:00
all: ui
2016-12-22 18:44:54 -05:00
ui: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
2016-12-17 23:17:34 -05:00
mkdir -p $(RELEASEFOLDER)/Dependencies
rm -f $(RELEASEFOLDER)/Dependencies/*
cd UpdateHelper && xbuild /property:Configuration="Release" /property:Platform="AnyCPU"
cp "bin/Any CPU/Release/MesenUpdater.exe" $(RELEASEFOLDER)/Dependencies/
2016-12-17 23:17:34 -05:00
cp GUI.NET/Dependencies/* $(RELEASEFOLDER)/Dependencies/
2016-12-22 18:44:54 -05:00
cp InteropDLL/$(OBJFOLDER)/$(SHAREDLIB) $(RELEASEFOLDER)/Dependencies/$(SHAREDLIB)
cd $(RELEASEFOLDER)/Dependencies && zip ../Dependencies.zip *
2017-05-22 22:29:58 -04:00
cd GUI.NET && xbuild /property:Configuration="Release" /property:Platform="$(MESENPLATFORM)" /property:PreBuildEvent="" /property:DefineConstants="HIDETESTMENU,DISABLEAUTOUPDATE"
2016-12-22 18:44:54 -05:00
2018-01-04 23:09:07 -05:00
libretro: Libretro/$(OBJFOLDER)/$(LIBRETROLIB)
cp ./Libretro/$(OBJFOLDER)/$(LIBRETROLIB) ./bin
2016-12-22 18:44:54 -05:00
core: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
2016-12-17 23:17:34 -05:00
runtests:
2016-12-22 18:44:54 -05:00
cd TestHelper/$(OBJFOLDER) && ./testhelper
2016-12-17 23:17:34 -05:00
rungametests:
2016-12-22 18:44:54 -05:00
cd TestHelper/$(OBJFOLDER) && ./testhelper ~/Mesen/TestGames
testhelper: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
mkdir -p TestHelper/$(OBJFOLDER)
$(CPPC) $(GCCOPTIONS) -Wl,-z,defs -o testhelper TestHelper/*.cpp InteropDLL/ConsoleWrapper.cpp $(SEVENZIPOBJ) $(LUAOBJ) $(LINUXOBJ) $(LIBEVDEVOBJ) $(UTILOBJ) $(COREOBJ) -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB)
2018-03-24 12:14:39 -04:00
mv testhelper TestHelper/$(OBJFOLDER)
2016-12-22 18:44:54 -05:00
SevenZip/$(OBJFOLDER)/%.o: SevenZip/%.c
mkdir -p SevenZip/$(OBJFOLDER) && cd SevenZip/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst SevenZip/%, ../%, $<)
Lua/$(OBJFOLDER)/%.o: Lua/%.c
mkdir -p Lua/$(OBJFOLDER) && cd Lua/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst Lua/%, ../%, $<)
2016-12-22 18:44:54 -05:00
Utilities/$(OBJFOLDER)/%.o: Utilities/%.cpp
mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Utilities/$(OBJFOLDER)/%.o: Utilities/HQX/%.cpp
mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Utilities/$(OBJFOLDER)/%.o: Utilities/xBRZ/%.cpp
mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Utilities/$(OBJFOLDER)/%.o: Utilities/KreedSaiEagle/%.cpp
mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Utilities/$(OBJFOLDER)/%.o: Utilities/Scale2x/%.cpp
mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Core/$(OBJFOLDER)/%.o: Core/%.cpp
2018-03-24 11:22:43 -04:00
mkdir -p Core/$(OBJFOLDER) && cd Core/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Core/%, ../%, $<)
2016-12-22 18:44:54 -05:00
Linux/$(OBJFOLDER)/%.o: Linux/%.cpp
mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Linux/%, ../%, $<) $(SDL2INC) $(LIBEVDEVINC)
2016-12-22 18:44:54 -05:00
Linux/$(OBJFOLDER)/%.o: Linux/libevdev/%.c
2018-03-24 11:22:43 -04:00
mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst Linux/%, ../%, $<)
2016-12-22 18:44:54 -05:00
InteropDLL/$(OBJFOLDER)/$(SHAREDLIB): $(SEVENZIPOBJ) $(LUAOBJ) $(UTILOBJ) $(COREOBJ) $(LIBEVDEVOBJ) $(LINUXOBJ) InteropDLL/ConsoleWrapper.cpp InteropDLL/DebugWrapper.cpp
2016-12-22 18:44:54 -05:00
mkdir -p InteropDLL/$(OBJFOLDER)
$(CPPC) $(GCCOPTIONS) -Wl,-z,defs -shared -o $(SHAREDLIB) InteropDLL/*.cpp $(SEVENZIPOBJ) $(LUAOBJ) $(LINUXOBJ) $(LIBEVDEVOBJ) $(UTILOBJ) $(COREOBJ) $(SDL2INC) -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB)
2018-03-24 12:14:39 -04:00
mv $(SHAREDLIB) InteropDLL/$(OBJFOLDER)
2018-01-04 23:09:07 -05:00
2018-03-24 12:14:39 -04:00
Libretro/$(OBJFOLDER)/$(LIBRETROLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) $(LUAOBJ) Libretro/libretro.cpp
2018-01-04 23:09:07 -05:00
mkdir -p Libretro/$(OBJFOLDER)
$(CPPC) $(GCCOPTIONS) -Wl,-z,defs -shared -o $(LIBRETROLIB) Libretro/*.cpp $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) $(LUAOBJ) -pthread $(FSLIB)
2018-03-24 12:14:39 -04:00
mv $(LIBRETROLIB) Libretro/$(OBJFOLDER)
2018-01-04 23:09:07 -05:00
debug:
MONO_LOG_LEVEL=debug mono $(RELEASEFOLDER)/Mesen.exe
2016-12-17 23:17:34 -05:00
run:
mono $(RELEASEFOLDER)/Mesen.exe
2016-12-17 23:17:34 -05:00
clean:
rm -rf Lua/$(OBJFOLDER)
rm -rf SevenZip/$(OBJFOLDER)
rm -rf Utilities/$(OBJFOLDER)
rm -rf Core/$(OBJFOLDER)
rm -rf Linux/$(OBJFOLDER)
rm -rf InteropDLL/$(OBJFOLDER)
rm -rf Libretro/$(OBJFOLDER)
rm -rf TestHelper/$(OBJFOLDER)
rm -rf $(RELEASEFOLDER)