Skip to content
Newer
Older
100644 272 lines (219 sloc) 7.99 KB
0a3364d @lousyphreak svn import #53614
authored
1 # This file is used by Makefile and declares common build rules,
2 # a list of common object files etc.
3 #
4 # $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/Makefile.common $
5 # $Id: Makefile.common 53115 2010-10-10 11:40:16Z Kirben $
6
7 ######################################################################
8 # The default build target: just build the scummvm executable
9 ######################################################################
10
11 all: $(EXECUTABLE) plugins
12
13
14 ######################################################################
15 # Module settings
16 ######################################################################
17
18 PLUGINS :=
19 MODULES := test tools base $(MODULES)
20
21 -include $(srcdir)/engines/engines.mk
22
23 # After the game specific modules follow the shared modules
24 MODULES += \
25 gui \
26 sound \
27 backends \
28 engines \
29 graphics \
30 common \
31 po
32
33 ifdef USE_MT32EMU
34 MODULES += sound/softsynth/mt32
35 endif
36
37 ######################################################################
38 # The build rules follow - normally you should have no need to
39 # touch whatever comes after here.
40 ######################################################################
41
42 # Concat DEFINES and INCLUDES to form the CPPFLAGS
43 CPPFLAGS := $(DEFINES) $(INCLUDES)
44
45 # Include the build instructions for all modules
46 -include $(addprefix $(srcdir)/, $(addsuffix /module.mk,$(MODULES)))
47
48 # Depdir information
49 DEPDIRS = $(addsuffix $(DEPDIR),$(MODULE_DIRS))
50 DEPFILES =
51
52 # Make base/version.o depend on all other object files. This way if anything is
53 # changed, it causes version.cpp to be recompiled. This in turn ensures that
54 # the build date in gScummVMBuildDate is correct.
55 base/version.o: $(filter-out base/libbase.a,$(OBJS))
56
57 # Replace regular output with quiet messages
58 ifneq ($(findstring $(MAKEFLAGS),s),s)
59 ifneq ($(VERBOSE_BUILD),1)
60 ifneq ($(VERBOSE_BUILD),yes)
61 QUIET_CXX = @echo ' ' C++ ' ' $@;
62 QUIET_AS = @echo ' ' AS ' ' $@;
63 QUIET_NASM = @echo ' ' NASM ' ' $@;
64 QUIET_AR = @echo ' ' AR ' ' $@;
65 QUIET_RANLIB = @echo ' ' RANLIB ' ' $@;
66 QUIET_PLUGIN = @echo ' ' PLUGIN ' ' $@;
67 QUIET_LINK = @echo ' ' LINK ' ' $@;
68 QUIET = @
69 endif
70 endif
71 endif
72
73 # The build rule for the ScummVM executable
74 $(EXECUTABLE): $(OBJS)
75 $(QUIET_LINK)$(LD) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@
76
77 distclean: clean
78 $(RM) config.h config.mk config.log
79
80 clean:
81 $(RM_REC) $(DEPDIRS)
82 $(RM) $(OBJS) $(EXECUTABLE)
83
84
85 #
86 # The build rules for object files.
87 #
88
89 ifdef CXX_UPDATE_DEP_FLAG
90
91 # Build rule for C++ files. Makes use of CXX_UPDATE_DEP_FLAG for advanced
92 # dependency tracking.
93 %.o: %.cpp
94 $(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
95 $(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
96
97
98 # Build rules for Objective-C and Objective-C++ files. Strictly speaking, this is for OS X only.
99 %.o: %.mm
100 $(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
101 $(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
102
103 %.o: %.m
104 $(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
105 $(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(OBJCFLAGS) -c $(<) -o $*.o
106
107 # Build rule for assembler files with preprocessing
108 %.o: %.S
109 $(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
110 $(QUIET_AS)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(ASFLAGS) -c $(<) -o $*.o
111
112 else
113
114 # Dumb compile rule, for C++ compilers that don't allow dependency tracking or
115 # where it is broken (such as GCC 2.95).
116 .cpp.o:
117 $(QUIET)$(MKDIR) $(*D)
118 $(QUIET_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
119
120 # Build rule for assembler files with preprocessing
121 %.o: %.S
122 $(QUIET)$(MKDIR) $(*D)
123 $(QUIET_AS)$(CXX) $(ASFLAGS) -c $(<) -o $*.o
124
125 endif
126
127 # Build rule for assembler files
128 %.o: %.s
129 $(QUIET)$(MKDIR) $(*D)
130 $(QUIET_AS)$(AS) $(ASFLAGS) $(<) -o $*.o
131
132 ifdef USE_NASM
133 # Build rule for NASM assembler files
134 %.o: %.asm
135 $(QUIET)$(MKDIR) $(*D)
136 $(QUIET_NASM)$(NASM) $(NASMFLAGS) -o $*.o $(<)
137 endif
138
139 # Include the dependency tracking files.
140 -include $(wildcard $(addsuffix /*.d,$(DEPDIRS)))
141
142 # Mark *.d files and most *.mk files as PHONY. This stops make from trying to
143 # recreate them (which it can't), and in particular from looking for potential
144 # source files. This can save quite a bit of disk access time.
145 .PHONY: $(wildcard $(addsuffix /*.d,$(DEPDIRS))) $(addprefix $(srcdir)/, $(addsuffix /module.mk,$(MODULES))) \
146 $(srcdir)/$(port_mk) $(srcdir)/rules.mk $(srcdir)/engines/engines.mk
147
148 ######################################################################
149 # Get the current version information
150 ######################################################################
151
152 # AmigaOS4's grep has a problem with "./" in pathnames, so use cat.
153 VERSION = $(shell cat "${srcdir}/base/internal_version.h" | grep SCUMMVM_VERSION | cut -d\" -f2)
154 VER_MAJOR = $(shell echo $(VERSION) | cut -d. -f 1)
155 VER_MINOR = $(shell echo $(VERSION) | cut -d. -f 2)
156 VER_PATCH = $(shell echo $(VERSION) | cut -d. -f 3 | cut -c1)
157 VER_EXTRA = $(shell echo $(VERSION) | cut -d. -f 3 | cut -c2-)
158
159
160 ######################################################################
161 # Get Subversion's working copy information
162 ######################################################################
163
164 ifneq ($(shell svn info $(srcdir) 1>/dev/null 2>&1 || echo "error"),error)
165 SVNROOT := $(srcdir)
166 ifeq ($(origin VER_SVNREV), undefined)
167 # Get the working copy base revision
168 VER_SVNREV := $(shell LANG=C svn info $(SVNROOT) | grep "^Revision" | cut -d ' ' -f 2)
169 endif
170 else
171 SVNROOT := https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/
172 endif
173
174 # Define the Subversion revision if available, either autodetected or
175 # specified by the user, but only for base/version.cpp.
176 ifneq ($(origin VER_SVNREV), undefined)
177 base/version.o: CXXFLAGS:=$(CXXFLAGS) -DSCUMMVM_SVN_REVISION=\"$(VER_SVNREV)\"
178 endif
179
180 ######################################################################
181 # Distribution settings
182 ######################################################################
183
184 ifeq ($(VER_EXTRA),svn)
185 ifeq ($(origin VER_SVNREV), undefined)
186 DISTVERSION = $(shell date '+%Y-%m-%d')
187 else
188 DISTVERSION = svn$(VER_SVNREV)
189 endif
190 else
191 DISTVERSION = $(VERSION)
192 endif
193
194 DISTNAME := scummvm-$(DISTVERSION)
195 DISTDIR := dist
196 VERFILE := $(DISTDIR)/$(DISTNAME)/base/internal_version.h
197
198 $(VERFILE): $(srcdir)/base/internal_version.h
199 @$(RM_REC) $(DISTDIR)
200 @$(MKDIR) $(DISTDIR)
201 svn export $(SVNROOT) $(DISTDIR)/$(DISTNAME)
202 ifneq ($(origin VER_SVNREV), undefined)
203 @# Use the current SVN revision as a default for the snapshot sources
204 @svn cat $(SVNROOT)/base/internal_version.h | sed -e \
205 "s/^#define SCUMMVM_SVN_REVISION$$/#define SCUMMVM_SVN_REVISION \"$(VER_SVNREV)\"/g" \
206 > $(VERFILE)
207 endif
208
209 $(DISTDIR)/$(DISTNAME).tar.gz: $(VERFILE)
210 cd $(DISTDIR); tar zcf $(DISTNAME).tar.gz $(DISTNAME)
211
212 $(DISTDIR)/$(DISTNAME).tar.bz2: $(VERFILE)
213 cd $(DISTDIR); tar jcf $(DISTNAME).tar.bz2 $(DISTNAME)
214
215 $(DISTDIR)/$(DISTNAME).zip: $(VERFILE)
216 cd $(DISTDIR); zip -qr9 $(DISTNAME).zip $(DISTNAME)
217
218 dist-src: \
219 $(DISTDIR)/$(DISTNAME).tar.gz \
220 $(DISTDIR)/$(DISTNAME).tar.bz2 \
221 $(DISTDIR)/$(DISTNAME).zip
222 @#RPM-src?
223 @#DEB-src?
224
225 # Common files
226 DIST_FILES_DOCS:=$(addprefix $(srcdir)/,AUTHORS COPYING COPYING.BSD COPYING.LGPL COPYRIGHT NEWS README)
227
228 # Themes files
229 DIST_FILES_THEMES=scummmodern.zip scummclassic.zip
230 ifdef USE_TRANSLATION
231 DIST_FILES_THEMES+=translations.dat
232 endif
233 DIST_FILES_THEMES:=$(addprefix $(srcdir)/gui/themes/,$(DIST_FILES_THEMES))
234
235 # Engine data files
236 DIST_FILES_ENGINEDATA=
237 ifdef ENABLE_DRASCULA
238 DIST_FILES_ENGINEDATA+=drascula.dat
239 endif
240 ifdef ENABLE_HUGO
241 DIST_FILES_ENGINEDATA+=hugo.dat
242 endif
243 ifdef ENABLE_KYRA
244 DIST_FILES_ENGINEDATA+=kyra.dat
245 endif
246 ifdef ENABLE_LURE
247 DIST_FILES_ENGINEDATA+=lure.dat
248 endif
249 ifdef ENABLE_M4
250 DIST_FILES_ENGINEDATA+=m4.dat
251 endif
252 ifdef ENABLE_QUEEN
253 DIST_FILES_ENGINEDATA+=queen.tbl
254 endif
255 ifdef ENABLE_SKY
256 DIST_FILES_ENGINEDATA+=sky.cpt
257 endif
258 ifdef ENABLE_TEENAGENT
259 DIST_FILES_ENGINEDATA+=teenagent.dat
260 endif
261 ifdef ENABLE_TOON
262 DIST_FILES_ENGINEDATA+=toon.dat
263 endif
264 DIST_FILES_ENGINEDATA:=$(addprefix $(srcdir)/dists/engine-data/,$(DIST_FILES_ENGINEDATA))
265
266 # pred.dic is currently only used for the AGI engine
267 ifdef ENABLE_AGI
268 DIST_FILES_ENGINEDATA+=$(srcdir)/dists/pred.dic
269 endif
270
271 .PHONY: all clean distclean plugins dist-src
Something went wrong with that request. Please try again.