RetroArch/Makefile

296 lines
8 KiB
Makefile
Raw Permalink Normal View History

HAVE_FILE_LOGGER=1
NEED_CXX_LINKER?=0
NEED_GOLD_LINKER?=0
MISSING_DECLS =0
ifneq ($(C90_BUILD),)
C89_BUILD=1
endif
2010-05-29 11:01:11 -04:00
include config.mk
2010-05-28 08:04:50 -04:00
2017-12-29 15:07:30 -05:00
# 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.)
2017-12-29 15:16:28 -05:00
-include Makefile.local
2017-12-29 15:07:30 -05:00
2020-01-04 13:05:05 -05:00
ifeq ($(HAVE_ANGLE), 1)
TARGET = retroarch_angle
else
TARGET = retroarch
2020-01-04 13:05:05 -05:00
endif
2010-05-26 15:27:37 -04:00
OBJ :=
LIBS :=
DEF_FLAGS := -I.
2019-01-31 15:55:07 -05:00
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
2020-01-15 13:20:10 -05:00
2017-03-29 12:47:58 -04:00
ifneq ($(findstring BSD,$(OS)),)
DEF_FLAGS += -DBSD
2017-03-29 12:47:58 -04:00
LDFLAGS += -L/usr/local/lib
UDEV_CFLAGS += -I/usr/local/include/libepoll-shim
UDEV_LIBS += -lepoll-shim
2017-03-29 12:47:58 -04:00
endif
ifneq ($(findstring DOS,$(OS)),)
DEF_FLAGS += -march=i386
LDFLAGS += -lemu
endif
ifneq ($(findstring FPGA,$(OS)),)
DEFINES += -DHAVE_FPGA
endif
ifneq ($(findstring Win32,$(OS)),)
2022-11-28 22:45:55 -05:00
LDFLAGS += -static-libgcc -lwinmm -limm32
endif
include Makefile.common
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang"),1)
2020-01-15 13:20:10 -05:00
DEF_FLAGS += -Wno-invalid-source-encoding -Wno-incompatible-ms-struct
endif
2016-10-02 11:31:19 -04:00
ifeq ($(shell $(CC) -v 2>&1 | grep -c "tcc"),1)
MD = -MD
else
MD = -MMD
endif
2014-01-11 13:08:24 -05:00
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
2010-11-19 15:26:31 -05:00
2015-09-06 08:45:24 -04:00
ifeq ($(MISSING_DECLS), 1)
2020-01-15 13:20:10 -05:00
DEF_FLAGS += -Werror=missing-declarations
2015-09-06 08:45:24 -04:00
endif
2011-05-11 11:52:16 -04:00
ifeq ($(HAVE_DYLIB), 1)
LIBS += $(DYLIB_LIB)
2010-05-29 10:59:57 -04:00
endif
2010-05-28 08:04:50 -04:00
ifeq ($(HAVE_DYNAMIC), 1)
LIBS += $(DYLIB_LIB)
else
2012-04-22 04:46:06 -04:00
LIBS += $(libretro)
2010-12-30 07:54:49 -05:00
endif
2011-01-10 11:15:27 -05:00
ifneq ($(V),1)
Q := @
endif
2018-12-10 20:03:03 -05:00
ifeq ($(HAVE_DRMINGW), 1)
DEF_FLAGS += -DHAVE_DRMINGW
2018-12-10 20:03:03 -05:00
LDFLAGS += $(DRMINGW_LIBS)
endif
ifneq ($(findstring Win32,$(OS)),)
LDFLAGS += -mwindows
endif
2020-01-15 00:35:49 -05:00
ifneq ($(CXX_BUILD), 1)
ifneq ($(C89_BUILD),)
CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long -Werror=declaration-after-statement
2020-01-15 00:35:49 -05:00
else ifeq ($(HAVE_C99), 1)
CFLAGS += $(C99_CFLAGS)
endif
CFLAGS += -D_GNU_SOURCE
endif
DEF_FLAGS += $(INCLUDE_DIRS) -Ideps -Ideps/stb
2016-02-16 14:24:00 -05:00
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS) -D__STDC_CONSTANT_MACROS
2015-04-19 18:38:55 -04:00
OBJCFLAGS := $(CFLAGS) -D__STDC_CONSTANT_MACROS
2014-08-29 15:35:56 -04:00
ifeq ($(HAVE_CXX), 1)
ifeq ($(CXX_BUILD), 1)
2016-07-15 09:40:06 -04:00
LINK = $(CXX)
CFLAGS := $(CXXFLAGS) -xc++
CFLAGS += -DCXX_BUILD
CXXFLAGS += -DCXX_BUILD
else ifeq ($(NEED_CXX_LINKER),1)
2014-08-29 15:35:56 -04:00
LINK = $(CXX)
else
LINK = $(CC)
2014-08-29 15:35:56 -04:00
endif
else
LINK = $(CC)
2018-05-03 18:43:37 -04:00
endif
2014-08-29 15:35:56 -04:00
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
ifneq ($(X86),)
CFLAGS += -m32
CXXFLAGS += -m32
LDFLAGS += -m32
endif
2015-05-19 14:11:34 -04:00
ifneq ($(SANITIZER),)
CFLAGS := -fsanitize=$(SANITIZER) $(CFLAGS)
CXXFLAGS := -fsanitize=$(SANITIZER) $(CXXFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
2015-05-19 14:11:34 -04:00
endif
2015-11-24 11:49:36 -05:00
ifneq ($(findstring $(GPERFTOOLS),profiler),)
LIBS += -lprofiler
endif
ifneq ($(findstring $(GPERFTOOLS),tcmalloc),)
LIBS += -ltcmalloc
endif
2018-04-30 14:33:05 -04:00
# 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
2015-11-11 14:18:45 -05:00
all: $(TARGET) config.mk
2010-12-29 20:56:56 -05:00
2018-04-30 14:33:05 -04:00
$(MOC_SRC):
@$(if $(Q), $(shell echo echo MOC $<),)
$(eval MOC_TMP := $(patsubst %.h,%_moc.cpp,$@))
$(Q)QT_SELECT=$(QT_VERSION) $(MOC) -o $(MOC_TMP) $<
2018-04-30 14:33:05 -04:00
$(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
2015-11-11 14:15:27 -05:00
-include $(RARCH_OBJ:.o=.d)
ifeq ($(HAVE_CONFIG_MK),)
2010-12-29 20:56:56 -05:00
config.mk: configure qb/*
@echo "config.mk is outdated or non-existing. Run ./configure again."
2010-12-29 21:23:12 -05:00
@exit 1
endif
endif
2010-05-28 08:04:50 -04:00
2019-07-11 19:15:02 -04:00
SYMBOL_MAP := -Wl,-Map=output.map
$(TARGET): $(RARCH_OBJ)
2011-01-10 11:15:27 -05:00
@$(if $(Q), $(shell echo echo LD $@),)
2019-07-11 19:15:02 -04:00
$(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
2010-06-27 09:46:23 -04:00
$(OBJDIR)/%.o: %.c config.h config.mk
@mkdir -p $(dir $@)
2011-01-10 11:15:27 -05:00
@$(if $(Q), $(shell echo echo CC $<),)
2016-10-02 11:31:19 -04:00
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) $(MD) -c -o $@ $<
2010-05-28 08:04:50 -04:00
2016-02-16 14:24:00 -05:00
$(OBJDIR)/%.o: %.cpp config.h config.mk
2014-08-29 15:35:56 -04:00
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
2014-08-29 15:35:56 -04:00
2015-04-19 18:38:55 -04:00
$(OBJDIR)/%.o: %.m
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo OBJC $<),)
2015-04-19 18:38:55 -04:00
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS)
@mkdir -p $(dir $@)
2012-12-09 12:37:09 -05:00
@$(if $(Q), $(shell echo echo AS $<),)
2013-01-04 15:56:15 -05:00
$(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
2012-12-09 10:28:49 -05:00
2014-09-14 16:50:29 -04:00
$(OBJDIR)/%.o: %.rc $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo WINDRES $<),)
$(Q)$(WINDRES) $(DEFINES) -o $@ $<
2014-09-14 16:50:29 -04:00
2010-05-28 08:04:50 -04:00
install: $(TARGET)
2016-08-28 00:44:53 -04:00
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.appdata.xml $(DESTDIR)$(DATA_DIR)/metainfo
2024-05-30 18:16:48 -04:00
cp org.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/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
2024-05-30 18:16:48 -04:00
chmod 644 $(DESTDIR)$(DATA_DIR)/applications/org.libretro.RetroArch.desktop
chmod 644 $(DESTDIR)$(DATA_DIR)/metainfo/com.libretro.RetroArch.appdata.xml
chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
chmod 644 $(DESTDIR)$(DATA_DIR)/pixmaps/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
2010-05-28 08:04:50 -04:00
uninstall:
rm -f $(DESTDIR)$(BIN_DIR)/$(TARGET)
2016-08-26 20:29:50 -04:00
rm -f $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
2024-05-30 18:16:48 -04:00
rm -f $(DESTDIR)$(DATA_DIR)/applications/org.libretro.RetroArch.desktop
rm -f $(DESTDIR)$(DATA_DIR)/metainfo/com.libretro.RetroArch.appdata.xml
rm -f $(DESTDIR)$(DATA_DIR)/pixmaps/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)
2010-05-26 15:27:37 -04:00
clean:
rm -rf $(OBJDIR_BASE)
2010-08-19 14:29:32 -04:00
rm -f $(TARGET)
rm -f *.d
2010-06-27 09:46:23 -04:00
.PHONY: all install uninstall clean
2018-04-30 14:33:05 -04:00
print-%:
@echo '$*=$($*)'