author | bjarni |
Mon, 06 Sep 2004 16:45:53 +0000 | |
changeset 162 | 565551f829e9 |
parent 157 | dd017fa3bad8 |
child 163 | deb9b58db3f4 |
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 |
|
62 |
# MIDI: if set, it will use it as custom path to midi player. |
|
63 |
# If unset, it will use the hardcoded path in the c code |
|
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
|
64 |
# NOVERBOSE: supress all warnings and errors during compilation. |
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 |
# |
67 |
# DATA_DIR_PREFIX: This sets the dir OpenTTD looks for the needed files. |
|
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 |
||
84 |
# CONFIG_WRITER have to be found even for manual configuration |
|
85 |
CONFIG_WRITER=makefiledir/Makefile.config_writer |
|
86 |
||
87 |
ifndef MANUAL_CONFIG |
|
88 |
# Automatic configuration |
|
89 |
MAKE_CONFIG:=Makefile.config |
|
90 |
MAKEFILE:=Makefile |
|
91 |
LIB_DETECTION=makefiledir/Makefile.libdetection |
|
92 |
CONFIG_WRITER=makefiledir/Makefile.config_writer |
|
93 |
||
94 |
# Apply automatic configuration |
|
95 |
# See target section for how this is built, suppress errors |
|
96 |
# since first time it isn't found but make reads this twice |
|
97 |
-include $(MAKE_CONFIG) |
|
98 |
else |
|
99 |
CONFIG_INCLUDED:=1 |
|
100 |
endif |
|
101 |
||
102 |
# tests if makefile.config contains the new needed SDL-CONFIG |
|
103 |
# it updates makefile.config if needed. Flags like ENABLE_NETWORK are remembered |
|
104 |
ifndef SDL-CONFIG |
|
105 |
ifdef WITH_SDL |
|
106 |
ifndef MANUAL_CONFIG |
|
107 |
#network is enabled by default |
|
108 |
ENABLE_NETWORK:=1 |
|
109 |
UPDATECONFIG:=upgradeconf |
|
110 |
CONFIG_INCLUDED:= |
|
111 |
else |
|
112 |
# this should define SDL-CONFIG for manual configuration |
|
113 |
ifeq ($(shell uname),FreeBSD) |
|
114 |
SDL-CONFIG:=sdl11-config |
|
115 |
else |
|
116 |
SDL-CONFIG:=sdl-config |
|
117 |
endif |
|
118 |
endif |
|
119 |
endif |
|
120 |
endif |
|
121 |
||
122 |
ifndef CONFIG_INCLUDED |
|
123 |
-include $(LIB_DETECTION) |
|
124 |
endif |
|
125 |
||
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
|
126 |
# 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
|
127 |
|
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
|
128 |
ifdef NOVERBOSE |
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
|
129 |
VERBOSE_FILTER = >/dev/null 2>&1 |
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
|
130 |
else |
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
|
131 |
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
|
132 |
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
|
133 |
|
0 | 134 |
ifdef DISPLAY_WARNINGS |
135 |
WARNING_DISPLAY:=-fstrict-aliasing |
|
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
|
136 |
VERBOSE_FILTER = |
0 | 137 |
else |
138 |
WARNING_DISPLAY:=-fno-strict-aliasing |
|
139 |
endif |
|
140 |
||
141 |
ifdef STATIC |
|
142 |
ifndef WIN32 |
|
143 |
ifndef OSX |
|
144 |
ifndef MORPHOS |
|
145 |
ifndef SKIP_STATIC_CHECK |
|
146 |
$(error Static is only known to work on MorphOS and MacOSX!!! --- Check makefile.config for more info and howto bypass this check) |
|
147 |
endif |
|
148 |
endif |
|
149 |
endif |
|
150 |
endif |
|
151 |
endif |
|
152 |
||
153 |
||
154 |
# Force SDL on UNIX platforms |
|
155 |
ifndef WITH_SDL |
|
156 |
ifdef UNIX |
|
157 |
$(error You need to have SDL installed in order to run OpenTTD on UNIX.) |
|
158 |
endif |
|
159 |
endif |
|
160 |
||
161 |
||
162 |
||
163 |
############################################################################## |
|
164 |
# |
|
165 |
# Compiler configuration |
|
166 |
# |
|
167 |
CC=gcc |
|
168 |
CXX=g++ |
|
169 |
||
170 |
ifdef MORPHOS |
|
171 |
CC += -noixemul -pipe |
|
172 |
CXX += -noixemul -pipe |
|
173 |
endif |
|
174 |
||
175 |
# Executable file extension |
|
176 |
ifdef WIN32 |
|
177 |
EXE=.exe |
|
178 |
else |
|
179 |
EXE= |
|
180 |
endif |
|
181 |
||
182 |
# Set output executable names |
|
32 | 183 |
TTD=openttd$(EXE) |
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
184 |
ENDIAN_CHECK=endian_check$(EXE) |
0 | 185 |
STRGEN=strgen/strgen$(EXE) |
186 |
OSXAPP="OpenTTD.app" |
|
187 |
||
188 |
# What revision are we compiling, if we have an idea? |
|
189 |
REV_NUMBER := $(shell if test -d .svn; then svnversion . | tr -dc 0-9; fi) |
|
190 |
||
191 |
ifdef RELEASE |
|
192 |
REV:=$(RELEASE) |
|
193 |
else |
|
194 |
REV := $(shell if test -d .svn; then echo -n r; svnversion .; fi) |
|
195 |
tmp_test:=$(shell echo "$(REV)" | grep "M" ) |
|
196 |
ifdef tmp_test |
|
197 |
REV_NUMBER:=1 |
|
198 |
endif |
|
199 |
endif |
|
200 |
||
201 |
ifndef REV_NUMBER |
|
202 |
REV_NUMBER:=0 |
|
203 |
endif |
|
204 |
||
205 |
# MorphOS needs builddate |
|
206 |
BUILDDATE=`date +%d.%m.%y` |
|
207 |
||
208 |
# AMD64 needs a little more settings to work |
|
209 |
ifeq ($(shell uname -m), x86_64) |
|
210 |
endwarnings:=endwarnings |
|
211 |
64_bit_warnings:=64_bit_warnings |
|
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
212 |
BASECFLAGS += -m64 |
0 | 213 |
endif |
214 |
||
215 |
||
216 |
# When calling the compiler, use these flags |
|
217 |
# -g debugging symbols |
|
218 |
# -Wall all warnings |
|
219 |
# -s automatic strip |
|
220 |
# |
|
221 |
# You may also want: |
|
222 |
# -O optimize or -O2 fully optimize (O's above 2 are not recommended) |
|
223 |
# -pg profile - generate profiling data. See "man gprof" to use this. |
|
224 |
||
225 |
CFLAGS=-Wall -Wno-multichar |
|
226 |
CDEFS=-DWITH_REV |
|
227 |
LDFLAGS= |
|
228 |
LIBS= |
|
229 |
||
230 |
ifdef DEBUG |
|
231 |
# Debug mode |
|
232 |
CDEFS += -D_DEBUG |
|
233 |
BASECFLAGS += -g |
|
234 |
else |
|
235 |
ifdef PROFILE |
|
236 |
BASECFLAGS += -pg |
|
237 |
else |
|
238 |
# Release mode |
|
239 |
ifndef MORPHOS |
|
240 |
# automatical strip breaks under morphos |
|
241 |
BASECFLAGS += -s |
|
242 |
LDFLAGS += -s |
|
243 |
endif |
|
244 |
endif |
|
245 |
||
246 |
ifdef OSX |
|
247 |
# these compilerflags makes the app run as fast as possible without making the app unstable. It works on G3 or newer |
|
248 |
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) |
|
249 |
else |
|
250 |
ifdef MORPHOS |
|
251 |
BASECFLAGS += -O2 -funroll-loops -fexpensive-optimizations -mstring -mmultiple $(WARNING_DISPLAY) |
|
252 |
else |
|
253 |
BASECFLAGS += -O2 $(WARNING_DISPLAY) |
|
254 |
endif |
|
255 |
ifndef PROFILE |
|
256 |
BASECFLAGS += -fomit-frame-pointer |
|
257 |
endif |
|
258 |
endif |
|
259 |
endif |
|
260 |
||
261 |
ifdef STATIC |
|
262 |
ifndef OSX # OSX can't build static if -static flag is used |
|
263 |
LDFLAGS += -static |
|
264 |
endif |
|
265 |
endif |
|
266 |
||
267 |
# If building on Cygwin/MingW don't link with Cygwin libs |
|
268 |
ifdef WIN32 |
|
269 |
ifdef MINGW |
|
270 |
ifdef CYGWIN |
|
271 |
BASECFLAGS += -mno-cygwin |
|
272 |
LDFLAGS += -mno-cygwin |
|
273 |
endif |
|
274 |
endif |
|
275 |
endif |
|
276 |
||
277 |
CFLAGS += $(BASECFLAGS) |
|
278 |
||
279 |
ifdef UNIX |
|
280 |
CDEFS += -DUNIX |
|
281 |
endif |
|
282 |
||
283 |
# SDL config |
|
284 |
ifdef WITH_SDL |
|
285 |
CDEFS += -DWITH_SDL |
|
286 |
CFLAGS += `$(SDL-CONFIG) --cflags` |
|
287 |
ifdef STATIC |
|
288 |
LIBS += `$(SDL-CONFIG) --static-libs` |
|
289 |
else |
|
290 |
LIBS += `$(SDL-CONFIG) --libs` |
|
291 |
endif |
|
292 |
endif |
|
293 |
||
294 |
||
295 |
# zlib config |
|
296 |
ifdef WITH_ZLIB |
|
297 |
CDEFS += -DWITH_ZLIB |
|
298 |
ifdef STATIC |
|
299 |
ifdef OSX |
|
300 |
# zlib is default on OSX, so everybody have it. No need for static linking |
|
301 |
LIBS += -lz |
|
302 |
else |
|
303 |
ifndef STATIC_ZLIB_PATH |
|
304 |
ifndef MANUAL_CONFIG |
|
305 |
# updates makefile.config with the zlib path |
|
306 |
UPDATECONFIG:=upgradeconf |
|
307 |
endif |
|
308 |
TEMP:=$(shell ls /lib 2>/dev/null | grep "zlib.a")$(shell ls /lib 2>/dev/null | grep "libz.a") |
|
309 |
ifdef TEMP |
|
310 |
STATIC_ZLIB_PATH:=/lib/$(TEMP) |
|
311 |
else |
|
312 |
TEMP:=$(shell ls /usr/lib 2>/dev/null | grep "zlib.a")$(shell ls /usr/lib 2>/dev/null | grep "libz.a") |
|
313 |
ifdef TEMP |
|
314 |
STATIC_ZLIB_PATH:=/usr/lib/$(TEMP) |
|
315 |
else |
|
316 |
TEMP:=$(shell ls /usr/local/lib 2>/dev/null | grep "zlib.a")$(shell ls /usr/local/lib 2>/dev/null | grep "libz.a") |
|
317 |
ifdef TEMP |
|
318 |
STATIC_ZLIB_PATH:=/usr/local/lib/$(TEMP) |
|
319 |
endif |
|
320 |
endif |
|
321 |
endif |
|
322 |
endif |
|
323 |
LIBS += $(STATIC_ZLIB_PATH) |
|
324 |
endif |
|
325 |
else |
|
326 |
LIBS += -lz |
|
327 |
endif |
|
328 |
endif |
|
329 |
||
330 |
# libpng config |
|
331 |
ifdef WITH_PNG |
|
332 |
CDEFS += -DWITH_PNG |
|
333 |
# FreeBSD doesn't use libpng-config |
|
334 |
ifdef FREEBSD |
|
335 |
LIBS += -lpng |
|
336 |
else |
|
337 |
CFLAGS += `libpng-config --cflags` |
|
338 |
ifdef OSX |
|
339 |
ifdef STATIC |
|
340 |
# Seems like we need a tiny hack for OSX static to work |
|
341 |
LIBS += `libpng-config --prefix`/lib/libpng.a |
|
342 |
else |
|
343 |
LIBS += `libpng-config --libs` |
|
344 |
endif |
|
345 |
else |
|
346 |
# seems like older libpng versions are broken and need this |
|
347 |
PNGCONFIG_FLAGS = --ldflags --libs |
|
348 |
ifdef STATIC |
|
349 |
LIBS += `libpng-config --static $(PNGCONFIG_FLAGS)` |
|
350 |
else |
|
351 |
LIBS += `libpng-config $(PNGCONFIG_FLAGS)` |
|
352 |
endif |
|
353 |
endif |
|
354 |
endif |
|
355 |
endif |
|
356 |
||
357 |
||
358 |
ifdef TRANSLATOR |
|
359 |
STRGEN_FLAGS=-t |
|
360 |
else |
|
361 |
STRGEN_FLAGS= |
|
362 |
endif |
|
363 |
||
364 |
# file paths setup |
|
365 |
ifdef GAME_DATA_DIR |
|
366 |
CDEFS += -DGAME_DATA_DIR=\"$(GAME_DATA_DIR)\" |
|
367 |
endif |
|
368 |
||
369 |
ifdef PERSONAL_DIR |
|
370 |
CDEFS += -DPERSONAL_DIR=\"$(PERSONAL_DIR)\" |
|
371 |
endif |
|
372 |
||
373 |
ifdef USE_HOMEDIR |
|
374 |
CDEFS += -DUSE_HOMEDIR |
|
375 |
endif |
|
376 |
||
377 |
# MIDI setup |
|
378 |
ifdef OSX |
|
379 |
ifndef MIDI |
|
380 |
MIDI:=$(OSXAPP)/contents/macos/track_starter |
|
381 |
endif |
|
382 |
endif |
|
383 |
||
384 |
ifdef MIDI |
|
385 |
CDEFS += -DEXTERNAL_PLAYER=\"$(MIDI)\" |
|
386 |
ifdef MIDI_ARG |
|
387 |
CDEFS += -DMIDI_ARG=\"$(MIDI_ARG)\" |
|
388 |
endif |
|
389 |
endif |
|
390 |
||
391 |
# Experimental |
|
392 |
ifdef WITH_NETWORK |
|
393 |
CDEFS += -DENABLE_NETWORK |
|
394 |
ifdef UNIX |
|
395 |
ifndef OSX |
|
396 |
ifndef MORPHOS |
|
397 |
# this have caused problems on many platforms and disabling it didn't break anything |
|
398 |
# now we test if disabling it as a general breaks it for anybody |
|
399 |
#LIBS += -lresolv |
|
400 |
endif |
|
401 |
endif |
|
402 |
endif |
|
403 |
endif |
|
404 |
||
405 |
ifdef WITH_DIRECTMUSIC |
|
406 |
CDEFS += -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT |
|
407 |
endif |
|
408 |
||
409 |
ifdef WIN32 |
|
410 |
LIBS += -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32 -lstdc++ |
|
411 |
TTDLDFLAGS += -Wl,--subsystem,windows |
|
412 |
endif |
|
413 |
||
414 |
# sets up the paths for use for make install |
|
415 |
ifdef BINARY_DIR |
|
416 |
BINARY_INSTALL:=$(BINARY_DIR)$(TTD) |
|
417 |
else |
|
418 |
BINARY_INSTALL:=$(INSTALL_DIR)$(TTD) |
|
419 |
endif |
|
420 |
ifdef DATA_DIR_PREFIX |
|
421 |
DATA_DIR:=$(DATA_DIR_PREFIX) |
|
422 |
else |
|
423 |
DATA_DIR:=$(INSTALL_DIR) |
|
424 |
endif |
|
425 |
||
426 |
############################################################################## |
|
427 |
# |
|
428 |
# What to compile |
|
429 |
# (users do not want to modify anything below) |
|
430 |
# |
|
431 |
||
432 |
||
433 |
### Sources |
|
434 |
||
435 |
ttd_SOURCES = \ |
|
112
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
436 |
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
|
437 |
aircraft_gui.c airport.c airport_gui.c aystar.c bridge_gui.c \ |
126 | 438 |
clear_cmd.c command.c console.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
|
439 |
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
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
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
|
444 |
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
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
town_gui.c train_cmd.c train_gui.c tree_cmd.c ttd.c tunnelbridge_cmd.c \ |
5291485847ff
(svn r113) -Update: re-ordered Makefile (filenames are now in alphabetic order again) (Celestar)
truelight
parents:
84
diff
changeset
|
449 |
unmovable_cmd.c vehicle.c viewport.c water_cmd.c widget.c window.c \ |
0 | 450 |
|
451 |
ifdef WITH_SDL |
|
452 |
ttd_SOURCES += sdl.c |
|
453 |
endif |
|
454 |
||
455 |
ifdef WIN32 |
|
456 |
ttd_SOURCES += win32.c w32dm.c |
|
457 |
else |
|
458 |
ttd_SOURCES += extmidi.c unix.c |
|
459 |
endif |
|
460 |
||
461 |
ttd_OBJS = $(ttd_SOURCES:%.c=%.o) |
|
462 |
||
463 |
ifdef WIN32 |
|
464 |
# Resource file |
|
465 |
ttd_OBJS += winres.o |
|
466 |
endif |
|
467 |
||
468 |
ifdef WITH_DIRECTMUSIC |
|
469 |
ttd_SOURCES += w32dm2.cpp |
|
470 |
ttd_OBJS += w32dm2.o |
|
471 |
endif |
|
472 |
||
473 |
ttd_DEPS1 = $(foreach obj,$(ttd_OBJS),.deps/$(obj)) |
|
474 |
ttd_DEPS = $(ttd_DEPS1:%.o=%.P) |
|
475 |
||
476 |
LANG_TXT = $(filter-out %.unfinished.txt,$(wildcard lang/*.txt)) |
|
477 |
LANGS = $(LANG_TXT:%.txt=%.lng) |
|
478 |
||
479 |
C_COMPILE = $(CC) $(CFLAGS) $(CDEFS) |
|
480 |
CXX_COMPILE = $(CXX) $(CFLAGS) $(CDEFS) |
|
481 |
||
482 |
C_BUILD = $(C_COMPILE) -c |
|
483 |
CXX_BUILD = $(CXX_COMPILE) -c |
|
484 |
||
485 |
C_LINK = $(CC) $(LDFLAGS) -o |
|
486 |
||
487 |
||
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
|
488 |
|
0 | 489 |
############################################################################## |
490 |
# |
|
491 |
# Targets |
|
492 |
# |
|
493 |
||
494 |
||
495 |
### Normal build rules |
|
496 |
||
497 |
||
498 |
ifdef OSX |
|
499 |
OSX:=OSX |
|
500 |
endif |
|
501 |
||
502 |
||
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
503 |
all: endian.h $(UPDATECONFIG) $(TTD) $(OSX) $(endwarnings) |
0 | 504 |
|
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
505 |
endian.h: $(ENDIAN_CHECK) |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
506 |
# Check if system is LITTLE_ENDIAN or BIG_ENDIAN |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
507 |
./$(ENDIAN_CHECK) > $@ |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
508 |
|
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
509 |
$(ENDIAN_CHECK): endian_check.c |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
510 |
$(CC) $(BASECFLAGS) $(CDEFS) endian_check.c -o $@ |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
126
diff
changeset
|
511 |
|
0 | 512 |
|
513 |
$(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
|
514 |
@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
|
515 |
$(C_LINK) $@ $(TTDLDFLAGS) $(ttd_OBJS) $(LIBS) $(VERBOSE_FILTER) |
0 | 516 |
|
517 |
$(OSX): |
|
518 |
@mkdir -p $(OSXAPP)/Contents/MacOS |
|
519 |
@mkdir -p $(OSXAPP)/Contents/Resources |
|
520 |
@echo "APPL????" > $(OSXAPP)/Contents/PkgInfo |
|
35 | 521 |
@cp os/macos/ttd.icns $(OSXAPP)/Contents/Resources/openttd.icns |
0 | 522 |
@os/macos/plistgen.sh $(OSXAPP) $(REV) |
523 |
@cp os/macos/track_starter $(OSXAPP)/contents/macos |
|
524 |
@ls os/macos | grep -q "\.class" || \ |
|
525 |
javac os/macos/OpenTTDMidi.java |
|
526 |
@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
|
527 |
@cp $(TTD) $(OSXAPP)/Contents/MacOS/$(TTD) |
0 | 528 |
|
529 |
$(endwarnings): $(64_bit_warnings) |
|
530 |
||
531 |
$(64_bit_warnings): |
|
532 |
$(warning 64 bit CPUs will get some 64 bit specific bugs!) |
|
533 |
$(warning If you see any bugs, include in your bug report that you use a 64 bit CPU) |
|
534 |
||
535 |
$(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
|
536 |
@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
|
537 |
$(CC) $(BASECFLAGS) $(CDEFS) -o $@ $^ $(VERBOSE_FILTER) |
0 | 538 |
|
539 |
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
|
540 |
@echo 'Generating $@'; \ |
0 | 541 |
$(STRGEN) |
542 |
||
543 |
table/strings.h: lang/english.lng |
|
544 |
||
545 |
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
|
546 |
@echo 'Generating $@'; \ |
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
|
547 |
$(STRGEN) $(STRGEN_FLAGS) $< $(VERBOSE_FILTER) |
0 | 548 |
|
549 |
winres.o: ttd.rc |
|
550 |
windres -o $@ $< |
|
551 |
||
552 |
||
553 |
rev.c: FORCE |
|
554 |
@# setting the revision number in a place, there the binary can read it |
|
555 |
@echo 'const char _openttd_revision[] = "'$(REV)'";' >>rev.c.new |
|
556 |
@echo 'const int _revision_number = $(REV_NUMBER);' >>rev.c.new |
|
557 |
@# some additions for MorphOS versions tag |
|
558 |
@echo '#ifdef __MORPHOS__' >>rev.c.new |
|
559 |
@echo 'const char morphos_versions_tag[] = "\\0$$VER: OpenTTD '$(REV)' ('${BUILDDATE}') © OpenTTD Team [MorphOS, PowerPC]";' >>rev.c.new |
|
560 |
@echo '#endif' >>rev.c.new |
|
561 |
@# Only update the real rev.c if it actually changed, to prevent |
|
562 |
@# useless rebuilds. |
|
563 |
@cmp -s rev.c rev.c.new 2>/dev/null || mv rev.c.new rev.c |
|
564 |
@rm -f rev.c.new |
|
565 |
||
566 |
FORCE: |
|
567 |
||
568 |
||
32 | 569 |
# ttd$(EXE) is removed just to make sure people execute the right binary (openttd$(EXE)) |
570 |
# remove this for next release! |
|
0 | 571 |
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
|
572 |
@echo 'Cleaning up...'; \ |
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
|
573 |
rm -rf .deps *~ $(TTD) $(STRGEN) core table/strings.h $(LANGS) $(ttd_OBJS) ttd$(EXE) |
0 | 574 |
|
575 |
mrproper: clean |
|
576 |
rm -rf $(MAKE_CONFIG) |
|
577 |
||
578 |
ifndef OSX |
|
579 |
ifndef MORPHOS |
|
580 |
install: |
|
581 |
@if [ "$(INSTALL)" == "" ]; then $(error make install is highly experimental at his state and not\ |
|
582 |
tested very much - use at your own risk - to use run \"make install INSTALL:=1\" - make sure makefile.config\ |
|
583 |
is set correctly up - run \"make upgradeconf\") |
|
584 |
@if [ "$(DATA_DIR)" == "" ]; then $(error no install path set - check makefile.config) |
|
585 |
mkdir -p $(DATA_DIR)/lang |
|
586 |
mkdir -p $(DATA_DIR)/data |
|
587 |
cp $(TTD) $(BINARY_INSTALL) |
|
588 |
cp lang/*.lng $(DATA_DIR)/lang |
|
589 |
cp data/*.grf $(DATA_DIR)/data |
|
590 |
else #MorphOS |
|
591 |
install: |
|
592 |
$(error make install is not supported on MorphOS) |
|
593 |
endif |
|
594 |
else # OSX |
|
595 |
install: |
|
596 |
$(error make install is not supported on MacOSX) |
|
597 |
endif |
|
598 |
||
599 |
||
600 |
love: |
|
601 |
@echo "YES! I thought you would never ask. We will have a great time. You can keep me turned on all night" |
|
602 |
||
603 |
.PHONY: clean all $(OSX) install $(64_bit_warnings) $(endwarnings) love |
|
604 |
||
605 |
||
606 |
### Automatic configuration |
|
607 |
-include $(CONFIG_WRITER) |
|
608 |
||
609 |
||
610 |
# Export all variables set to subprocesses (a bit dirty) |
|
611 |
.EXPORT_ALL_VARIABLES: |
|
612 |
upgradeconf: $(MAKE_CONFIG) |
|
613 |
rm $(MAKE_CONFIG) |
|
614 |
$(MAKE) $(MAKE_CONFIG) |
|
615 |
||
616 |
.PHONY: upgradeconf |
|
617 |
||
618 |
||
619 |
### Internal build rules |
|
620 |
||
621 |
# This makes sure the .deps dir is always around. |
|
622 |
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) |
|
623 |
||
624 |
# Introduce the dependencies |
|
625 |
-include $(ttd_DEPS) |
|
626 |
||
627 |
# This compiles the object file as well as silently updating its dependencies |
|
628 |
# list at the same time. It is not an issue that they aren't around during the |
|
629 |
# first compilation round as we just build everything at that time anyway, |
|
630 |
# 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
|
631 |
|
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
|
632 |
#@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
|
633 |
|
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
|
634 |
|
0 | 635 |
%.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
|
636 |
@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
|
637 |
$(C_BUILD) $< -Wp,-MD,.deps/$(*F).pp $(VERBOSE_FILTER) |
0 | 638 |
@-cp .deps/$(*F).pp .deps/$(*F).P; \ |
639 |
tr ' ' '\012' < .deps/$(*F).pp \ |
|
640 |
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ |
|
641 |
>> .deps/$(*F).P; \ |
|
642 |
rm .deps/$(*F).pp |
|
643 |
||
644 |
# For DirectMusic build |
|
645 |
%.o: %.cpp $(MAKE_CONFIG) |
|
646 |
$(CXX_BUILD) $< |