aboutsummaryrefslogtreecommitdiff
path: root/Makefile.common
blob: 78e0d6e423ca5c3faac522a63f618caad4960ae7 (plain)
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# This file is used by Makefile and declares common build rules,
# a list of common object files etc.
#

######################################################################
# The default build target: just build the scummvm executable
######################################################################

all: $(EXECUTABLE) plugins

ifdef SPLIT_DWARF
all: $(EXECUTABLE).dwp
endif

ifdef USE_PANDOC
all: README$(PANDOCEXT) NEWS$(PANDOCEXT) doc/de/NEUES$(PANDOCEXT)
endif

######################################################################
# Module settings
######################################################################

PLUGINS :=
MODULES := test devtools base $(MODULES)

-include engines/engines.mk

# After the game specific modules follow the shared modules
MODULES += \
	gui \
	backends \
	engines \
	video \
	image \
	graphics \
	audio \
	common \
	po

ifdef USE_MT32EMU
MODULES += audio/softsynth/mt32
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 =

# 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
# the build date in gScummVMBuildDate is correct.
base/version.o: $(filter-out base/libbase.a,$(OBJS))

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)
QUIET_CC      = @echo '   ' C '      ' $@;
QUIET_CXX     = @echo '   ' C++ '    ' $@;
QUIET_AS      = @echo '   ' AS '     ' $@;
QUIET_NASM    = @echo '   ' NASM '   ' $@;
QUIET_PANDOC  = @echo '   ' PANDOC ' ' $@;
QUIET_AR      = @echo '   ' AR '     ' $@;
QUIET_RANLIB  = @echo '   ' RANLIB ' ' $@;
QUIET_PLUGIN  = @echo '   ' PLUGIN ' ' $@;
QUIET_LINK    = @echo '   ' LINK '   ' $@;
QUIET_DWP     = @echo '   ' DWP '    ' $@;
QUIET_WINDRES = @echo '   ' WINDRES '' $@;
QUIET         = @
endif
endif
endif

# The build rule for the ScummVM executable
$(EXECUTABLE): $(OBJS)
	$(QUIET_LINK)$(LD) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@

ifdef SPLIT_DWARF
$(EXECUTABLE).dwp: $(EXECUTABLE)
	$(QUIET_DWP)$(DWP) -e $(EXECUTABLE)
endif

distclean: clean clean-devtools
	$(RM) config.h config.mk config.log engines/engines.mk engines/plugins_table.h

clean:
	$(RM_REC) $(DEPDIRS)
	$(RM) $(OBJS) $(EXECUTABLE)
ifdef SPLIT_DWARF
	$(RM) $(OBJS:.o=.dwo)
	$(RM) $(EXECUTABLE).dwp
endif


#
# 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: %.c
	$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
	$(QUIET_CC)$(CC) $(CXX_UPDATE_DEP_FLAG) $(CFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
%.o: %.cpp
	$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
	$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o


# 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)
	$(QUIET_CXX)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(CPPFLAGS) $(OBJCFLAGS) -c $(<) -o $*.o

# Build rule for assembler files with preprocessing
%.o: %.S
	$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
	$(QUIET_AS)$(CXX) $(CXX_UPDATE_DEP_FLAG) $(ASFLAGS) -c $(<) -o $*.o

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:
	$(QUIET)$(MKDIR) $(*D)
	$(QUIET_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o

# Build rule for assembler files with preprocessing
%.o: %.S
	$(QUIET)$(MKDIR) $(*D)
	$(QUIET_AS)$(CXX) $(ASFLAGS) -c $(<) -o $*.o

endif

# Build rule for assembler files
%.o: %.s
	$(QUIET)$(MKDIR) $(*D)
	$(QUIET_AS)$(AS) $(ASFLAGS) $(<) -o $*.o

# Build rule for Windows resource files
# TODO: Support dependency tracking
%.o: %.rc
	$(QUIET)$(MKDIR) $(*D)
	$(QUIET_WINDRES)$(WINDRES) $(WINDRESFLAGS) $(CPPFLAGS) $(<) -o $*.o

ifdef USE_NASM
# Build rule for NASM assembler files
%.o: %.asm
	$(QUIET)$(MKDIR) $(*D)
	$(QUIET_NASM)$(NASM) $(NASMFLAGS) -o $*.o $(<)
endif

# Include the dependency tracking files.
-include $(wildcard $(addsuffix /*.d,$(DEPDIRS)))

# 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

######################################################################
# Get the current version information
######################################################################

# 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-)

ifdef AMIGAOS
# Amiga needs date in specific format for the version cookie
AMIGA_DATE = $(shell gdate '+%d.%m.%Y')
base/version.o: CXXFLAGS:=$(CXXFLAGS) -DAMIGA_DATE=\"$(AMIGA_DATE)\"
endif

######################################################################
# Get git's working copy information
######################################################################

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")
# Get the working copy base revision
VER_REV := $(shell cd $(srcdir); git describe --long --match desc/\* | cut -d '-' -f 2-)$(VER_DIRTY)
endif
else
GITROOT := git://github.com/scummvm/scummvm.git
endif

# Define the Subversion revision if available, either autodetected or
# specified by the user, but only for base/version.cpp.
ifneq ($(origin VER_REV), undefined)
base/version.o: CXXFLAGS:=$(CXXFLAGS) -DSCUMMVM_REVISION=\"$(VER_REV)\"
endif

######################################################################
# Distribution settings
######################################################################

ifeq ($(VER_EXTRA),git)
ifeq ($(origin VER_REV), undefined)
DISTVERSION = $(shell date '+%Y-%m-%d')
else
DISTVERSION = git$(VER_REV)
endif
else
DISTVERSION = $(VERSION)
endif

DISTNAME := scummvm-$(DISTVERSION)
DISTDIR := dist
VERFILE := $(DISTDIR)/$(DISTNAME)/base/internal_version.h

ifdef USE_PANDOC
# Convert README.md and NEWS.md to plain text for any platform that might require it
%$(PANDOCEXT): %.md
	$(QUIET)$(MKDIR) $(*D)
	$(QUIET_PANDOC)$(PANDOC) -f gfm -t $(PANDOCFORMAT) --metadata pagetitle=$(basename $(notdir $@)) -s -o $@ $<
endif

# TODO git via $(GITROOT)
$(VERFILE): $(srcdir)/base/internal_version.h
	@$(RM_REC) $(DISTDIR)
	@$(MKDIR) $(DISTDIR)
	svn export $(SVNROOT) $(DISTDIR)/$(DISTNAME)
ifneq ($(origin VER_REV), undefined)
	@# Use the current SVN revision as a default for the snapshot sources
	@svn cat $(SVNROOT)/base/internal_version.h | sed -e \
		"s/^#define SCUMMVM_REVISION$$/#define SCUMMVM_REVISION \"$(VER_REV)\"/g" \
		> $(VERFILE)
endif

$(DISTDIR)/$(DISTNAME).tar.gz: $(VERFILE)
	cd $(DISTDIR); tar zcf $(DISTNAME).tar.gz $(DISTNAME)

$(DISTDIR)/$(DISTNAME).tar.bz2: $(VERFILE)
	cd $(DISTDIR); tar jcf $(DISTNAME).tar.bz2 $(DISTNAME)

$(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?

# Common files
DIST_FILES_DOCS:=$(addprefix $(srcdir)/,AUTHORS COPYING COPYING.BSD COPYING.LGPL COPYING.FREEFONT COPYING.OFL COPYRIGHT NEWS.md README.md)
ifdef USE_PANDOC
DIST_FILES_DOCS+=README$(PANDOCEXT) NEWS$(PANDOCEXT)
endif

DIST_FILES_DOCS_languages=cz da de es fr it no-nb se
DIST_FILES_DOCS_cz:=$(addprefix $(srcdir)/doc/cz/,PrectiMe)
DIST_FILES_DOCS_da:=$(addprefix $(srcdir)/doc/da/,HurtigStart)
DIST_FILES_DOCS_de:=$(addprefix $(srcdir)/doc/de/,LIESMICH NEUES.md Schnellstart)
ifdef USE_PANDOC
DIST_FILES_DOCS_de+=doc/de/NEUES$(PANDOCEXT)
endif
DIST_FILES_DOCS_es:=$(addprefix $(srcdir)/doc/es/,InicioRapido)
DIST_FILES_DOCS_fr:=$(addprefix $(srcdir)/doc/fr/,DemarrageRapide)
DIST_FILES_DOCS_it:=$(addprefix $(srcdir)/doc/it/,GuidaRapida)
DIST_FILES_DOCS_no-nb:=$(addprefix $(srcdir)/doc/no-nb/,HurtigStart)
DIST_FILES_DOCS_se:=$(addprefix $(srcdir)/doc/se/,LasMig Snabbstart)

# Themes files
DIST_FILES_THEMES=scummmodern.zip scummclassic.zip scummremastered.zip
ifdef USE_TRANSLATION
DIST_FILES_THEMES+=translations.dat
endif
DIST_FILES_THEMES:=$(addprefix $(srcdir)/gui/themes/,$(DIST_FILES_THEMES))

# Networking files
DIST_FILES_NETWORKING=
ifdef USE_SDL_NET
DIST_FILES_NETWORKING:=$(addprefix $(srcdir)/dists/networking/,wwwroot.zip)
endif

# Engine data files
DIST_FILES_ENGINEDATA=
ifdef ENABLE_ACCESS
DIST_FILES_ENGINEDATA+=access.dat
endif
ifdef ENABLE_CRYO
DIST_FILES_ENGINEDATA+=cryo.dat
endif
ifdef ENABLE_DRASCULA
DIST_FILES_ENGINEDATA+=drascula.dat
endif
ifdef ENABLE_HUGO
DIST_FILES_ENGINEDATA+=hugo.dat
endif
ifdef ENABLE_KYRA
DIST_FILES_ENGINEDATA+=kyra.dat
endif
ifdef ENABLE_LURE
DIST_FILES_ENGINEDATA+=lure.dat
endif
ifdef ENABLE_MORTEVIELLE
DIST_FILES_ENGINEDATA+=mort.dat
endif
ifdef ENABLE_NEVERHOOD
DIST_FILES_ENGINEDATA+=neverhood.dat
endif
ifdef ENABLE_QUEEN
DIST_FILES_ENGINEDATA+=queen.tbl
endif
ifdef ENABLE_SKY
DIST_FILES_ENGINEDATA+=sky.cpt
endif
ifdef ENABLE_SUPERNOVA
DIST_FILES_ENGINEDATA+=supernova.dat
endif
ifdef ENABLE_TEENAGENT
DIST_FILES_ENGINEDATA+=teenagent.dat
endif
ifdef ENABLE_TITANIC
DIST_FILES_ENGINEDATA+=titanic.dat
endif
ifdef ENABLE_TONY
DIST_FILES_ENGINEDATA+=tony.dat
endif
ifdef ENABLE_TOON
DIST_FILES_ENGINEDATA+=toon.dat
endif
ifdef ENABLE_WINTERMUTE
DIST_FILES_ENGINEDATA+=wintermute.zip
endif
ifdef ENABLE_MACVENTURE
DIST_FILES_ENGINEDATA+=macventure.dat
endif
ifdef ENABLE_XEEN
DIST_FILES_ENGINEDATA+=xeen.ccs
endif
ifdef USE_FREETYPE2
DIST_FILES_ENGINEDATA+=fonts.dat
endif
DIST_FILES_ENGINEDATA:=$(addprefix $(srcdir)/dists/engine-data/,$(DIST_FILES_ENGINEDATA))

# pred.dic is currently only used for the AGI engine
ifdef ENABLE_AGI
DIST_FILES_ENGINEDATA+=$(srcdir)/dists/pred.dic
endif

.PHONY: all clean distclean plugins dist-src