truelight@0: # This Makefile is partially based on "a completely generic Makefile", truelight@0: # originally created by Justin Husted truelight@0: # truelight@0: # Rewrite and sane dependencies support by Petr Baudis truelight@0: # Cygwin support and configuration by Jaen Saul truelight@0: # A lot of modifications by Bjarni Corfitzen truelight@0: # truelight@0: # Last modified by: $Author: strigeus $ truelight@0: # On: $Date: 2004/03/11 19:15:06 $ truelight@0: truelight@0: truelight@0: ############################################################################## truelight@0: # truelight@0: # Usage truelight@0: # truelight@0: truelight@0: # Synopsis: truelight@0: # truelight@0: # make WITH_ZLIB=1 UNIX=1 MANUAL_CONFIG=1 truelight@0: # truelight@0: # (See below for the list of possible options.) truelight@0: # truelight@0: # Alternately, you can run make without the MANUAL_CONFIG part. It then truelight@0: # generates Makefile.config, where you can customize all the options. truelight@0: # However beware that for all subsequent calls the option values from truelight@0: # Makefile.config take precedence to the commandline options. truelight@0: # truelight@0: # (That means that you probably want to either specify the options on command truelight@0: # line together with MANUAL_CONFIG=1 or you want to specify no commandline truelight@0: # options at all.) truelight@0: truelight@0: # Targets: truelight@0: # truelight@0: # Defaults to building binary truelight@0: # clean: remove intermediate build files truelight@0: # mrproper: remove intermediate files and makefile configuration truelight@0: # upgradeconf: add new options to old Makefile.config truelight@0: # osx: OS X application bjarni@563: # release: used by OSX to make a dmg file ready to release truelight@0: truelight@0: # Options: truelight@0: # truelight@0: # Summary of OS choice defines truelight@0: # WIN32: building on Windows truelight@0: # UNIX: building on *nix derivate (Linux, FreeBSD) truelight@0: # OSX: building on Mac OS X truelight@0: # MORPHOS: building on MorphOS tron@421: # BEOS: building on BeOS tron@446: # SUNOS: building on SunOS (Solaris) truelight@0: # truelight@0: # Summary of library choice defines truelight@0: # WITH_ZLIB: savegames using zlib truelight@0: # WITH_PNG: screenshots using PNG truelight@0: # WITH_SDL: SDL video driver support truelight@0: # truelight@0: # Summary of other defines: truelight@0: # MANUAL_CONFIG: do not use Makefile.config, config options set manually truelight@0: # DEBUG: build in debug mode truelight@0: # PROFILE: build in profile mode, disables -s and -fomit-frame-pointer truelight@0: # DISPLAY_WARNINGS: when off, some errors are not displayed while compiling truelight@0: # TRANSLATOR: build in translator mode (untranslated strings are prepended by truelight@0: # a mark) truelight@0: # RELEASE: this will be the released version number. It replaces all places truelight@0: # where it normally would print the revision number darkvater@222: # MIDI: if set, it will use it as custom path to midi player. truelight@0: # If unset, it will use the hardcoded path in the c code darkvater@222: # NOVERBOSE: supress all warnings and errors during compilation. bjarni@162: # It looks nicer, but you will not know what went wrong. Use it on released (stable) sources only pasky@462: # VERBOSE: actually show the commands used for compilation. truelight@0: # bjarni@285: # Paths: bjarni@285: # INSTALL: If not set, the game uses the directory of the binary to truelight@543: # store everything (lang, data, gm, save and openttd.cfg), this is the `old' behaviour. bjarni@285: # In this case, none of the following paths are used, you also should _not_ bjarni@285: # use `make install', but copy the required stuff yourself (or just play out bjarni@285: # of you source directory, which should work fine). bjarni@285: # If you want to use `make install' to install the game globally, you should bjarni@285: # define it _before_ you build the game. If you only define INSTALL when you bjarni@285: # do `make install', the game won't be able to find it's files (so you should bjarni@285: # also define all the following paths before building). bjarni@285: # bjarni@285: # So, the following paths should be defined if INSTALL is defined. bjarni@285: # None of these paths have to end with / bjarni@285: # PREFIX: Normally /usr/local bjarni@285: # BINARY_DIR: The location of the binary, normally games. (Will be prefixed bjarni@285: # with $PREFIX) truelight@543: # DATA_DIR: The location of the data (lang, data and gm), normally bjarni@285: # share/games/openttd. (Will be prefixed with $PREFIX) bjarni@285: # PERSONAL_DIR: The directory where openttd.cfg and the save folder will be bjarni@285: # stored. You cannot use ~ here, define USE_HOMEDIR for that. bjarni@285: # USE_HOMEDIR: If this variable is set, PERSONAL_DIR will be prefixed with bjarni@285: # ~/ at runtime (the user's homedir) bjarni@561: # SECOND_DATA_PATH Use this data dir if a file is not found in the data dir in the data path bjarni@561: # CUSTOM_LANG_PATH If this is set, it will use the path given to search for lng files bjarni@561: # instead of the lang dir in the data path bjarni@561: # NOTE: both SECOND_DATA_PATH and CUSTOM_LANG_PATH uses paths relative to where OTTD is opened bjarni@285: # bjarni@285: # DEST_DIR: make install will use this directory instead of the filesystem bjarni@285: # root to install its files. This should normally not be used by bjarni@285: # ordinary users, currently it is only used for the debian bjarni@285: # packaging. This value should only be set when calling `make bjarni@285: # install' and is not saved in Makefile.config truelight@0: # truelight@0: # STATIC: link statically truelight@0: # CYGWIN: build in Cygwin environment truelight@0: # MINGW: build with MingW compiler, link with MingW libraries truelight@0: # truelight@0: # Experimental (does not work properly): truelight@0: # WITH_NETWORK: enable networking truelight@0: # WITH_DIRECTMUSIC: enable DirectMusic MIDI support bjarni@549: # DEDICATED: allows compilation on UNIX without SDL. Useful for dedicated servers truelight@0: truelight@0: truelight@0: ############################################################################## truelight@0: # truelight@0: # Configuration truelight@0: # truelight@0: bjarni@180: # Makefile version tag bjarni@180: # it checks if the version tag in makefile.config is the same and force update outdated config files bjarni@561: MAKEFILE_VERSION:=5 bjarni@180: truelight@0: # CONFIG_WRITER have to be found even for manual configuration truelight@0: CONFIG_WRITER=makefiledir/Makefile.config_writer truelight@0: truelight@0: ifndef MANUAL_CONFIG truelight@0: # Automatic configuration truelight@0: MAKE_CONFIG:=Makefile.config truelight@0: MAKEFILE:=Makefile truelight@0: LIB_DETECTION=makefiledir/Makefile.libdetection truelight@0: CONFIG_WRITER=makefiledir/Makefile.config_writer truelight@0: truelight@0: # Apply automatic configuration truelight@0: # See target section for how this is built, suppress errors truelight@0: # since first time it isn't found but make reads this twice truelight@0: -include $(MAKE_CONFIG) truelight@0: else truelight@0: CONFIG_INCLUDED:=1 truelight@0: endif truelight@0: bjarni@180: # updates makefile.config if it's outdated bjarni@180: ifneq ($(MAKEFILE_VERSION),$(CONFIG_VERSION)) bjarni@189: ifndef MANUAL_CONFIG # manual config should not check this bjarni@189: UPDATECONFIG:=upgradeconf bjarni@189: CONFIG_INCLUDED:= bjarni@189: else bjarni@189: # this should define SDL-CONFIG for manual configuration bjarni@189: ifeq ($(shell uname),FreeBSD) bjarni@189: SDL-CONFIG:=sdl11-config bjarni@189: else bjarni@189: SDL-CONFIG:=sdl-config bjarni@189: endif bjarni@189: endif truelight@0: else bjarni@189: # this should define SDL-CONFIG for manual configuration bjarni@189: ifeq ($(shell uname),FreeBSD) bjarni@189: SDL-CONFIG:=sdl11-config bjarni@189: else bjarni@189: SDL-CONFIG:=sdl-config bjarni@189: endif truelight@0: endif truelight@0: bjarni@219: # this is used if there aren't any makefile.config truelight@0: ifndef CONFIG_INCLUDED bjarni@285: # sets network on by default if there aren't any config file truelight@543: ENABLE_NETWORK:=1 bjarni@285: bjarni@285: # paths for make install bjarni@285: # disabled as they would break it for some (many?) people if they were default bjarni@285: #PREFIX:=/usr/local bjarni@285: #DATA_DIR:=share/games/openttd bjarni@285: #BINARY_DIR:=games bjarni@285: #PERSONAL_DIR:=.openttd bjarni@285: #USE_HOMEDIR:=1 bjarni@285: truelight@0: -include $(LIB_DETECTION) truelight@0: endif truelight@0: bjarni@162: # Verbose filter bjarni@162: bjarni@162: ifdef NOVERBOSE darkvater@222: VERBOSE_FILTER = >/dev/null 2>&1 bjarni@162: else darkvater@222: VERBOSE_FILTER = bjarni@162: endif bjarni@162: truelight@0: ifdef DISPLAY_WARNINGS truelight@0: WARNING_DISPLAY:=-fstrict-aliasing darkvater@222: VERBOSE_FILTER = truelight@0: else truelight@0: WARNING_DISPLAY:=-fno-strict-aliasing truelight@0: endif truelight@0: bjarni@180: ifdef SUPRESS_LANG_ERRORS bjarni@180: ifndef VERBOSE_FILTER bjarni@180: LANG_ERRORS = >/dev/null 2>&1 bjarni@180: endif bjarni@180: endif bjarni@180: truelight@0: ifdef STATIC truelight@0: ifndef WIN32 truelight@0: ifndef OSX truelight@0: ifndef MORPHOS truelight@0: ifndef SKIP_STATIC_CHECK truelight@0: $(error Static is only known to work on MorphOS and MacOSX!!! --- Check makefile.config for more info and howto bypass this check) truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: bjarni@580: ifdef RELEASE bjarni@580: ifdef OSX bjarni@580: ifndef STATIC bjarni@580: $(error do not make dynamically linked releases. Most users can't use those) bjarni@580: endif bjarni@580: endif bjarni@580: endif truelight@0: truelight@0: # Force SDL on UNIX platforms truelight@0: ifndef WITH_SDL truelight@0: ifdef UNIX bjarni@549: ifndef DEDICATED bjarni@549: $(error You need to have SDL installed in order to run OpenTTD on UNIX. Use DEDICATED if you want to compile a CLI based server) truelight@0: endif truelight@0: endif bjarni@549: endif bjarni@549: truelight@0: truelight@0: truelight@0: ############################################################################## truelight@0: # truelight@0: # Compiler configuration truelight@0: # truelight@0: CC=gcc truelight@0: CXX=g++ truelight@0: truelight@0: ifdef MORPHOS truelight@0: CC += -noixemul -pipe truelight@0: CXX += -noixemul -pipe truelight@0: endif truelight@0: truelight@0: # Executable file extension truelight@0: ifdef WIN32 truelight@0: EXE=.exe truelight@0: else truelight@0: EXE= truelight@0: endif truelight@0: truelight@0: # Set output executable names darkvater@32: TTD=openttd$(EXE) truelight@157: ENDIAN_CHECK=endian_check$(EXE) truelight@0: STRGEN=strgen/strgen$(EXE) truelight@0: OSXAPP="OpenTTD.app" truelight@0: truelight@0: # What revision are we compiling, if we have an idea? truelight@0: REV_NUMBER := $(shell if test -d .svn; then svnversion . | tr -dc 0-9; fi) truelight@0: truelight@0: ifdef RELEASE truelight@0: REV:=$(RELEASE) truelight@0: else tron@450: REV := $(shell if test -d .svn; then svnversion . | awk '{ print "r"$$0 }'; fi) truelight@0: tmp_test:=$(shell echo "$(REV)" | grep "M" ) truelight@0: ifdef tmp_test truelight@0: REV_NUMBER:=1 truelight@0: endif truelight@0: endif truelight@0: truelight@0: ifndef REV_NUMBER truelight@0: REV_NUMBER:=0 truelight@0: endif truelight@0: truelight@0: # MorphOS needs builddate truelight@0: BUILDDATE=`date +%d.%m.%y` truelight@0: truelight@0: # AMD64 needs a little more settings to work truelight@0: ifeq ($(shell uname -m), x86_64) truelight@0: endwarnings:=endwarnings truelight@0: 64_bit_warnings:=64_bit_warnings truelight@157: BASECFLAGS += -m64 truelight@0: endif truelight@0: truelight@0: truelight@0: # When calling the compiler, use these flags truelight@0: # -g debugging symbols truelight@0: # -Wall all warnings truelight@0: # -s automatic strip truelight@0: # truelight@0: # You may also want: truelight@0: # -O optimize or -O2 fully optimize (O's above 2 are not recommended) truelight@0: # -pg profile - generate profiling data. See "man gprof" to use this. truelight@0: truelight@0: CFLAGS=-Wall -Wno-multichar truelight@0: CDEFS=-DWITH_REV truelight@0: LDFLAGS= truelight@0: LIBS= truelight@0: truelight@0: ifdef DEBUG truelight@0: # Debug mode truelight@0: CDEFS += -D_DEBUG truelight@0: BASECFLAGS += -g truelight@0: else truelight@0: ifdef PROFILE truelight@0: BASECFLAGS += -pg truelight@543: LDFLAGS += -pg truelight@0: else truelight@0: # Release mode truelight@0: ifndef MORPHOS truelight@0: # automatical strip breaks under morphos truelight@0: BASECFLAGS += -s truelight@0: LDFLAGS += -s truelight@0: endif truelight@0: endif truelight@0: truelight@0: ifdef OSX truelight@0: # these compilerflags makes the app run as fast as possible without making the app unstable. It works on G3 or newer truelight@0: 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) truelight@0: else truelight@0: ifdef MORPHOS bjarni@569: BASECFLAGS += -O3 -funroll-loops -fexpensive-optimizations -mstring -mmultiple $(WARNING_DISPLAY) truelight@0: else truelight@0: BASECFLAGS += -O2 $(WARNING_DISPLAY) truelight@0: endif truelight@0: ifndef PROFILE truelight@0: BASECFLAGS += -fomit-frame-pointer truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: truelight@0: ifdef STATIC truelight@0: ifndef OSX # OSX can't build static if -static flag is used truelight@0: LDFLAGS += -static truelight@0: endif truelight@0: endif truelight@0: truelight@0: # If building on Cygwin/MingW don't link with Cygwin libs truelight@0: ifdef WIN32 truelight@0: ifdef MINGW truelight@0: ifdef CYGWIN truelight@0: BASECFLAGS += -mno-cygwin truelight@0: LDFLAGS += -mno-cygwin truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: truelight@0: CFLAGS += $(BASECFLAGS) truelight@0: truelight@0: ifdef UNIX truelight@0: CDEFS += -DUNIX truelight@0: endif truelight@0: tron@421: ifdef BEOS tron@421: CDEFS += -DBEOS tron@421: LDFLAGS += -lmidi -lbe tron@421: ifdef WITH_NETWORK tron@421: ifdef BEOS_NET_SERVER tron@421: CDEFS += -DBEOS_NET_SERVER tron@421: endif tron@421: endif tron@421: endif tron@421: tron@446: ifdef SUNOS tron@446: CDEFS += -DSUNOS tron@446: ifdef WITH_NETWORK tron@446: LDFLAGS += -lnsl -lsocket tron@446: endif tron@446: endif tron@446: truelight@0: # SDL config truelight@0: ifdef WITH_SDL truelight@0: CDEFS += -DWITH_SDL truelight@0: CFLAGS += `$(SDL-CONFIG) --cflags` truelight@0: ifdef STATIC truelight@0: LIBS += `$(SDL-CONFIG) --static-libs` truelight@0: else truelight@0: LIBS += `$(SDL-CONFIG) --libs` truelight@0: endif truelight@0: endif truelight@0: truelight@0: truelight@0: # zlib config truelight@0: ifdef WITH_ZLIB truelight@0: CDEFS += -DWITH_ZLIB truelight@0: ifdef STATIC truelight@0: ifdef OSX truelight@0: # zlib is default on OSX, so everybody have it. No need for static linking truelight@0: LIBS += -lz truelight@0: else truelight@0: ifndef STATIC_ZLIB_PATH truelight@0: ifndef MANUAL_CONFIG truelight@0: # updates makefile.config with the zlib path truelight@0: UPDATECONFIG:=upgradeconf truelight@0: endif truelight@0: TEMP:=$(shell ls /lib 2>/dev/null | grep "zlib.a")$(shell ls /lib 2>/dev/null | grep "libz.a") truelight@0: ifdef TEMP truelight@0: STATIC_ZLIB_PATH:=/lib/$(TEMP) truelight@0: else truelight@0: TEMP:=$(shell ls /usr/lib 2>/dev/null | grep "zlib.a")$(shell ls /usr/lib 2>/dev/null | grep "libz.a") truelight@0: ifdef TEMP truelight@0: STATIC_ZLIB_PATH:=/usr/lib/$(TEMP) truelight@0: else truelight@0: TEMP:=$(shell ls /usr/local/lib 2>/dev/null | grep "zlib.a")$(shell ls /usr/local/lib 2>/dev/null | grep "libz.a") truelight@0: ifdef TEMP truelight@0: STATIC_ZLIB_PATH:=/usr/local/lib/$(TEMP) truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: LIBS += $(STATIC_ZLIB_PATH) truelight@0: endif truelight@0: else truelight@0: LIBS += -lz truelight@0: endif truelight@0: endif truelight@0: truelight@0: # libpng config truelight@0: ifdef WITH_PNG truelight@0: CDEFS += -DWITH_PNG truelight@0: # FreeBSD doesn't use libpng-config truelight@0: ifdef FREEBSD truelight@0: LIBS += -lpng truelight@0: else truelight@0: CFLAGS += `libpng-config --cflags` bjarni@551: truelight@0: # seems like older libpng versions are broken and need this truelight@0: PNGCONFIG_FLAGS = --ldflags --libs truelight@0: ifdef STATIC bjarni@583: ifdef OSX bjarni@583: # Seems like we need a tiny hack for OSX static to work bjarni@583: LIBS += `libpng-config --prefix`/lib/libpng.a bjarni@583: else truelight@0: LIBS += `libpng-config --static $(PNGCONFIG_FLAGS)` bjarni@583: endif truelight@0: else bjarni@551: LIBS += `libpng-config --L_opts $(PNGCONFIG_FLAGS)` truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: bjarni@347: # enables/disables assert() bjarni@348: ifdef DISABLE_ASSERTS bjarni@348: CFLAGS += -DNDEBUG bjarni@348: endif bjarni@348: bjarni@348: # automatically disables asserts for release bjarni@348: ifdef RELEASE bjarni@347: ifndef ENABLE_ASSERTS bjarni@347: CFLAGS += -DNDEBUG bjarni@347: endif bjarni@348: endif truelight@0: truelight@0: ifdef TRANSLATOR truelight@0: STRGEN_FLAGS=-t truelight@0: else truelight@0: STRGEN_FLAGS= truelight@0: endif truelight@0: truelight@0: truelight@0: # MIDI setup truelight@0: ifdef OSX truelight@0: ifndef MIDI truelight@0: MIDI:=$(OSXAPP)/contents/macos/track_starter truelight@0: endif bjarni@561: ifndef SECOND_DATA_PATH bjarni@561: SECOND_DATA_PATH:="$(OSXAPP)/contents/data/" bjarni@561: endif bjarni@561: ifndef CUSTOM_LANG_DIR bjarni@561: CUSTOM_LANG_DIR:="$(OSXAPP)/contents/lang/" bjarni@561: endif truelight@0: endif truelight@0: truelight@0: ifdef MIDI truelight@0: CDEFS += -DEXTERNAL_PLAYER=\"$(MIDI)\" truelight@0: ifdef MIDI_ARG truelight@0: CDEFS += -DMIDI_ARG=\"$(MIDI_ARG)\" truelight@0: endif truelight@0: endif truelight@0: truelight@0: ifdef WITH_NETWORK truelight@0: CDEFS += -DENABLE_NETWORK truelight@543: ifdef QNX truelight@543: LIBS += -lsocket truelight@543: endif truelight@0: ifdef UNIX truelight@0: ifndef OSX truelight@0: ifndef MORPHOS truelight@0: # this have caused problems on many platforms and disabling it didn't break anything truelight@0: # now we test if disabling it as a general breaks it for anybody truelight@0: #LIBS += -lresolv truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: endif truelight@0: bjarni@561: bjarni@561: ifdef SECOND_DATA_PATH bjarni@561: CDEFS += -DSECOND_DATA_DIR=\"$(SECOND_DATA_PATH)/\" bjarni@561: endif bjarni@561: bjarni@561: ifdef CUSTOM_LANG_DIR bjarni@561: CDEFS += -DCUSTOM_LANG_DIR=\"$(CUSTOM_LANG_DIR)/\" bjarni@561: endif bjarni@561: truelight@0: ifdef WITH_DIRECTMUSIC truelight@0: CDEFS += -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT truelight@0: endif truelight@0: truelight@0: ifdef WIN32 truelight@0: LIBS += -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32 -lstdc++ truelight@0: TTDLDFLAGS += -Wl,--subsystem,windows truelight@0: endif truelight@0: truelight@0: # sets up the paths for use for make install bjarni@285: ifdef INSTALL bjarni@285: # We use _PREFIXED vars here, so the paths are recalculated every time, and bjarni@285: # the prefix is not prepended in the makefile config bjarni@285: BINARY_DIR_PREFIXED:=$(PREFIX)/$(BINARY_DIR) bjarni@285: DATA_DIR_PREFIXED:=$(PREFIX)/$(DATA_DIR) bjarni@285: # We use _INSTALL vars here, these vars are the locations where the files will bjarni@285: # be installed bjarni@285: DATA_DIR_INSTALL=$(DEST_DIR)/$(DATA_DIR_PREFIXED) bjarni@285: BINARY_DIR_INSTALL=$(DEST_DIR)/$(BINARY_DIR_PREFIXED) bjarni@285: # Let the code know where to find stuff bjarni@285: ifdef DATA_DIR_PREFIXED bjarni@285: CDEFS += -DGAME_DATA_DIR=\"$(DATA_DIR_PREFIXED)/\" truelight@0: endif bjarni@285: bjarni@285: ifdef PERSONAL_DIR bjarni@285: CDEFS += -DPERSONAL_DIR=\"$(PERSONAL_DIR)/\" bjarni@285: endif bjarni@285: bjarni@285: ifdef USE_HOMEDIR bjarni@285: CDEFS += -DUSE_HOMEDIR bjarni@285: endif truelight@0: endif truelight@0: truelight@0: ############################################################################## truelight@0: # truelight@0: # What to compile truelight@0: # (users do not want to modify anything below) truelight@0: # truelight@0: truelight@0: truelight@0: ### Sources truelight@0: tron@421: C_SOURCES = \ truelight@112: ai.c ai_build.c ai_new.c ai_pathfinder.c ai_shared.c aircraft_cmd.c \ truelight@112: aircraft_gui.c airport.c airport_gui.c aystar.c bridge_gui.c \ truelight@543: callback_table.c clear_cmd.c command.c console.c console_cmds.c \ truelight@543: dedicated.c disaster_cmd.c dock_gui.c dummy_land.c economy.c \ dominik@452: engine.c engine_gui.c fileio.c gfx.c graph_gui.c newgrf.c \ truelight@602: industry_cmd.c industry_gui.c intro_gui.c landscape.c main_gui.c md5.c \ truelight@112: minilzo.c misc.c misc_cmd.c misc_gui.c music_gui.c namegen.c network.c \ truelight@543: network_client.c network_data.c network_gamelist.c network_gui.c \ truelight@543: network_server.c network_udp.c news_gui.c oldloader.c order_cmd.c \ truelight@543: order_gui.c pathfind.c player_gui.c players.c queue.c rail_cmd.c \ truelight@543: rail_gui.c rev.c road_cmd.c road_gui.c roadveh_cmd.c roadveh_gui.c \ truelight@543: saveload.c screenshot.c settings.c settings_gui.c ship_cmd.c \ truelight@543: ship_gui.c smallmap_gui.c sound.c sprite.c spritecache.c station_cmd.c \ truelight@543: station_gui.c strings.c subsidy_gui.c terraform_gui.c texteff.c \ truelight@543: town_cmd.c town_gui.c train_cmd.c train_gui.c tree_cmd.c ttd.c \ truelight@543: tunnelbridge_cmd.c unmovable_cmd.c vehicle.c vehicle_gui.c viewport.c \ truelight@543: water_cmd.c widget.c window.c tron@421: CXX_SOURCES = truelight@0: truelight@0: ifdef WITH_SDL tron@421: C_SOURCES += sdl.c truelight@0: endif truelight@0: truelight@0: ifdef WIN32 tron@421: C_SOURCES += win32.c w32dm.c truelight@0: else tron@421: C_SOURCES += extmidi.c unix.c truelight@0: endif truelight@0: tron@421: ttd_OBJS = $(C_SOURCES:%.c=%.o) $(CXX_SOURCES:%.cpp=%.o) tron@421: tron@421: ifdef BEOS bjarni@532: CXX_SOURCES += os/beos/bemidi.cpp bjarni@532: CFLAGS += -I. tron@421: endif truelight@0: truelight@0: ifdef WIN32 truelight@0: # Resource file truelight@0: ttd_OBJS += winres.o truelight@0: endif truelight@0: truelight@0: ifdef WITH_DIRECTMUSIC tron@421: CXX_SOURCES += w32dm2.cpp truelight@0: endif truelight@0: truelight@0: ttd_DEPS1 = $(foreach obj,$(ttd_OBJS),.deps/$(obj)) truelight@0: ttd_DEPS = $(ttd_DEPS1:%.o=%.P) truelight@0: truelight@0: LANG_TXT = $(filter-out %.unfinished.txt,$(wildcard lang/*.txt)) truelight@0: LANGS = $(LANG_TXT:%.txt=%.lng) truelight@0: truelight@0: C_COMPILE = $(CC) $(CFLAGS) $(CDEFS) truelight@0: CXX_COMPILE = $(CXX) $(CFLAGS) $(CDEFS) truelight@0: truelight@0: C_BUILD = $(C_COMPILE) -c truelight@0: CXX_BUILD = $(CXX_COMPILE) -c truelight@0: truelight@0: C_LINK = $(CC) $(LDFLAGS) -o truelight@0: truelight@0: bjarni@162: truelight@0: ############################################################################## truelight@0: # truelight@0: # Targets truelight@0: # truelight@0: truelight@0: truelight@0: ### Normal build rules truelight@0: truelight@0: truelight@0: ifdef OSX truelight@0: OSX:=OSX truelight@0: endif truelight@0: truelight@0: tron@475: all: endian.h $(UPDATECONFIG) $(LANGS) $(TTD) $(OSX) $(endwarnings) truelight@0: truelight@157: endian.h: $(ENDIAN_CHECK) darkvater@222: @# Check if system is LITTLE_ENDIAN or BIG_ENDIAN truelight@163: @echo 'Running endian_check'; \ truelight@163: ./$(ENDIAN_CHECK) > $@ truelight@157: truelight@157: $(ENDIAN_CHECK): endian_check.c truelight@163: @echo 'Compiling and Linking $@'; \ truelight@163: $(CC) $(BASECFLAGS) $(CDEFS) endian_check.c -o $@ darkvater@222: truelight@0: tron@475: $(TTD): table/strings.h $(ttd_OBJS) $(MAKE_CONFIG) pasky@462: $(if $(VERBOSE),@echo '$(C_LINK) $@ $(TTDLDFLAGS) $(ttd_OBJS) $(LIBS)';,@echo 'Compiling and Linking $@';) \ pasky@462: $(C_LINK) $@ $(TTDLDFLAGS) $(ttd_OBJS) $(LIBS) $(VERBOSE_FILTER) truelight@0: bjarni@563: $(OSX): bjarni@610: @rm -fr "$(OSXAPP)" bjarni@610: @mkdir -p "$(OSXAPP)"/Contents/MacOS bjarni@610: @mkdir -p "$(OSXAPP)"/Contents/Resources bjarni@610: @mkdir -p "$(OSXAPP)"/Contents/Data bjarni@610: @mkdir -p "$(OSXAPP)"/Contents/Lang bjarni@610: @echo "APPL????" > "$(OSXAPP)"/Contents/PkgInfo bjarni@610: @cp os/macos/ttd.icns "$(OSXAPP)"/Contents/Resources/openttd.icns bjarni@610: @os/macos/plistgen.sh "$(OSXAPP)" "$(REV)" bjarni@610: @cp os/macos/track_starter "$(OSXAPP)"/contents/macos truelight@0: @ls os/macos | grep -q "\.class" || \ truelight@0: javac os/macos/OpenTTDMidi.java bjarni@610: @cp os/macos/OpenTTDMidi.class "$(OSXAPP)"/contents/macos bjarni@610: @cp data/* "$(OSXAPP)"/Contents/data/ bjarni@610: @cp lang/*.lng "$(OSXAPP)"/Contents/lang/ bjarni@610: @cp $(TTD) "$(OSXAPP)"/Contents/MacOS/$(TTD) truelight@0: truelight@0: $(endwarnings): $(64_bit_warnings) truelight@0: truelight@0: $(64_bit_warnings): truelight@0: $(warning 64 bit CPUs will get some 64 bit specific bugs!) truelight@0: $(warning If you see any bugs, include in your bug report that you use a 64 bit CPU) truelight@0: tron@451: $(STRGEN): strgen/strgen.c bjarni@162: @echo 'Compiling and Linking $@'; \ bjarni@162: $(CC) $(BASECFLAGS) $(CDEFS) -o $@ $^ $(VERBOSE_FILTER) truelight@0: tron@474: table/strings.h: lang/english.txt $(STRGEN) bjarni@162: @echo 'Generating $@'; \ truelight@0: $(STRGEN) darkvater@222: tron@476: lang/%.lng: lang/%.txt $(STRGEN) lang/english.txt bjarni@162: @echo 'Generating $@'; \ bjarni@180: $(STRGEN) $(STRGEN_FLAGS) $< $(VERBOSE_FILTER) $(LANG_ERRORS) truelight@0: truelight@0: winres.o: ttd.rc truelight@0: windres -o $@ $< truelight@0: bjarni@563: ifdef OSX bjarni@563: release: all bjarni@565: @mkdir -p "OpenTTD $(RELEASE)" bjarni@565: @mkdir -p "OpenTTD $(RELEASE)"/docs bjarni@565: @cp -R $(OSXAPP) "OpenTTD $(RELEASE)"/ bjarni@565: @cp docs/OSX_where_did_the_package_go.txt "OpenTTD $(RELEASE)"/Where\ did\ the\ package\ go.txt bjarni@565: @cp readme.txt "OpenTTD $(RELEASE)"/docs/ bjarni@565: @cp docs/README_if_game_crashed_on_OSX.txt "OpenTTD $(RELEASE)"/docs/readme\ if\ crashed\ on\ OSX.txt bjarni@565: @cp docs/console.txt "OpenTTD $(RELEASE)"/docs/ bjarni@565: @cp COPYING "OpenTTD $(RELEASE)"/docs/ bjarni@565: @cp changelog.txt "OpenTTD $(RELEASE)"/docs/ bjarni@565: @cp docs/README_if_game_crashed_on_OSX.txt "OpenTTD $(RELEASE)"/docs/ bjarni@565: @cp os/macos/*.webloc "OpenTTD $(RELEASE)" bjarni@590: @/usr/bin/hdiutil create -ov -format UDZO -srcfolder "OpenTTD $(RELEASE)" openttd-"$(RELEASE)"-osx.dmg bjarni@565: @rm -fr "OpenTTD $(RELEASE)" bjarni@563: bjarni@564: nightly_build: all bjarni@574: @mkdir -p "OpenTTD_nightly_$(DATE)" bjarni@574: @mkdir -p "OpenTTD_nightly_$(DATE)"/docs bjarni@574: @cp -R $(OSXAPP) "OpenTTD_nightly_$(DATE)"/ bjarni@574: @cp docs/OSX_where_did_the_package_go.txt "OpenTTD_nightly_$(DATE)"/Where\ did\ the\ package\ go.txt bjarni@574: @cp readme.txt "OpenTTD_nightly_$(DATE)"/docs/ bjarni@574: @cp docs/README_if_game_crashed_on_OSX.txt "OpenTTD_nightly_$(DATE)"/docs/readme\ if\ crashed\ on\ OSX.txt bjarni@574: @cp docs/console.txt "OpenTTD_nightly_$(DATE)"/docs/ bjarni@574: @cp COPYING "OpenTTD_nightly_$(DATE)"/docs/ bjarni@574: @cp revisionlog.txt "OpenTTD_nightly_$(DATE)"/revisionlog.txt bjarni@574: @cp docs/README_if_game_crashed_on_OSX.txt "OpenTTD_nightly_$(DATE)"/docs/ bjarni@574: @cp os/macos/*.webloc "OpenTTD_nightly_$(DATE)"/ bjarni@590: @/usr/bin/hdiutil create -ov -format UDZO -srcfolder "OpenTTD_nightly_$(DATE)" openttd-nightly-"$(DATE)".dmg bjarni@574: @rm -fr "OpenTTD_nightly_$(DATE)" bjarni@564: bjarni@564: .PHONY: release nightly_build bjarni@563: endif truelight@0: truelight@0: rev.c: FORCE truelight@0: @# setting the revision number in a place, there the binary can read it bjarni@615: @echo 'const char _openttd_revision[] = "$(REV)";' >>rev.c.new truelight@0: @echo 'const int _revision_number = $(REV_NUMBER);' >>rev.c.new truelight@0: @# some additions for MorphOS versions tag truelight@0: @echo '#ifdef __MORPHOS__' >>rev.c.new bjarni@615: @echo 'const char morphos_versions_tag[] = "\\0$$VER: OpenTTD $(REV) ('${BUILDDATE}') © OpenTTD Team [MorphOS, PowerPC]";' >>rev.c.new truelight@0: @echo '#endif' >>rev.c.new truelight@0: @# Only update the real rev.c if it actually changed, to prevent truelight@0: @# useless rebuilds. truelight@0: @cmp -s rev.c rev.c.new 2>/dev/null || mv rev.c.new rev.c truelight@0: @rm -f rev.c.new truelight@0: truelight@0: FORCE: truelight@0: truelight@0: truelight@0: clean: bjarni@162: @echo 'Cleaning up...'; \ bjarni@589: rm -rf .deps *~ $(TTD) $(STRGEN) core table/strings.h $(LANGS) $(ttd_OBJS) endian.h $(ENDIAN_CHECK) truelight@0: truelight@0: mrproper: clean truelight@0: rm -rf $(MAKE_CONFIG) truelight@0: truelight@0: ifndef OSX truelight@0: ifndef MORPHOS truelight@0: install: bjarni@285: ifeq ($(INSTALL),) bjarni@285: $(error make install is highly experimental at his state and not\ truelight@0: tested very much - use at your own risk - to use run \"make install INSTALL:=1\" - make sure makefile.config\ truelight@0: is set correctly up - run \"make upgradeconf\") bjarni@285: endif bjarni@285: truelight@543: ifeq ($(PREFIX), ) truelight@543: $(error no prefix set - check makefile.config) bjarni@285: endif bjarni@285: # We compare against the non prefixed version here, so we won't install bjarni@285: # if only the prefix has been set bjarni@285: ifeq ($(DATA_DIR),) bjarni@285: $(error no data path set - check makefile.config) bjarni@285: endif bjarni@285: ifeq ($(BINARY_DIR),) bjarni@285: $(error no binary path set - check makefile.config) bjarni@285: endif bjarni@285: # We'll install in $DEST_DIR instead of root if it is set (we don't bjarni@285: # care about extra /'s bjarni@285: mkdir -p $(DATA_DIR_INSTALL)/lang bjarni@285: mkdir -p $(DATA_DIR_INSTALL)/data bjarni@285: mkdir -p $(DATA_DIR_INSTALL)/gm bjarni@285: mkdir -p $(BINARY_DIR_INSTALL) bjarni@285: cp $(TTD) $(BINARY_DIR_INSTALL) bjarni@285: cp lang/*.lng $(DATA_DIR_INSTALL)/lang bjarni@285: cp data/*.grf $(DATA_DIR_INSTALL)/data bjarni@285: cp data/opntitle.dat $(DATA_DIR_INSTALL)/data bjarni@285: cp media/openttd.64.png $(DATA_DIR_INSTALL) truelight@0: else #MorphOS truelight@0: install: truelight@0: $(error make install is not supported on MorphOS) truelight@0: endif truelight@0: else # OSX truelight@0: install: truelight@0: $(error make install is not supported on MacOSX) truelight@0: endif truelight@0: truelight@0: truelight@0: love: truelight@0: @echo "YES! I thought you would never ask. We will have a great time. You can keep me turned on all night" truelight@0: truelight@0: .PHONY: clean all $(OSX) install $(64_bit_warnings) $(endwarnings) love truelight@0: truelight@0: truelight@0: ### Automatic configuration truelight@0: -include $(CONFIG_WRITER) darkvater@222: truelight@0: truelight@0: # Export all variables set to subprocesses (a bit dirty) truelight@0: .EXPORT_ALL_VARIABLES: truelight@0: upgradeconf: $(MAKE_CONFIG) truelight@0: rm $(MAKE_CONFIG) truelight@0: $(MAKE) $(MAKE_CONFIG) truelight@0: truelight@0: .PHONY: upgradeconf truelight@0: truelight@0: truelight@0: ### Internal build rules truelight@0: truelight@0: # This makes sure the .deps dir is always around. truelight@0: DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) truelight@0: truelight@0: # Introduce the dependencies truelight@0: -include $(ttd_DEPS) truelight@0: truelight@0: # This compiles the object file as well as silently updating its dependencies truelight@0: # list at the same time. It is not an issue that they aren't around during the truelight@0: # first compilation round as we just build everything at that time anyway, truelight@0: # therefore we do not need to watch deps. bjarni@162: bjarni@162: #@echo '$(C_BUILD) $<'; \ bjarni@162: bjarni@162: truelight@0: %.o: %.c $(MAKE_CONFIG) pasky@462: $(if $(VERBOSE),@echo '$(C_BUILD) $<',@echo 'Compiling $(*F).o'); \ bjarni@162: $(C_BUILD) $< -Wp,-MD,.deps/$(*F).pp $(VERBOSE_FILTER) truelight@0: @-cp .deps/$(*F).pp .deps/$(*F).P; \ truelight@0: tr ' ' '\012' < .deps/$(*F).pp \ truelight@0: | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ truelight@0: >> .deps/$(*F).P; \ truelight@0: rm .deps/$(*F).pp truelight@0: bjarni@532: # For DirectMusic build and BeOS specific parts truelight@0: %.o: %.cpp $(MAKE_CONFIG) bjarni@532: $(CXX_BUILD) $< -o $@