scummvm/Makefile.common

254 lines
7.8 KiB
Makefile
Raw Normal View History

# This file is used by Makefile and declares common build rules,
# a list of common object files etc.
#
######################################################################
2012-01-06 10:37:57 +00:00
# The default build target: just build the residualvm executable
######################################################################
2009-05-25 20:49:53 +00:00
all: $(EXECUTABLE) plugins
######################################################################
# Module settings
######################################################################
2012-03-25 09:41:48 +00:00
#ResidualVM: added 'math':
2009-05-25 20:49:53 +00:00
PLUGINS :=
2012-02-10 06:51:41 +00:00
MODULES := test devtools base $(MODULES)
2009-05-25 20:49:53 +00:00
-include $(srcdir)/engines/engines.mk
# After the game specific modules follow the shared modules
MODULES += \
2009-10-04 12:19:24 +00:00
gui \
2009-05-04 18:41:11 +00:00
backends \
2011-04-10 19:59:04 +00:00
engines \
2011-05-01 15:49:40 +00:00
video \
2011-04-10 19:59:04 +00:00
graphics \
2011-04-14 10:41:26 +00:00
audio \
math \
common \
2011-04-11 00:28:51 +00:00
po
2010-01-21 19:25:03 +00:00
ifdef USE_MT32EMU
2011-04-14 10:41:26 +00:00
MODULES += audio/softsynth/mt32
2010-01-21 19:25:03 +00:00
endif
######################################################################
# The build rules follow - normally you should have no need to
# touch whatever comes after here.
######################################################################
# Concat DEFINES and INCLUDES to form the CPPFLAGS
CPPFLAGS := $(DEFINES) $(INCLUDES)
# Include the build instructions for all modules
-include $(addprefix $(srcdir)/, $(addsuffix /module.mk,$(MODULES)))
# Depdir information
DEPDIRS = $(addsuffix $(DEPDIR),$(MODULE_DIRS))
DEPFILES =
2009-05-25 20:49:53 +00:00
# Make base/version.o depend on all other object files. This way if anything is
# changed, it causes version.cpp to be recompiled. This in turn ensures that
2009-05-25 20:49:53 +00:00
# the build date in gScummVMBuildDate is correct.
base/version.o: $(filter-out base/libbase.a,$(OBJS))
2011-04-14 10:41:26 +00:00
ifdef USE_ELF_LOADER
backends/plugins/elf/version.o: $(filter-out base/libbase.a,$(filter-out backends/libbackends.a,$(OBJS)))
endif
# Replace regular output with quiet messages
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifneq ($(VERBOSE_BUILD),1)
ifneq ($(VERBOSE_BUILD),yes)
2011-05-08 13:38:26 +00:00
QUIET_CXX = @echo ' ' C++ ' ' $@;
QUIET_AS = @echo ' ' AS ' ' $@;
QUIET_NASM = @echo ' ' NASM ' ' $@;
QUIET_AR = @echo ' ' AR ' ' $@;
QUIET_RANLIB = @echo ' ' RANLIB ' ' $@;
QUIET_PLUGIN = @echo ' ' PLUGIN ' ' $@;
QUIET_LINK = @echo ' ' LINK ' ' $@;
QUIET_WINDRES = @echo ' ' WINDRES '' $@;
QUIET = @
endif
endif
endif
2012-01-06 10:37:57 +00:00
# The build rule for the ResidualVM executable
$(EXECUTABLE): $(OBJS)
2010-01-21 19:25:03 +00:00
$(QUIET_LINK)$(LD) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@
2013-07-07 13:29:33 +00:00
distclean: clean clean-devtools
$(RM) config.h config.mk config.log
clean:
$(RM_REC) $(DEPDIRS)
$(RM) $(OBJS) $(EXECUTABLE)
2009-10-05 08:33:46 +00:00
#
# The build rules for object files.
#
ifdef CXX_UPDATE_DEP_FLAG
# Build rule for C++ files. Makes use of CXX_UPDATE_DEP_FLAG for advanced
# dependency tracking.
%.o: %.cpp
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
2009-10-05 08:33:46 +00:00
$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
2010-01-21 19:25:03 +00:00
# Build rules for Objective-C and Objective-C++ files. Strictly speaking, this is for OS X only.
%.o: %.mm
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
%.o: %.m
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
2012-02-24 11:15:44 +00:00
$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CPPFLAGS) $(OBJCFLAGS) -c $(<) -o $*.o
2009-10-05 08:33:46 +00:00
2011-04-10 19:59:04 +00:00
# Build rule for assembler files with preprocessing
%.o: %.S
$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
$(QUIET_AS)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(ASFLAGS) -c $(<) -o $*.o
2009-10-05 08:33:46 +00:00
else
# Dumb compile rule, for C++ compilers that don't allow dependency tracking or
# where it is broken (such as GCC 2.95).
.cpp.o:
2011-04-10 19:59:04 +00:00
$(QUIET)$(MKDIR) $(*D)
2009-10-05 08:33:46 +00:00
$(QUIET_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
2011-04-10 19:59:04 +00:00
# Build rule for assembler files with preprocessing
%.o: %.S
$(QUIET)$(MKDIR) $(*D)
$(QUIET_AS)$(CXX) $(ASFLAGS) -c $(<) -o $*.o
2009-10-05 08:33:46 +00:00
endif
2010-01-21 19:25:03 +00:00
# Build rule for assembler files
2009-10-05 08:33:46 +00:00
%.o: %.s
2010-01-21 19:25:03 +00:00
$(QUIET)$(MKDIR) $(*D)
2009-10-05 08:33:46 +00:00
$(QUIET_AS)$(AS) $(ASFLAGS) $(<) -o $*.o
2011-04-10 19:59:04 +00:00
ifdef USE_NASM
2010-01-21 19:25:03 +00:00
# Build rule for NASM assembler files
2009-10-05 08:33:46 +00:00
%.o: %.asm
2010-01-21 19:25:03 +00:00
$(QUIET)$(MKDIR) $(*D)
2011-04-10 19:59:04 +00:00
$(QUIET_NASM)$(NASM) $(NASMFLAGS) -o $*.o $(<)
endif
# Include the dependency tracking files.
-include $(wildcard $(addsuffix /*.d,$(DEPDIRS)))
2010-01-21 19:25:03 +00:00
# Mark *.d files and most *.mk files as PHONY. This stops make from trying to
# recreate them (which it can't), and in particular from looking for potential
# source files. This can save quite a bit of disk access time.
.PHONY: $(wildcard $(addsuffix /*.d,$(DEPDIRS))) $(addprefix $(srcdir)/, $(addsuffix /module.mk,$(MODULES))) \
$(srcdir)/$(port_mk) $(srcdir)/rules.mk $(srcdir)/engines/engines.mk
######################################################################
2009-04-04 14:43:23 +00:00
# Get the current version information
######################################################################
2012-03-25 09:41:48 +00:00
# AmigaOS4's grep has a problem with "./" in pathnames, so use cat piped into grep.
VERSION = $(shell cat "${srcdir}/base/internal_version.h" | grep SCUMMVM_VERSION | cut -d\" -f2)
VER_MAJOR = $(shell echo $(VERSION) | cut -d. -f 1)
VER_MINOR = $(shell echo $(VERSION) | cut -d. -f 2)
VER_PATCH = $(shell echo $(VERSION) | cut -d. -f 3 | cut -c1)
VER_EXTRA = $(shell echo $(VERSION) | cut -d. -f 3 | cut -c2-)
2009-05-25 20:49:53 +00:00
2009-04-04 14:43:23 +00:00
######################################################################
2011-04-14 10:41:26 +00:00
# Get git's working copy information
2009-04-04 14:43:23 +00:00
######################################################################
2011-04-14 10:41:26 +00:00
ifneq ($(shell cd $(srcdir); git rev-parse --verify HEAD 1>/dev/null 2>&1 || echo "error"),error)
GITROOT := $(srcdir)
ifeq ($(origin VER_REV), undefined)
# Are there uncommitted changes? (describe --dirty is only available since 1.6.6)
VER_DIRTY := $(shell cd $(srcdir); git update-index --refresh --unmerged 1>/dev/null 2>&1; git diff-index --quiet HEAD || echo "-dirty")
2009-04-04 14:43:23 +00:00
# Get the working copy base revision
2012-01-06 21:56:21 +00:00
#ResidualVM: --always
2013-07-07 13:29:33 +00:00
VER_REV := $(shell cd $(srcdir); git describe --always --long --match desc/\* | cut -d '-' -f 2-)$(VER_DIRTY)
2009-04-04 14:43:23 +00:00
endif
else
2012-01-06 12:32:30 +00:00
GITROOT := git://github.com/residualvm/residualvm.git
2009-04-04 14:43:23 +00:00
endif
# Define the Subversion revision if available, either autodetected or
2011-04-11 13:40:01 +00:00
# specified by the user, but only for base/version.cpp.
2011-04-14 10:41:26 +00:00
ifneq ($(origin VER_REV), undefined)
2012-02-24 11:15:44 +00:00
base/version.o: CXXFLAGS:=$(CXXFLAGS) -DSCUMMVM_REVISION=\"$(VER_REV)\"
2009-04-04 14:43:23 +00:00
endif
######################################################################
# Distribution settings
######################################################################
2011-04-14 10:41:26 +00:00
ifeq ($(VER_EXTRA),git)
ifeq ($(origin VER_REV), undefined)
DISTVERSION = $(shell date '+%Y-%m-%d')
else
2011-04-14 10:41:26 +00:00
DISTVERSION = git$(VER_REV)
2009-04-04 14:43:23 +00:00
endif
else
DISTVERSION = $(VERSION)
endif
2012-01-06 10:37:57 +00:00
DISTNAME := residualvm-$(DISTVERSION)
DISTDIR := dist
2009-05-25 20:49:53 +00:00
VERFILE := $(DISTDIR)/$(DISTNAME)/base/internal_version.h
2011-04-14 10:41:26 +00:00
# TODO git via $(GITROOT)
2009-05-25 20:49:53 +00:00
$(VERFILE): $(srcdir)/base/internal_version.h
@$(RM_REC) $(DISTDIR)
@$(MKDIR) $(DISTDIR)
svn export $(SVNROOT) $(DISTDIR)/$(DISTNAME)
2011-04-14 10:41:26 +00:00
ifneq ($(origin VER_REV), undefined)
2009-04-04 14:43:23 +00:00
@# Use the current SVN revision as a default for the snapshot sources
2009-05-25 20:49:53 +00:00
@svn cat $(SVNROOT)/base/internal_version.h | sed -e \
2012-02-24 11:15:44 +00:00
"s/^#define SCUMMVM_REVISION$$/#define SCUMMVM_REVISION \"$(VER_REV)\"/g" \
2009-04-04 14:43:23 +00:00
> $(VERFILE)
endif
2009-04-04 14:43:23 +00:00
$(DISTDIR)/$(DISTNAME).tar.gz: $(VERFILE)
cd $(DISTDIR); tar zcf $(DISTNAME).tar.gz $(DISTNAME)
2009-04-04 14:43:23 +00:00
$(DISTDIR)/$(DISTNAME).tar.bz2: $(VERFILE)
cd $(DISTDIR); tar jcf $(DISTNAME).tar.bz2 $(DISTNAME)
2009-04-04 14:43:23 +00:00
$(DISTDIR)/$(DISTNAME).zip: $(VERFILE)
cd $(DISTDIR); zip -qr9 $(DISTNAME).zip $(DISTNAME)
dist-src: \
$(DISTDIR)/$(DISTNAME).tar.gz \
$(DISTDIR)/$(DISTNAME).tar.bz2 \
$(DISTDIR)/$(DISTNAME).zip
@#RPM-src?
@#DEB-src?
2009-10-05 08:33:46 +00:00
# Common files
2012-12-19 23:29:39 +00:00
DIST_FILES_DOCS:=$(addprefix $(srcdir)/,AUTHORS COPYING COPYING.BSD COPYING.LGPL COPYING.FREEFONT COPYRIGHT KNOWN_BUGS NEWS README)
# Themes files
2011-04-11 13:40:01 +00:00
DIST_FILES_THEMES=modern.zip
ifdef USE_TRANSLATION
DIST_FILES_THEMES+=translations.dat
endif
DIST_FILES_THEMES:=$(addprefix $(srcdir)/gui/themes/,$(DIST_FILES_THEMES))
2009-10-05 08:33:46 +00:00
# Engine data files
2012-01-28 09:44:25 +00:00
DIST_FILES_ENGINEDATA=
ifdef ENABLE_GRIM
DIST_FILES_ENGINEDATA+=residualvm-grim-patch.lab
endif
2009-10-05 08:33:46 +00:00
DIST_FILES_ENGINEDATA:=$(addprefix $(srcdir)/dists/engine-data/,$(DIST_FILES_ENGINEDATA))
2009-05-25 20:49:53 +00:00
.PHONY: all clean distclean plugins dist-src