author | darkvater |
Sun, 12 Sep 2004 21:49:38 +0000 | |
changeset 222 | b88456001397 |
parent 221 | 124a804562a5 |
child 285 | e306da1c4ad1 |
permissions | -rw-r--r-- |
0 | 1 |
# This Makefile is partially based on "a completely generic Makefile", |
2 |
# originally created by Justin Husted <husted@cs> |
|
3 |
# |
|
4 |
# Rewrite and sane dependencies support by Petr Baudis <pasky@ucw.cz> |
|
5 |
# Cygwin support and configuration by Jaen Saul <slowbyte@hot.ee> |
|
6 |
# A lot of modifications by Bjarni Corfitzen <bjarni@openttd.com> |
|
7 |
# |
|
8 |
# Last modified by: $Author: strigeus $ |
|
9 |
# On: $Date: 2004/03/11 19:15:06 $ |
|
10 |
||
11 |
||
12 |
############################################################################## |
|
13 |
# |
|
14 |
# Usage |
|
15 |
# |
|
16 |
||
17 |
# Synopsis: |
|
18 |
# |
|
19 |
# make WITH_ZLIB=1 UNIX=1 MANUAL_CONFIG=1 |
|
20 |
# |
|
21 |
# (See below for the list of possible options.) |
|
22 |
# |
|
23 |
# Alternately, you can run make without the MANUAL_CONFIG part. It then |
|
24 |
# generates Makefile.config, where you can customize all the options. |
|
25 |
# However beware that for all subsequent calls the option values from |
|
26 |
# Makefile.config take precedence to the commandline options. |
|
27 |
# |
|
28 |
# (That means that you probably want to either specify the options on command |
|
29 |
# line together with MANUAL_CONFIG=1 or you want to specify no commandline |
|
30 |
# options at all.) |
|
31 |
||
32 |
# Targets: |
|
33 |
# |
|
34 |
# Defaults to building binary |
|
35 |
# clean: remove intermediate build files |
|
36 |
# mrproper: remove intermediate files and makefile configuration |
|
37 |
# upgradeconf: add new options to old Makefile.config |
|
38 |
# osx: OS X application |
|
39 |
||
40 |
# Options: |
|
41 |
# |
|
42 |
# Summary of OS choice defines |
|
43 |
# WIN32: building on Windows |
|
44 |
# UNIX: building on *nix derivate (Linux, FreeBSD) |
|
45 |
# OSX: building on Mac OS X |
|
46 |
# MORPHOS: building on MorphOS |
|
47 |
# |
|
48 |
# Summary of library choice defines |
|
49 |
# WITH_ZLIB: savegames using zlib |
|
50 |
# WITH_PNG: screenshots using PNG |
|
51 |
# WITH_SDL: SDL video driver support |
|
52 |
# |
|
53 |
# Summary of other defines: |
|
54 |
# MANUAL_CONFIG: do not use Makefile.config, config options set manually |
|
55 |
# DEBUG: build in debug mode |
|
56 |
# PROFILE: build in profile mode, disables -s and -fomit-frame-pointer |
|
57 |
# DISPLAY_WARNINGS: when off, some errors are not displayed while compiling |
|
58 |
# TRANSLATOR: build in translator mode (untranslated strings are prepended by |
|
59 |
# a <TODO> mark) |
|
60 |
# RELEASE: this will be the released version number. It replaces all places |
|
61 |
# where it normally would print the revision number |
|
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
62 |
# MIDI: if set, it will use it as custom path to midi player. |
0 | 63 |
# If unset, it will use the hardcoded path in the c code |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
64 |
# NOVERBOSE: supress all warnings and errors during compilation. |
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
65 |
# It looks nicer, but you will not know what went wrong. Use it on released (stable) sources only |
0 | 66 |
# |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
67 |
# DATA_DIR_PREFIX: This sets the dir OpenTTD looks for the needed files. |
0 | 68 |
# MUST END WITH / if defined |
69 |
# |
|
70 |
# STATIC: link statically |
|
71 |
# CYGWIN: build in Cygwin environment |
|
72 |
# MINGW: build with MingW compiler, link with MingW libraries |
|
73 |
# |
|
74 |
# Experimental (does not work properly): |
|
75 |
# WITH_NETWORK: enable networking |
|
76 |
# WITH_DIRECTMUSIC: enable DirectMusic MIDI support |
|
77 |
||
78 |
||
79 |
############################################################################## |
|
80 |
# |
|
81 |
# Configuration |
|
82 |
# |
|
83 |
||
180
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
84 |
# Makefile version tag |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
85 |
# it checks if the version tag in makefile.config is the same and force update outdated config files |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
86 |
MAKEFILE_VERSION:=1 |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
87 |
|
0 | 88 |
# CONFIG_WRITER have to be found even for manual configuration |
89 |
CONFIG_WRITER=makefiledir/Makefile.config_writer |
|
90 |
||
91 |
ifndef MANUAL_CONFIG |
|
92 |
# Automatic configuration |
|
93 |
MAKE_CONFIG:=Makefile.config |
|
94 |
MAKEFILE:=Makefile |
|
95 |
LIB_DETECTION=makefiledir/Makefile.libdetection |
|
96 |
CONFIG_WRITER=makefiledir/Makefile.config_writer |
|
97 |
||
98 |
# Apply automatic configuration |
|
99 |
# See target section for how this is built, suppress errors |
|
100 |
# since first time it isn't found but make reads this twice |
|
101 |
-include $(MAKE_CONFIG) |
|
102 |
else |
|
103 |
CONFIG_INCLUDED:=1 |
|
104 |
endif |
|
105 |
||
180
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
106 |
# updates makefile.config if it's outdated |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
107 |
ifneq ($(MAKEFILE_VERSION),$(CONFIG_VERSION)) |
189
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
108 |
ifndef MANUAL_CONFIG # manual config should not check this |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
109 |
UPDATECONFIG:=upgradeconf |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
110 |
CONFIG_INCLUDED:= |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
111 |
else |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
112 |
# this should define SDL-CONFIG for manual configuration |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
113 |
ifeq ($(shell uname),FreeBSD) |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
114 |
SDL-CONFIG:=sdl11-config |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
115 |
else |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
116 |
SDL-CONFIG:=sdl-config |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
117 |
endif |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
118 |
endif |
0 | 119 |
else |
189
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
120 |
# this should define SDL-CONFIG for manual configuration |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
121 |
ifeq ($(shell uname),FreeBSD) |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
122 |
SDL-CONFIG:=sdl11-config |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
123 |
else |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
124 |
SDL-CONFIG:=sdl-config |
4d133909845a
(svn r190) Makefile: fixed bug, that prevented compilation with MANUAL_CONFIG enabled
bjarni
parents:
180
diff
changeset
|
125 |
endif |
0 | 126 |
endif |
127 |
||
219
adfdf7fad721
(svn r220) Makefile: enables ENABLE_NETWORK by default if no config file is present
bjarni
parents:
189
diff
changeset
|
128 |
# this is used if there aren't any makefile.config |
0 | 129 |
ifndef CONFIG_INCLUDED |
219
adfdf7fad721
(svn r220) Makefile: enables ENABLE_NETWORK by default if no config file is present
bjarni
parents:
189
diff
changeset
|
130 |
ENABLE_NETWORK:=1 # sets network on by default if there aren't any config file |
0 | 131 |
-include $(LIB_DETECTION) |
132 |
endif |
|
133 |
||
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
134 |
# Verbose filter |
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
135 |
|
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
136 |
ifdef NOVERBOSE |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
137 |
VERBOSE_FILTER = >/dev/null 2>&1 |
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
138 |
else |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
139 |
VERBOSE_FILTER = |
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
140 |
endif |
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
141 |
|
0 | 142 |
ifdef DISPLAY_WARNINGS |
143 |
WARNING_DISPLAY:=-fstrict-aliasing |
|
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
144 |
VERBOSE_FILTER = |
0 | 145 |
else |
146 |
WARNING_DISPLAY:=-fno-strict-aliasing |
|
147 |
endif |
|
148 |
||
180
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
149 |
ifdef SUPRESS_LANG_ERRORS |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
150 |
ifndef VERBOSE_FILTER |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
151 |
LANG_ERRORS = >/dev/null 2>&1 |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
152 |
endif |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
153 |
endif |
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
154 |
|
0 | 155 |
ifdef STATIC |
156 |
ifndef WIN32 |
|
157 |
ifndef OSX |
|
158 |
ifndef MORPHOS |
|
159 |
ifndef SKIP_STATIC_CHECK |
|
160 |
$(error Static is only known to work on MorphOS and MacOSX!!! --- Check makefile.config for more info and howto bypass this check) |
|
161 |
endif |
|
162 |
endif |
|
163 |
endif |
|
164 |
endif |
|
165 |
endif |
|
166 |
||
167 |
||
168 |
# Force SDL on UNIX platforms |
|
169 |
ifndef WITH_SDL |
|
170 |
ifdef UNIX |
|
171 |
$(error You need to have SDL installed in order to run OpenTTD on UNIX.) |
|
172 |
endif |
|
173 |
endif |
|
174 |
||
175 |
||
176 |
||
177 |
############################################################################## |
|
178 |
# |
|
179 |
# Compiler configuration |
|
180 |
# |
|
181 |
CC=gcc |
|
182 |
CXX=g++ |
|
183 |
||
184 |
ifdef MORPHOS |
|
185 |
CC += -noixemul -pipe |
|
186 |
CXX += -noixemul -pipe |
|
187 |
endif |
|
188 |
||
189 |
# Executable file extension |
|
190 |
ifdef WIN32 |
|
191 |
EXE=.exe |
|
192 |
else |
|
193 |
EXE= |
|
194 |
endif |
|
195 |
||
196 |
# Set output executable names |
|
32 | 197 |
TTD=openttd$(EXE) |
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
198 |
ENDIAN_CHECK=endian_check$(EXE) |
0 | 199 |
STRGEN=strgen/strgen$(EXE) |
200 |
OSXAPP="OpenTTD.app" |
|
201 |
||
202 |
# What revision are we compiling, if we have an idea? |
|
203 |
REV_NUMBER := $(shell if test -d .svn; then svnversion . | tr -dc 0-9; fi) |
|
204 |
||
205 |
ifdef RELEASE |
|
206 |
REV:=$(RELEASE) |
|
207 |
else |
|
208 |
REV := $(shell if test -d .svn; then echo -n r; svnversion .; fi) |
|
209 |
tmp_test:=$(shell echo "$(REV)" | grep "M" ) |
|
210 |
ifdef tmp_test |
|
211 |
REV_NUMBER:=1 |
|
212 |
endif |
|
213 |
endif |
|
214 |
||
215 |
ifndef REV_NUMBER |
|
216 |
REV_NUMBER:=0 |
|
217 |
endif |
|
218 |
||
219 |
# MorphOS needs builddate |
|
220 |
BUILDDATE=`date +%d.%m.%y` |
|
221 |
||
222 |
# AMD64 needs a little more settings to work |
|
223 |
ifeq ($(shell uname -m), x86_64) |
|
224 |
endwarnings:=endwarnings |
|
225 |
64_bit_warnings:=64_bit_warnings |
|
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
226 |
BASECFLAGS += -m64 |
0 | 227 |
endif |
228 |
||
229 |
||
230 |
# When calling the compiler, use these flags |
|
231 |
# -g debugging symbols |
|
232 |
# -Wall all warnings |
|
233 |
# -s automatic strip |
|
234 |
# |
|
235 |
# You may also want: |
|
236 |
# -O optimize or -O2 fully optimize (O's above 2 are not recommended) |
|
237 |
# -pg profile - generate profiling data. See "man gprof" to use this. |
|
238 |
||
239 |
CFLAGS=-Wall -Wno-multichar |
|
240 |
CDEFS=-DWITH_REV |
|
241 |
LDFLAGS= |
|
242 |
LIBS= |
|
243 |
||
244 |
ifdef DEBUG |
|
245 |
# Debug mode |
|
246 |
CDEFS += -D_DEBUG |
|
247 |
BASECFLAGS += -g |
|
248 |
else |
|
249 |
ifdef PROFILE |
|
250 |
BASECFLAGS += -pg |
|
251 |
else |
|
252 |
# Release mode |
|
253 |
ifndef MORPHOS |
|
254 |
# automatical strip breaks under morphos |
|
255 |
BASECFLAGS += -s |
|
256 |
LDFLAGS += -s |
|
257 |
endif |
|
258 |
endif |
|
259 |
||
260 |
ifdef OSX |
|
261 |
# these compilerflags makes the app run as fast as possible without making the app unstable. It works on G3 or newer |
|
262 |
BASECFLAGS += -O3 -funroll-loops -fsched-interblock -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-jumps-max-skip=15 -falign-loops-max-skip=15 -mdynamic-no-pic -mpowerpc-gpopt -force_cpusubtype_ALL $(WARNING_DISPLAY) |
|
263 |
else |
|
264 |
ifdef MORPHOS |
|
265 |
BASECFLAGS += -O2 -funroll-loops -fexpensive-optimizations -mstring -mmultiple $(WARNING_DISPLAY) |
|
266 |
else |
|
267 |
BASECFLAGS += -O2 $(WARNING_DISPLAY) |
|
268 |
endif |
|
269 |
ifndef PROFILE |
|
270 |
BASECFLAGS += -fomit-frame-pointer |
|
271 |
endif |
|
272 |
endif |
|
273 |
endif |
|
274 |
||
275 |
ifdef STATIC |
|
276 |
ifndef OSX # OSX can't build static if -static flag is used |
|
277 |
LDFLAGS += -static |
|
278 |
endif |
|
279 |
endif |
|
280 |
||
281 |
# If building on Cygwin/MingW don't link with Cygwin libs |
|
282 |
ifdef WIN32 |
|
283 |
ifdef MINGW |
|
284 |
ifdef CYGWIN |
|
285 |
BASECFLAGS += -mno-cygwin |
|
286 |
LDFLAGS += -mno-cygwin |
|
287 |
endif |
|
288 |
endif |
|
289 |
endif |
|
290 |
||
291 |
CFLAGS += $(BASECFLAGS) |
|
292 |
||
293 |
ifdef UNIX |
|
294 |
CDEFS += -DUNIX |
|
295 |
endif |
|
296 |
||
297 |
# SDL config |
|
298 |
ifdef WITH_SDL |
|
299 |
CDEFS += -DWITH_SDL |
|
300 |
CFLAGS += `$(SDL-CONFIG) --cflags` |
|
301 |
ifdef STATIC |
|
302 |
LIBS += `$(SDL-CONFIG) --static-libs` |
|
303 |
else |
|
304 |
LIBS += `$(SDL-CONFIG) --libs` |
|
305 |
endif |
|
306 |
endif |
|
307 |
||
308 |
||
309 |
# zlib config |
|
310 |
ifdef WITH_ZLIB |
|
311 |
CDEFS += -DWITH_ZLIB |
|
312 |
ifdef STATIC |
|
313 |
ifdef OSX |
|
314 |
# zlib is default on OSX, so everybody have it. No need for static linking |
|
315 |
LIBS += -lz |
|
316 |
else |
|
317 |
ifndef STATIC_ZLIB_PATH |
|
318 |
ifndef MANUAL_CONFIG |
|
319 |
# updates makefile.config with the zlib path |
|
320 |
UPDATECONFIG:=upgradeconf |
|
321 |
endif |
|
322 |
TEMP:=$(shell ls /lib 2>/dev/null | grep "zlib.a")$(shell ls /lib 2>/dev/null | grep "libz.a") |
|
323 |
ifdef TEMP |
|
324 |
STATIC_ZLIB_PATH:=/lib/$(TEMP) |
|
325 |
else |
|
326 |
TEMP:=$(shell ls /usr/lib 2>/dev/null | grep "zlib.a")$(shell ls /usr/lib 2>/dev/null | grep "libz.a") |
|
327 |
ifdef TEMP |
|
328 |
STATIC_ZLIB_PATH:=/usr/lib/$(TEMP) |
|
329 |
else |
|
330 |
TEMP:=$(shell ls /usr/local/lib 2>/dev/null | grep "zlib.a")$(shell ls /usr/local/lib 2>/dev/null | grep "libz.a") |
|
331 |
ifdef TEMP |
|
332 |
STATIC_ZLIB_PATH:=/usr/local/lib/$(TEMP) |
|
333 |
endif |
|
334 |
endif |
|
335 |
endif |
|
336 |
endif |
|
337 |
LIBS += $(STATIC_ZLIB_PATH) |
|
338 |
endif |
|
339 |
else |
|
340 |
LIBS += -lz |
|
341 |
endif |
|
342 |
endif |
|
343 |
||
344 |
# libpng config |
|
345 |
ifdef WITH_PNG |
|
346 |
CDEFS += -DWITH_PNG |
|
347 |
# FreeBSD doesn't use libpng-config |
|
348 |
ifdef FREEBSD |
|
349 |
LIBS += -lpng |
|
350 |
else |
|
351 |
CFLAGS += `libpng-config --cflags` |
|
352 |
ifdef OSX |
|
353 |
ifdef STATIC |
|
354 |
# Seems like we need a tiny hack for OSX static to work |
|
355 |
LIBS += `libpng-config --prefix`/lib/libpng.a |
|
356 |
else |
|
357 |
LIBS += `libpng-config --libs` |
|
358 |
endif |
|
359 |
else |
|
360 |
# seems like older libpng versions are broken and need this |
|
361 |
PNGCONFIG_FLAGS = --ldflags --libs |
|
362 |
ifdef STATIC |
|
363 |
LIBS += `libpng-config --static $(PNGCONFIG_FLAGS)` |
|
364 |
else |
|
365 |
LIBS += `libpng-config $(PNGCONFIG_FLAGS)` |
|
366 |
endif |
|
367 |
endif |
|
368 |
endif |
|
369 |
endif |
|
370 |
||
371 |
||
372 |
ifdef TRANSLATOR |
|
373 |
STRGEN_FLAGS=-t |
|
374 |
else |
|
375 |
STRGEN_FLAGS= |
|
376 |
endif |
|
377 |
||
378 |
# file paths setup |
|
379 |
ifdef GAME_DATA_DIR |
|
380 |
CDEFS += -DGAME_DATA_DIR=\"$(GAME_DATA_DIR)\" |
|
381 |
endif |
|
382 |
||
383 |
ifdef PERSONAL_DIR |
|
384 |
CDEFS += -DPERSONAL_DIR=\"$(PERSONAL_DIR)\" |
|
385 |
endif |
|
386 |
||
387 |
ifdef USE_HOMEDIR |
|
388 |
CDEFS += -DUSE_HOMEDIR |
|
389 |
endif |
|
390 |
||
391 |
# MIDI setup |
|
392 |
ifdef OSX |
|
393 |
ifndef MIDI |
|
394 |
MIDI:=$(OSXAPP)/contents/macos/track_starter |
|
395 |
endif |
|
396 |
endif |
|
397 |
||
398 |
ifdef MIDI |
|
399 |
CDEFS += -DEXTERNAL_PLAYER=\"$(MIDI)\" |
|
400 |
ifdef MIDI_ARG |
|
401 |
CDEFS += -DMIDI_ARG=\"$(MIDI_ARG)\" |
|
402 |
endif |
|
403 |
endif |
|
404 |
||
405 |
# Experimental |
|
406 |
ifdef WITH_NETWORK |
|
407 |
CDEFS += -DENABLE_NETWORK |
|
408 |
ifdef UNIX |
|
409 |
ifndef OSX |
|
410 |
ifndef MORPHOS |
|
411 |
# this have caused problems on many platforms and disabling it didn't break anything |
|
412 |
# now we test if disabling it as a general breaks it for anybody |
|
413 |
#LIBS += -lresolv |
|
414 |
endif |
|
415 |
endif |
|
416 |
endif |
|
417 |
endif |
|
418 |
||
419 |
ifdef WITH_DIRECTMUSIC |
|
420 |
CDEFS += -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT |
|
421 |
endif |
|
422 |
||
423 |
ifdef WIN32 |
|
424 |
LIBS += -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32 -lstdc++ |
|
425 |
TTDLDFLAGS += -Wl,--subsystem,windows |
|
426 |
endif |
|
427 |
||
428 |
# sets up the paths for use for make install |
|
429 |
ifdef BINARY_DIR |
|
430 |
BINARY_INSTALL:=$(BINARY_DIR)$(TTD) |
|
431 |
else |
|
432 |
BINARY_INSTALL:=$(INSTALL_DIR)$(TTD) |
|
433 |
endif |
|
434 |
ifdef DATA_DIR_PREFIX |
|
435 |
DATA_DIR:=$(DATA_DIR_PREFIX) |
|
436 |
else |
|
437 |
DATA_DIR:=$(INSTALL_DIR) |
|
438 |
endif |
|
439 |
||
440 |
############################################################################## |
|
441 |
# |
|
442 |
# What to compile |
|
443 |
# (users do not want to modify anything below) |
|
444 |
# |
|
445 |
||
446 |
||
447 |
### Sources |
|
448 |
||
449 |
ttd_SOURCES = \ |
|
112
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
450 |
ai.c ai_build.c ai_new.c ai_pathfinder.c ai_shared.c aircraft_cmd.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
451 |
aircraft_gui.c airport.c airport_gui.c aystar.c bridge_gui.c \ |
221
124a804562a5
(svn r222) -Fix: Added network.h and console_cmd.c to MSVC6 Project
signde
parents:
219
diff
changeset
|
452 |
clear_cmd.c command.c console.c console_cmds.c disaster_cmd.c dock_gui.c dummy_land.c economy.c \ |
112
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
453 |
engine.c engine_gui.c fileio.c gfx.c graph_gui.c grfspecial.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
454 |
industry_cmd.c industry_gui.c intro_gui.c landscape.c main_gui.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
455 |
minilzo.c misc.c misc_cmd.c misc_gui.c music_gui.c namegen.c network.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
456 |
network_gui.c news_gui.c oldloader.c order_cmd.c order_gui.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
457 |
pathfind.c player_gui.c players.c queue.c rail_cmd.c rail_gui.c rev.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
458 |
road_cmd.c road_gui.c roadveh_cmd.c roadveh_gui.c saveload.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
459 |
screenshot.c settings.c settings_gui.c ship_cmd.c ship_gui.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
460 |
smallmap_gui.c sound.c spritecache.c station_cmd.c station_gui.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
461 |
strings.c subsidy_gui.c terraform_gui.c texteff.c town_cmd.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
462 |
town_gui.c train_cmd.c train_gui.c tree_cmd.c ttd.c tunnelbridge_cmd.c \ |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
163
diff
changeset
|
463 |
unmovable_cmd.c vehicle.c vehicle_gui.c viewport.c water_cmd.c widget.c window.c \ |
0 | 464 |
|
465 |
ifdef WITH_SDL |
|
466 |
ttd_SOURCES += sdl.c |
|
467 |
endif |
|
468 |
||
469 |
ifdef WIN32 |
|
470 |
ttd_SOURCES += win32.c w32dm.c |
|
471 |
else |
|
472 |
ttd_SOURCES += extmidi.c unix.c |
|
473 |
endif |
|
474 |
||
475 |
ttd_OBJS = $(ttd_SOURCES:%.c=%.o) |
|
476 |
||
477 |
ifdef WIN32 |
|
478 |
# Resource file |
|
479 |
ttd_OBJS += winres.o |
|
480 |
endif |
|
481 |
||
482 |
ifdef WITH_DIRECTMUSIC |
|
483 |
ttd_SOURCES += w32dm2.cpp |
|
484 |
ttd_OBJS += w32dm2.o |
|
485 |
endif |
|
486 |
||
487 |
ttd_DEPS1 = $(foreach obj,$(ttd_OBJS),.deps/$(obj)) |
|
488 |
ttd_DEPS = $(ttd_DEPS1:%.o=%.P) |
|
489 |
||
490 |
LANG_TXT = $(filter-out %.unfinished.txt,$(wildcard lang/*.txt)) |
|
491 |
LANGS = $(LANG_TXT:%.txt=%.lng) |
|
492 |
||
493 |
C_COMPILE = $(CC) $(CFLAGS) $(CDEFS) |
|
494 |
CXX_COMPILE = $(CXX) $(CFLAGS) $(CDEFS) |
|
495 |
||
496 |
C_BUILD = $(C_COMPILE) -c |
|
497 |
CXX_BUILD = $(CXX_COMPILE) -c |
|
498 |
||
499 |
C_LINK = $(CC) $(LDFLAGS) -o |
|
500 |
||
501 |
||
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
502 |
|
0 | 503 |
############################################################################## |
504 |
# |
|
505 |
# Targets |
|
506 |
# |
|
507 |
||
508 |
||
509 |
### Normal build rules |
|
510 |
||
511 |
||
512 |
ifdef OSX |
|
513 |
OSX:=OSX |
|
514 |
endif |
|
515 |
||
516 |
||
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
517 |
all: endian.h $(UPDATECONFIG) $(TTD) $(OSX) $(endwarnings) |
0 | 518 |
|
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
519 |
endian.h: $(ENDIAN_CHECK) |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
520 |
@# Check if system is LITTLE_ENDIAN or BIG_ENDIAN |
163
deb9b58db3f4
(svn r164) -Fix: Makefile did not clean up endian-files
truelight
parents:
162
diff
changeset
|
521 |
@echo 'Running endian_check'; \ |
deb9b58db3f4
(svn r164) -Fix: Makefile did not clean up endian-files
truelight
parents:
162
diff
changeset
|
522 |
./$(ENDIAN_CHECK) > $@ |
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
523 |
|
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
524 |
$(ENDIAN_CHECK): endian_check.c |
163
deb9b58db3f4
(svn r164) -Fix: Makefile did not clean up endian-files
truelight
parents:
162
diff
changeset
|
525 |
@echo 'Compiling and Linking $@'; \ |
deb9b58db3f4
(svn r164) -Fix: Makefile did not clean up endian-files
truelight
parents:
162
diff
changeset
|
526 |
$(CC) $(BASECFLAGS) $(CDEFS) endian_check.c -o $@ |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
527 |
|
0 | 528 |
|
529 |
$(TTD): table/strings.h $(ttd_OBJS) $(LANGS) $(MAKE_CONFIG) |
|
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
530 |
@echo 'Compiling and Linking $@'; \ |
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
531 |
$(C_LINK) $@ $(TTDLDFLAGS) $(ttd_OBJS) $(LIBS) $(VERBOSE_FILTER) |
0 | 532 |
|
533 |
$(OSX): |
|
534 |
@mkdir -p $(OSXAPP)/Contents/MacOS |
|
535 |
@mkdir -p $(OSXAPP)/Contents/Resources |
|
536 |
@echo "APPL????" > $(OSXAPP)/Contents/PkgInfo |
|
35 | 537 |
@cp os/macos/ttd.icns $(OSXAPP)/Contents/Resources/openttd.icns |
0 | 538 |
@os/macos/plistgen.sh $(OSXAPP) $(REV) |
539 |
@cp os/macos/track_starter $(OSXAPP)/contents/macos |
|
540 |
@ls os/macos | grep -q "\.class" || \ |
|
541 |
javac os/macos/OpenTTDMidi.java |
|
542 |
@cp os/macos/OpenTTDMidi.class $(OSXAPP)/contents/macos |
|
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
543 |
@cp $(TTD) $(OSXAPP)/Contents/MacOS/$(TTD) |
0 | 544 |
|
545 |
$(endwarnings): $(64_bit_warnings) |
|
546 |
||
547 |
$(64_bit_warnings): |
|
548 |
$(warning 64 bit CPUs will get some 64 bit specific bugs!) |
|
549 |
$(warning If you see any bugs, include in your bug report that you use a 64 bit CPU) |
|
550 |
||
551 |
$(STRGEN): strgen/strgen.c rev.o |
|
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
552 |
@echo 'Compiling and Linking $@'; \ |
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
553 |
$(CC) $(BASECFLAGS) $(CDEFS) -o $@ $^ $(VERBOSE_FILTER) |
0 | 554 |
|
555 |
lang/english.lng: lang/english.txt $(STRGEN) |
|
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
556 |
@echo 'Generating $@'; \ |
0 | 557 |
$(STRGEN) |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
558 |
|
0 | 559 |
table/strings.h: lang/english.lng |
560 |
||
561 |
lang/%.lng: lang/%.txt $(STRGEN) |
|
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
562 |
@echo 'Generating $@'; \ |
180
47ee14fe2b35
(svn r181) Makefile: enabled ability to supress output of missing strings in lng files
bjarni
parents:
164
diff
changeset
|
563 |
$(STRGEN) $(STRGEN_FLAGS) $< $(VERBOSE_FILTER) $(LANG_ERRORS) |
0 | 564 |
|
565 |
winres.o: ttd.rc |
|
566 |
windres -o $@ $< |
|
567 |
||
568 |
||
569 |
rev.c: FORCE |
|
570 |
@# setting the revision number in a place, there the binary can read it |
|
571 |
@echo 'const char _openttd_revision[] = "'$(REV)'";' >>rev.c.new |
|
572 |
@echo 'const int _revision_number = $(REV_NUMBER);' >>rev.c.new |
|
573 |
@# some additions for MorphOS versions tag |
|
574 |
@echo '#ifdef __MORPHOS__' >>rev.c.new |
|
575 |
@echo 'const char morphos_versions_tag[] = "\\0$$VER: OpenTTD '$(REV)' ('${BUILDDATE}') © OpenTTD Team [MorphOS, PowerPC]";' >>rev.c.new |
|
576 |
@echo '#endif' >>rev.c.new |
|
577 |
@# Only update the real rev.c if it actually changed, to prevent |
|
578 |
@# useless rebuilds. |
|
579 |
@cmp -s rev.c rev.c.new 2>/dev/null || mv rev.c.new rev.c |
|
580 |
@rm -f rev.c.new |
|
581 |
||
582 |
FORCE: |
|
583 |
||
584 |
||
32 | 585 |
# ttd$(EXE) is removed just to make sure people execute the right binary (openttd$(EXE)) |
586 |
# remove this for next release! |
|
0 | 587 |
clean: |
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
588 |
@echo 'Cleaning up...'; \ |
163
deb9b58db3f4
(svn r164) -Fix: Makefile did not clean up endian-files
truelight
parents:
162
diff
changeset
|
589 |
rm -rf .deps *~ $(TTD) $(STRGEN) core table/strings.h $(LANGS) $(ttd_OBJS) endian.h $(ENDIAN_CHECK) ttd$(EXE) |
0 | 590 |
|
591 |
mrproper: clean |
|
592 |
rm -rf $(MAKE_CONFIG) |
|
593 |
||
594 |
ifndef OSX |
|
595 |
ifndef MORPHOS |
|
596 |
install: |
|
597 |
@if [ "$(INSTALL)" == "" ]; then $(error make install is highly experimental at his state and not\ |
|
598 |
tested very much - use at your own risk - to use run \"make install INSTALL:=1\" - make sure makefile.config\ |
|
599 |
is set correctly up - run \"make upgradeconf\") |
|
600 |
@if [ "$(DATA_DIR)" == "" ]; then $(error no install path set - check makefile.config) |
|
601 |
mkdir -p $(DATA_DIR)/lang |
|
602 |
mkdir -p $(DATA_DIR)/data |
|
603 |
cp $(TTD) $(BINARY_INSTALL) |
|
604 |
cp lang/*.lng $(DATA_DIR)/lang |
|
605 |
cp data/*.grf $(DATA_DIR)/data |
|
606 |
else #MorphOS |
|
607 |
install: |
|
608 |
$(error make install is not supported on MorphOS) |
|
609 |
endif |
|
610 |
else # OSX |
|
611 |
install: |
|
612 |
$(error make install is not supported on MacOSX) |
|
613 |
endif |
|
614 |
||
615 |
||
616 |
love: |
|
617 |
@echo "YES! I thought you would never ask. We will have a great time. You can keep me turned on all night" |
|
618 |
||
619 |
.PHONY: clean all $(OSX) install $(64_bit_warnings) $(endwarnings) love |
|
620 |
||
621 |
||
622 |
### Automatic configuration |
|
623 |
-include $(CONFIG_WRITER) |
|
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
221
diff
changeset
|
624 |
|
0 | 625 |
|
626 |
# Export all variables set to subprocesses (a bit dirty) |
|
627 |
.EXPORT_ALL_VARIABLES: |
|
628 |
upgradeconf: $(MAKE_CONFIG) |
|
629 |
rm $(MAKE_CONFIG) |
|
630 |
$(MAKE) $(MAKE_CONFIG) |
|
631 |
||
632 |
.PHONY: upgradeconf |
|
633 |
||
634 |
||
635 |
### Internal build rules |
|
636 |
||
637 |
# This makes sure the .deps dir is always around. |
|
638 |
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) |
|
639 |
||
640 |
# Introduce the dependencies |
|
641 |
-include $(ttd_DEPS) |
|
642 |
||
643 |
# This compiles the object file as well as silently updating its dependencies |
|
644 |
# list at the same time. It is not an issue that they aren't around during the |
|
645 |
# first compilation round as we just build everything at that time anyway, |
|
646 |
# therefore we do not need to watch deps. |
|
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
647 |
|
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
648 |
#@echo '$(C_BUILD) $<'; \ |
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
649 |
|
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
650 |
|
0 | 651 |
%.o: %.c $(MAKE_CONFIG) |
162
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
652 |
@echo 'Compiling $(*F).o'; \ |
565551f829e9
(svn r163) Makefile: made compileroutput nicer and added NOVERBOSE to supress all warnings/errors if wanted(default off) (sign_de)
bjarni
parents:
157
diff
changeset
|
653 |
$(C_BUILD) $< -Wp,-MD,.deps/$(*F).pp $(VERBOSE_FILTER) |
0 | 654 |
@-cp .deps/$(*F).pp .deps/$(*F).P; \ |
655 |
tr ' ' '\012' < .deps/$(*F).pp \ |
|
656 |
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ |
|
657 |
>> .deps/$(*F).P; \ |
|
658 |
rm .deps/$(*F).pp |
|
659 |
||
660 |
# For DirectMusic build |
|
661 |
%.o: %.cpp $(MAKE_CONFIG) |
|
662 |
$(CXX_BUILD) $< |