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