Ticket #14290: Makefile

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