1
2#######################################################################
3# Default compilation parameters. Normally don't edit these           #
4#######################################################################
5
6srcdir      ?= .
7
8DEFINES     := -DHAVE_CONFIG_H
9LDFLAGS     :=
10INCLUDES    := -I. -I$(srcdir) -I$(srcdir)/engines
11LIBS        :=
12OBJS        :=
13DEPDIR      := .deps
14
15MODULES     :=
16MODULE_DIRS :=
17
18# All game detection-related object files for engines
19DETECT_OBJS :=
20LOAD_RULES_MK   := 1
21
22# Load the make rules generated by configure
23-include config.mk
24
25ifeq "$(HAVE_GCC)" "1"
26	CXXFLAGS:= -Wall $(CXXFLAGS)
27	# Turn off some annoying and not-so-useful warnings
28	CXXFLAGS+= -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder
29	# Enable even more warnings...
30	CXXFLAGS+= -Wpointer-arith -Wcast-qual
31	CXXFLAGS+= -Wshadow -Wnon-virtual-dtor -Wwrite-strings
32
33	# Currently we disable this gcc flag, since it will also warn in cases,
34	# where using GCC_PRINTF (means: __attribute__((format(printf, x, y))))
35	# is not possible, thus it would fail compiliation with -Werror without
36	# being helpful.
37	#CXXFLAGS+= -Wmissing-format-attribute
38
39	# Disable exceptions.
40	CXXFLAGS+= -fno-exceptions
41
42ifneq "$(HAVE_CLANG)" "1"
43	# enable checking of pointers returned by "new", but only when we do not
44	# build with clang
45	CXXFLAGS+= -fcheck-new
46endif
47endif
48
49ifeq "$(HAVE_CLANG)" "1"
50	CXXFLAGS+= -Wno-conversion -Wno-shorten-64-to-32 -Wno-sign-compare -Wno-four-char-constants
51	# We use a anonymous nested type declaration in an anonymous union in
52	# common/str.h. This is no standard construct and clang warns about it.
53	# It works for all our target systems though, thus we simply disable that
54	# warning.
55	CXXFLAGS+= -Wno-nested-anon-types
56endif
57
58ifeq "$(HAVE_ICC)" "1"
59	# Disable some warnings:
60	#  161: unrecognized #pragma
61	# 1899: multicharacter character literal (potential portability problem)
62	CXXFLAGS+= -diag-disable 161,1899
63endif
64
65#######################################################################
66# Default commands - put the necessary replacements in config.mk      #
67#######################################################################
68
69CAT     ?= cat
70CP      ?= cp
71ECHO    ?= printf
72INSTALL ?= install
73MKDIR   ?= mkdir -p
74RM      ?= rm -f
75RM_REC  ?= $(RM) -r
76ZIP     ?= zip -q
77
78#######################################################################
79# Misc stuff - you should never have to edit this                     #
80#######################################################################
81
82EXECUTABLE  := $(EXEPRE)scummvm$(EXEEXT)
83
84include $(srcdir)/Makefile.common
85
86ENGINE_SUBDIRS_CONFIGURE := $(wildcard $(srcdir)/engines/*/configure.engine)
87
88config.h:
89SAVED_ENV_VARS = AR AS ASFLAGS CPPFLAGS CXX CXXFLAGS LD LDFLAGS RANLIB SDL_CONFIG STRIP WINDRES WINDRESFLAGS
90
91# The environment variable PKG_CONFIG_LIBDIR has a different meaning
92# for pkg-config when it is empty and when it is not defined.
93# When PKG_CONFIG_LIBDIR is defined but empty, the .pc files cannot
94# be found because the search path is empty.
95# Here we make sure not to define PKG_CONFIG_LIBDIR when automatically
96# running configure and it was not set for the previous run
97# so pkg-config uses the system default search path for the .pc files.
98ifneq ($(SAVED_PKG_CONFIG_LIBDIR),unset)
99	SAVED_ENV_VARS += PKG_CONFIG_LIBDIR
100endif
101
102# check if configure has been run or has been changed since last run
103configure.stamp: $(srcdir)/configure $(srcdir)/engines.awk $(ENGINE_SUBDIRS_CONFIGURE)
104ifeq "$(findstring config.mk,$(MAKEFILE_LIST))" "config.mk"
105	@echo "Running $(srcdir)/configure with the last specified parameters"
106	@sleep 2
107
108	$(foreach VAR,$(SAVED_ENV_VARS),$(VAR)="$(SAVED_$(VAR))") \
109		$(srcdir)/configure $(SAVED_CONFIGFLAGS)
110else
111	$(error You need to run $(srcdir)/configure before you can run make. Check $(srcdir)/configure --help for a list of parameters)
112endif
113
114config.h config.mk engines/plugins_table.h engines/detection_table.h engines/engines.mk: configure.stamp
115	@if ! test -f $@; then \
116		rm -f configure.stamp; \
117		$(MAKE) configure.stamp; \
118	fi
119
120ifneq ($(origin port_mk), undefined)
121include $(srcdir)/$(port_mk)
122endif
123
124.PHONY: print-dists print-executables print-version print-distversion
125print-dists:
126	@echo $(DIST_FILES_DOCS) $(DIST_FILES_THEMES) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_PLATFORM) $(srcdir)/doc
127
128print-executables:
129	@echo $(if $(DIST_EXECUTABLES),$(DIST_EXECUTABLES),$(EXECUTABLE) $(PLUGINS))
130
131print-version:
132	@echo $(VERSION)
133
134print-distversion:
135	@echo $(DISTVERSION)
136
137devtools/create_project/cmake/build/create_project:
138	cmake -Hdevtools/create_project/cmake -Bdevtools/create_project/cmake/build/
139	cmake --build devtools/create_project/cmake/build/
140
141CMakeLists.txt: devtools/create_project/cmake/build/create_project config.mk
142	./devtools/create_project/cmake/build/create_project . --cmake $(SAVED_CONFIGFLAGS)
143
144cmake: CMakeLists.txt
145	cmake -H. -Bbuild
146	cmake --build build
147