forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
295 lines (244 loc) · 8.05 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
HAVE_FILE_LOGGER=1
NEED_CXX_LINKER?=0
NEED_GOLD_LINKER?=0
MISSING_DECLS =0
ifneq ($(C90_BUILD),)
C89_BUILD=1
endif
include config.mk
# Put your favorite compile flags in this file, if you want different defaults than upstream.
# Do not attempt to create that file upstream.
# (It'd be better to put this comment in that file, but .gitignore doesn't work on files that exist in the repo.)
-include Makefile.local
ifeq ($(HAVE_ANGLE), 1)
TARGET = retroarch_angle
else
TARGET = retroarch
endif
OBJ :=
LIBS :=
DEF_FLAGS := -I.
ASFLAGS :=
DEFINES := -DHAVE_CONFIG_H -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64
DEFINES += -DGLOBAL_CONFIG_DIR='"$(GLOBAL_CONFIG_DIR)"'
DEFINES += -DASSETS_DIR='"$(DESTDIR)$(ASSETS_DIR)"'
DEFINES += -DFILTERS_DIR='"$(DESTDIR)$(FILTERS_DIR)"'
DEFINES += -DCORE_INFO_DIR='"$(DESTDIR)$(CORE_INFO_DIR)"'
OBJDIR_BASE := obj-unix
ifeq ($(NEED_GOLD_LINKER), 1)
LDFLAGS += -fuse-ld=gold
endif
ifeq ($(DEBUG), 1)
OBJDIR := $(OBJDIR_BASE)/debug
CFLAGS ?= -O0 -g
CXXFLAGS ?= -O0 -g
DEFINES += -DDEBUG -D_DEBUG
else
OBJDIR := $(OBJDIR_BASE)/release
CFLAGS ?= -O3
CXXFLAGS ?= -O3
DEF_FLAGS += -ffast-math
endif
DEF_FLAGS += -Wall -Wsign-compare
ifneq ($(findstring BSD,$(OS)),)
DEF_FLAGS += -DBSD
LDFLAGS += -L/usr/local/lib
UDEV_CFLAGS += -I/usr/local/include/libepoll-shim
UDEV_LIBS += -lepoll-shim
endif
ifneq ($(findstring DOS,$(OS)),)
DEF_FLAGS += -march=i386
LDFLAGS += -lemu
endif
ifneq ($(findstring FPGA,$(OS)),)
DEFINES += -DHAVE_FPGA
endif
ifneq ($(findstring Win32,$(OS)),)
LDFLAGS += -static-libgcc -lwinmm -limm32
endif
include Makefile.common
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang"),1)
DEF_FLAGS += -Wno-invalid-source-encoding -Wno-incompatible-ms-struct
endif
ifeq ($(shell $(CC) -v 2>&1 | grep -c "tcc"),1)
MD = -MD
else
MD = -MMD
endif
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
ifeq ($(MISSING_DECLS), 1)
DEF_FLAGS += -Werror=missing-declarations
endif
ifeq ($(HAVE_DYLIB), 1)
LIBS += $(DYLIB_LIB)
endif
ifeq ($(HAVE_DYNAMIC), 1)
LIBS += $(DYLIB_LIB)
else
LIBS += $(libretro)
endif
ifneq ($(V),1)
Q := @
endif
ifeq ($(HAVE_DRMINGW), 1)
DEF_FLAGS += -DHAVE_DRMINGW
LDFLAGS += $(DRMINGW_LIBS)
endif
ifneq ($(findstring Win32,$(OS)),)
LDFLAGS += -mwindows
endif
ifneq ($(CXX_BUILD), 1)
ifneq ($(C89_BUILD),)
CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long -Werror=declaration-after-statement
else ifeq ($(HAVE_C99), 1)
CFLAGS += $(C99_CFLAGS)
endif
CFLAGS += -D_GNU_SOURCE
endif
DEF_FLAGS += $(INCLUDE_DIRS) -Ideps -Ideps/stb
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS) -D__STDC_CONSTANT_MACROS
OBJCFLAGS := $(CFLAGS) -D__STDC_CONSTANT_MACROS
ifeq ($(HAVE_CXX), 1)
ifeq ($(CXX_BUILD), 1)
LINK = $(CXX)
CFLAGS := $(CXXFLAGS) -xc++
CFLAGS += -DCXX_BUILD
CXXFLAGS += -DCXX_BUILD
else ifeq ($(NEED_CXX_LINKER),1)
LINK = $(CXX)
else
LINK = $(CC)
endif
else
LINK = $(CC)
endif
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
ifneq ($(X86),)
CFLAGS += -m32
CXXFLAGS += -m32
LDFLAGS += -m32
endif
ifneq ($(SANITIZER),)
CFLAGS := -fsanitize=$(SANITIZER) $(CFLAGS)
CXXFLAGS := -fsanitize=$(SANITIZER) $(CXXFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
endif
ifneq ($(findstring $(GPERFTOOLS),profiler),)
LIBS += -lprofiler
endif
ifneq ($(findstring $(GPERFTOOLS),tcmalloc),)
LIBS += -ltcmalloc
endif
# Qt MOC generation, required for QObject-derived classes
ifneq ($(MOC_HEADERS),)
# prefix moc_ to base filename of paths and change extension from h to cpp, so a/b/foo.h becomes a/b/moc_foo.cpp
MOC_SRC := $(join $(addsuffix moc_,$(addprefix $(OBJDIR)/,$(dir $(MOC_HEADERS)))), $(notdir $(MOC_HEADERS:.h=.cpp)))
MOC_OBJ := $(patsubst %.cpp,%.o,$(MOC_SRC))
RARCH_OBJ += $(MOC_OBJ)
endif
all: $(TARGET) config.mk
$(MOC_SRC):
@$(if $(Q), $(shell echo echo MOC $<),)
$(eval MOC_TMP := $(patsubst %.h,%_moc.cpp,$@))
$(Q)QT_SELECT=$(QT_VERSION) $(MOC) -o $(MOC_TMP) $<
$(foreach x,$(join $(addsuffix :,$(MOC_SRC)),$(MOC_HEADERS)),$(eval $x))
$(MOC_OBJ):
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(foreach x,$(join $(addsuffix :,$(MOC_OBJ)),$(MOC_SRC)),$(eval $x))
ifeq ($(MAKECMDGOALS),clean)
config.mk:
else
-include $(RARCH_OBJ:.o=.d)
ifeq ($(HAVE_CONFIG_MK),)
config.mk: configure qb/*
@echo "config.mk is outdated or non-existing. Run ./configure again."
@exit 1
endif
endif
SYMBOL_MAP := -Wl,-Map=output.map
$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
$(OBJDIR)/%.o: %.c config.h config.mk
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) $(MD) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp config.h config.mk
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.m
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo OBJC $<),)
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo AS $<),)
$(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
$(OBJDIR)/%.o: %.rc $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo WINDRES $<),)
$(Q)$(WINDRES) $(DEFINES) -o $@ $<
install: $(TARGET)
mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(GLOBAL_CONFIG_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DATA_DIR)/applications 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DATA_DIR)/metainfo 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DOC_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(MAN_DIR)/man6 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DATA_DIR)/pixmaps 2>/dev/null || /bin/true
cp $(TARGET) $(DESTDIR)$(BIN_DIR)
cp tools/cg2glsl.py $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
cp retroarch.cfg $(DESTDIR)$(GLOBAL_CONFIG_DIR)
cp com.libretro.RetroArch.metainfo.xml $(DESTDIR)$(DATA_DIR)/metainfo
cp com.libretro.RetroArch.desktop $(DESTDIR)$(DATA_DIR)/applications
cp docs/retroarch.6 $(DESTDIR)$(MAN_DIR)/man6
cp docs/retroarch-cg2glsl.6 $(DESTDIR)$(MAN_DIR)/man6
cp media/com.libretro.RetroArch.svg $(DESTDIR)$(DATA_DIR)/pixmaps
cp COPYING $(DESTDIR)$(DOC_DIR)
cp README.md $(DESTDIR)$(DOC_DIR)
chmod 755 $(DESTDIR)$(BIN_DIR)/$(TARGET)
chmod 755 $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
chmod 644 $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
chmod 644 $(DESTDIR)$(DATA_DIR)/applications/com.libretro.RetroArch.desktop
chmod 644 $(DESTDIR)$(DATA_DIR)/metainfo/com.libretro.RetroArch.metainfo.xml
chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
chmod 644 $(DESTDIR)$(DATA_DIR)/pixmaps/com.libretro.RetroArch.svg
@if test -d media/assets && test $(HAVE_ASSETS); then \
echo "Installing media assets..."; \
mkdir -p $(DESTDIR)$(ASSETS_DIR)/assets; \
if test $(HAVE_MATERIALUI) = 1; then \
cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/assets; \
fi; \
if test $(HAVE_XMB) = 1; then \
cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/assets; \
fi; \
if test $(HAVE_OZONE) = 1; then \
cp -r media/assets/ozone/ $(DESTDIR)$(ASSETS_DIR)/assets; \
fi; \
cp media/assets/COPYING $(DESTDIR)$(DOC_DIR)/COPYING.assets; \
echo "Asset copying done."; \
fi
uninstall:
rm -f $(DESTDIR)$(BIN_DIR)/$(TARGET)
rm -f $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
rm -f $(DESTDIR)$(DATA_DIR)/applications/com.libretro.RetroArch.desktop
rm -f $(DESTDIR)$(DATA_DIR)/metainfo/com.libretro.RetroArch.metainfo.xml
rm -f $(DESTDIR)$(DATA_DIR)/pixmaps/com.libretro.RetroArch.svg
rm -f $(DESTDIR)$(DOC_DIR)/COPYING
rm -f $(DESTDIR)$(DOC_DIR)/COPYING.assets
rm -f $(DESTDIR)$(DOC_DIR)/README.md
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
rm -rf $(DESTDIR)$(ASSETS_DIR)
clean:
rm -rf $(OBJDIR_BASE)
rm -f $(TARGET)
rm -f *.d
.PHONY: all install uninstall clean
print-%:
@echo '$*=$($*)'