This repository has been archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 320
/
makefile
179 lines (149 loc) · 7.28 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#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
#----------------------
#To specify whether you want to build for x86 or x64:
#"MESENPLATFORM=x86 make" or "MESENPLATFORM=x64 make"
#Default is x64
#-----------------------
# Link Time Optimization
#-----------------------
#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
MESENFLAGS=
libretro : MESENFLAGS=-D LIBRETRO
ifeq ($(USE_GCC),true)
CPPC=g++
CC=gcc
PROFILE_GEN_FLAG=-fprofile-generate
PROFILE_USE_FLAG=-fprofile-use
else
CPPC=clang++
CC=clang
PROFILE_GEN_FLAG = -fprofile-instr-generate=$(CURDIR)/PGOHelper/pgo.profraw
PROFILE_USE_FLAG = -fprofile-instr-use=$(CURDIR)/PGOHelper/pgo.profdata
endif
GCCOPTIONS=-fPIC -Wall --std=c++17 -O3 $(MESENFLAGS)
CCOPTIONS=-fPIC -Wall -O3 $(MESENFLAGS)
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
ifeq ($(PGO),profile)
CCOPTIONS += ${PROFILE_GEN_FLAG}
GCCOPTIONS += ${PROFILE_GEN_FLAG}
endif
ifeq ($(PGO),optimize)
CCOPTIONS += ${PROFILE_USE_FLAG}
GCCOPTIONS += ${PROFILE_USE_FLAG}
endif
ifeq ($(STATICLINK),true)
LINKOPTIONS += -static-libgcc -static-libstdc++
endif
OBJFOLDER=obj.$(MESENPLATFORM)
SHAREDLIB=libMesenCore.$(MESENPLATFORM).dll
LIBRETROLIB=mesen_libretro.$(MESENPLATFORM).so
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
all: ui
ui: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
mkdir -p $(RELEASEFOLDER)/Dependencies
rm -fr $(RELEASEFOLDER)/Dependencies/*
cd UpdateHelper && xbuild /property:Configuration="Release" /property:Platform="AnyCPU"
cp "bin/Any CPU/Release/MesenUpdater.exe" $(RELEASEFOLDER)/Dependencies/
cp -r GUI.NET/Dependencies/* $(RELEASEFOLDER)/Dependencies/
cp InteropDLL/$(OBJFOLDER)/$(SHAREDLIB) $(RELEASEFOLDER)/Dependencies/$(SHAREDLIB)
cd $(RELEASEFOLDER)/Dependencies && zip -r ../Dependencies.zip *
cd GUI.NET && xbuild /property:Configuration="Release" /property:Platform="$(MESENPLATFORM)" /property:PreBuildEvent="" /property:DefineConstants="HIDETESTMENU,DISABLEAUTOUPDATE"
libretro: Libretro/$(OBJFOLDER)/$(LIBRETROLIB)
mkdir -p bin
cp ./Libretro/$(OBJFOLDER)/$(LIBRETROLIB) ./bin/
core: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
runtests:
cd TestHelper/$(OBJFOLDER) && ./testhelper
rungametests:
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)
mv testhelper TestHelper/$(OBJFOLDER)
pgohelper:
mkdir -p PGOHelper/$(OBJFOLDER) && cd PGOHelper/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wl,-z,defs -o pgohelper ../PGOHelper.cpp ../../bin/pgohelperlib.so -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB)
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/%, ../%, $<)
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
mkdir -p Core/$(OBJFOLDER) && cd Core/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Core/%, ../%, $<)
Linux/$(OBJFOLDER)/%.o: Linux/%.cpp
mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Linux/%, ../%, $<) $(SDL2INC) $(LIBEVDEVINC)
Linux/$(OBJFOLDER)/%.o: Linux/libevdev/%.c
mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst Linux/%, ../%, $<)
InteropDLL/$(OBJFOLDER)/$(SHAREDLIB): $(SEVENZIPOBJ) $(LUAOBJ) $(UTILOBJ) $(COREOBJ) $(LIBEVDEVOBJ) $(LINUXOBJ) InteropDLL/ConsoleWrapper.cpp InteropDLL/DebugWrapper.cpp
mkdir -p bin
mkdir -p InteropDLL/$(OBJFOLDER)
$(CPPC) $(GCCOPTIONS) $(LINKOPTIONS) -Wl,-z,defs -shared -o $(SHAREDLIB) InteropDLL/*.cpp $(SEVENZIPOBJ) $(LUAOBJ) $(LINUXOBJ) $(LIBEVDEVOBJ) $(UTILOBJ) $(COREOBJ) $(SDL2INC) -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB)
cp $(SHAREDLIB) bin/pgohelperlib.so
mv $(SHAREDLIB) InteropDLL/$(OBJFOLDER)
Libretro/$(OBJFOLDER)/$(LIBRETROLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) $(LUAOBJ) Libretro/libretro.cpp
mkdir -p bin
mkdir -p Libretro/$(OBJFOLDER)
$(CPPC) $(GCCOPTIONS) $(LINKOPTIONS) -Wl,-z,defs -shared -o $(LIBRETROLIB) Libretro/*.cpp $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) $(LUAOBJ) -pthread $(FSLIB)
cp $(LIBRETROLIB) bin/pgohelperlib.so
mv $(LIBRETROLIB) Libretro/$(OBJFOLDER)
pgo:
./buildPGO.sh
official:
./build.sh
debug:
MONO_LOG_LEVEL=debug mono $(RELEASEFOLDER)/Mesen.exe
run:
mono $(RELEASEFOLDER)/Mesen.exe
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 PGOHelper/$(OBJFOLDER)
rm -rf $(RELEASEFOLDER)