aboutsummaryrefslogtreecommitdiff
path: root/Makefile.common
blob: 965f73dd42bd856be12cb69b47ec6664922e9d75 (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
# $Id$
# 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


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

MODULES := test tools base $(MODULES)

-include $(srcdir)/engines/engines.mk

# After the game specific modules follow the shared modules
MODULES += \
	engines \
	gui \
	graphics \
	sound \
	common \
	backends

ifdef USE_MT32EMU
MODULES += sound/softsynth/mt32
endif

ifdef DISABLE_SCALERS
DEFINES += -DDISABLE_SCALERS
endif

ifdef DISABLE_HQ_SCALERS
DEFINES += -DDISABLE_HQ_SCALERS
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))

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

distclean: clean
	$(RM_REC) $(DEPDIRS)
	$(RM) config.h config.mk config.log

clean:
	$(RM) $(OBJS) $(EXECUTABLE)

# Old (dumb) compile & dependcy rules
#INCS	= scumm/scumm.h common/scummsys.h
#.cpp.o:
#	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
#$(OBJS): $(INCS)

ifndef HAVE_GCC3
# If you use GCC, disable the above and enable this for intelligent
# dependency tracking. 
%.o: %.cpp
	$(MKDIR) $(*D)/$(DEPDIR)
	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d2" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
	$(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d
	$(CAT) "$(*D)/$(DEPDIR)/$(*F).d2" >> "$(*D)/$(DEPDIR)/$(*F).d"
	$(RM) "$(*D)/$(DEPDIR)/$(*F).d2"
else
# If you even have GCC 3.x, you can use this build rule, which is safer; the above
# rule can get you into a bad state if you Ctrl-C at the wrong moment.
# Also, with this GCC inserts additional dummy rules for the involved headers,
# which ensures a smooth compilation even if said headers become obsolete.
%.o: %.cpp
	$(MKDIR) $(*D)/$(DEPDIR)
	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
%.o: %.m
	$(MKDIR) $(*D)/$(DEPDIR)
	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(OBJCFLAGS) -c $(<) -o $*.o
endif

ifdef HAVE_NASM
%.o: %.asm
	$(NASM) -O1 $(NASMFLAGS) -g -o $*.o $(<)
endif

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


######################################################################
# Create the files that depend on the version
######################################################################

VERSION_FILES = \
	$(srcdir)/dists/iphone/Info.plist \
	$(srcdir)/dists/macosx/Info.plist

VERSION = $(shell cat "${srcdir}/base/internal_version.h" | 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-)

$(VERSION_FILES): %: %.in
	@echo "Creating $@"
	@cat $< | sed \
		-e "s/@VER_MAJOR@/$(VER_MAJOR)/g" \
		-e "s/@VER_MINOR@/$(VER_MINOR)/g" \
		-e "s/@VER_PATCH@/$(VER_PATCH)/g" \
		-e "s/@VER_EXTRA@/$(VER_EXTRA)/g" \
		-e "s/@VERSION@/$(VERSION)/g" \
		> $@


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

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

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

ifeq ($(shell svn stat $(srcdir) 2>&1 | grep "is not a working copy"),)
SVNROOT := $(srcdir)
else
SVNROOT := https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/
endif

$(VERFILE): $(srcdir)/base/internal_version.h
	@$(RM_REC) $(DISTDIR)
	@$(MKDIR) $(DISTDIR)
	svn export $(SVNROOT) $(DISTDIR)/$(DISTNAME)

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


# Themes files
DIST_FILES_THEMES:=$(addprefix $(srcdir)/gui/themes/,modern.ini modern.zip)

# Engine data files
DIST_FILES_ENGINEDATA=
ifndef DISABLE_IGOR
DIST_FILES_ENGINEDATA+=igor.tbl
endif
ifndef DISABLE_KYRA
DIST_FILES_ENGINEDATA+=kyra.dat
endif
ifndef DISABLE_LURE
DIST_FILES_ENGINEDATA+=lure.dat
endif
ifndef DISABLE_QUEEN
DIST_FILES_ENGINEDATA+=queen.tbl
endif
ifndef DISABLE_SKY
DIST_FILES_ENGINEDATA+=sky.cpt
endif
DIST_FILES_ENGINEDATA:=$(addprefix $(srcdir)/dists/engine-data/,$(DIST_FILES_ENGINEDATA))

.PHONY: all clean distclean plugins dist-src