tron@2185: # $Id$ tron@2185: 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 bjarni@2736: # WITH_COCOA: Cocoa 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: # 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. pasky@1584: # If unset, it will use the hardcoded path in the c code pasky@1584: # This can still be overriden by the music.extmidi openttd.cfg option. tron@2197: # WITH_DIRECTMUSIC: enable DirectMusic MIDI support bjarni@804: # WITH_NETWORK: enable networking bjarni@804: # DEDICATED: allows compilation on UNIX without SDL. Useful for dedicated servers bjarni@2672: # MAX_NUM_AUTOSAVES: sets the number of autosaves the games will make before starting bjarni@2672: # to overwrite the old ones. If not set, the game will use 16. bjarni@2672: # NOTE: assign a number, not a string of a number 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) matthijs@1865: # DATA_DIR: The location of the data (lang, data, gm and scenario), normally matthijs@1865: # share/games/openttd. (Will be prefixed with $PREFIX) Note that scenarios matthijs@1865: # are only put here if USE_HOMEDIR is true, otherwise they are placed in matthijs@1865: # PERSONAL_DIR/scenario matthijs@2901: # ICON_DIR: The location of the openttd icon. (Will be prefixed with matthijs@2901: # $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 tron@1251: # 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 pasky@1476: # (Note that DESTDIR is checked if DEST_DIR is not set.) 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: # pasky@1411: # VERBOSE: show full compiler invocations instead of brief progress messages pasky@1411: # TrueLight@1692: # Special for crosscompiling there are some commands available: TrueLight@1692: # bjarni@2834: # FAT_BINARY: builds a universal binary for OSX. Make sure you got both PPC and x86 libs. Only works with GCC 4 or newer bjarni@2834: # bjarni@2834: # JAGUAR: Crosscompiling for OSX 1.2.8 (codenamed Jaguar). Only works if OSX is defined too. Only works with GCC 4 or newer bjarni@2834: # This can be changed to any PPC version of OSX by changing the ppc flags in Makefile.config bjarni@2713: # bjarni@2719: # ENDIAN_FORCE: forces the endian-check to give a certain result. Can be BE, LE or PREPROCESSOR. bjarni@2719: # PREPROCESSOR is always used on all OSX targets and will make the preprocessor pick the right endian. bjarni@2719: # this means that you don't have to think about endianess when compiling for OSX. bjarni@2719: # Very useful for universal binaries and crosscompilers. Not sure if it works on non OSX targets TrueLight@1692: # WINDRES: the location of your windres TrueLight@1692: # CC_HOST: the gcc of your localhost if you are making a target that produces incompatible executables TrueLight@1692: # CFLAGS_HOST: cflags used for CC_HOST. Make it something if you are getting errors when you try to compi TrueLight@1692: # windows executables on linux. (just: CFLAGS_HOST:='-I' or something) truelight@0: truelight@0: truelight@0: ############################################################################## truelight@0: # truelight@0: # Configuration truelight@0: # truelight@0: bjarni@1148: bjarni@180: # Makefile version tag pasky@1492: # it checks if the version tag in Makefile.config is the same and force update outdated config files bjarni@2672: MAKEFILE_VERSION:=8 bjarni@180: tron@1146: # CONFIG_WRITER has 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@1955: ifndef LIBPNG-CONFIG bjarni@1955: LIBPNG-CONFIG :=libpng-config bjarni@1955: endif bjarni@1955: pasky@1492: # 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 bjarni@1693: endif bjarni@1693: bjarni@1693: ifndef SDL-CONFIG bjarni@1693: UPDATECONFIG:=upgradeconf bjarni@1693: CONFIG_INCLUDED:= truelight@0: endif truelight@0: pasky@1492: # 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@180: ifdef SUPRESS_LANG_ERRORS bjarni@180: LANG_ERRORS = >/dev/null 2>&1 bjarni@180: endif bjarni@180: bjarni@2722: ifdef OSX bjarni@2722: -include os/MacOSX/Makefile.setup bjarni@2722: endif bjarni@2722: truelight@0: ifdef STATIC truelight@0: ifndef WIN32 truelight@0: ifndef OSX truelight@0: ifndef MORPHOS truelight@0: ifndef SKIP_STATIC_CHECK pasky@1492: $(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@2736: ifdef WITH_COCOA bjarni@2736: ifdef WITH_SDL bjarni@2736: $(error You can not use both the SDL video driver and the Cocoa video driver at the same time) bjarni@2736: endif bjarni@2736: ifdef DEDICATED bjarni@2736: $(error You can not use the Cocoa video driver in a dedicated server) bjarni@2736: endif bjarni@2736: else 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@2736: endif bjarni@549: bjarni@1029: # remove the dependancy for sdl if DEDICALTED is used bjarni@1029: ifdef DEDICATED Darkvater@2779: WITH_SDL:= Darkvater@2779: endif Darkvater@2779: Darkvater@2779: # add -lpthread to LDFLAGS truelight@2298: ifndef WIN32 Darkvater@2779: ifndef MORPHOS Darkvater@2779: ifndef OSX Darkvater@2779: LDFLAGS+=-lpthread Darkvater@2779: endif Darkvater@2779: endif bjarni@1029: endif Darkvater@2779: truelight@2300: ifdef OSX Darkvater@2779: LDFLAGS+=-framework Cocoa truelight@2300: endif truelight@0: truelight@0: truelight@0: ############################################################################## truelight@0: # truelight@0: # Compiler configuration truelight@0: # 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: Darkvater@9957: REV := 0.4.6-$(shell if test -d .svn; then svnversion . | awk '{ print "r"$$0 }'; fi) truelight@0: truelight@0: # MorphOS needs builddate tron@1289: BUILDDATE=`date +%d.%m.%y` truelight@0: TrueLight@1692: # Check if there is a windres override TrueLight@1692: ifndef WINDRES TrueLight@1692: WINDRES = windres TrueLight@1692: endif TrueLight@1692: TrueLight@1692: # Check if we have a new target TrueLight@1692: ifdef CC_TARGET TrueLight@1692: CC = $(CC_TARGET) TrueLight@1692: endif TrueLight@1692: TrueLight@1692: # Check if CC_HOST is defined. If not, it is CC TrueLight@1692: ifndef CC_HOST TrueLight@1692: CC_HOST = $(CC) TrueLight@1692: endif TrueLight@1692: ifndef CFLAGS_HOST TrueLight@1692: CFLAGS_HOST = $(BASECFLAGS) TrueLight@1692: endif truelight@0: truelight@0: tron@1069: CC_VERSION = $(shell $(CC) -dumpversion | cut -c 1,3) tron@1052: tron@1052: # GNU make can only test for (in)equality tron@1052: # this is a workaround to test for >= tron@2240: ifeq ($(shell expr $(CC_VERSION) \>= 29), 1) tron@2751: CFLAGS += -O -Wall -Wno-multichar -Wsign-compare -Wstrict-prototypes -Wundef tron@1324: CFLAGS += -Wwrite-strings -Wpointer-arith tron@1052: endif tron@2240: ifeq ($(shell expr $(CC_VERSION) \>= 30), 1) tron@1052: CFLAGS += -W -Wno-unused-parameter tron@1052: endif tron@2240: ifeq ($(shell expr $(CC_VERSION) \>= 34), 1) tron@1093: CFLAGS += -Wdeclaration-after-statement -Wold-style-definition tron@1052: endif tron@1052: tron@1240: ifdef DEBUG tron@1479: ifeq ($(shell expr $(DEBUG) \>= 1), 1) tron@1479: CFLAGS += -g -D_DEBUG tron@1479: endif tron@1479: ifeq ($(shell expr $(DEBUG) \>= 2), 1) tron@1479: CFLAGS += -fno-inline tron@1479: endif tron@1479: ifeq ($(shell expr $(DEBUG) \>= 3), 1) tron@1479: CFLAGS += -O0 tron@1479: endif tron@1240: endif tron@1240: tron@1240: ifdef PROFILE tron@1240: CFLAGS += -pg tron@1240: LDFLAGS += -pg tron@1240: endif tron@1240: truelight@0: CDEFS=-DWITH_REV truelight@0: tron@1240: ifndef DEBUG tron@1240: ifndef PROFILE truelight@0: # Release mode truelight@0: ifndef MORPHOS Darkvater@1810: ifndef IRIX truelight@0: # automatical strip breaks under morphos truelight@0: BASECFLAGS += -s truelight@0: LDFLAGS += -s truelight@0: endif truelight@0: endif Darkvater@1810: 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 bjarni@2713: 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 truelight@0: else truelight@0: ifdef MORPHOS tron@2356: BASECFLAGS += -I/gg/os-include -O2 -noixemul -fstrict-aliasing -fexpensive-optimizations tron@1291: BASECFLAGS += -mcpu=604 -fno-inline -mstring -mmultiple truelight@0: else tron@1169: BASECFLAGS += -O2 truelight@0: endif truelight@0: ifndef PROFILE Darkvater@1810: ifndef IRIX truelight@0: BASECFLAGS += -fomit-frame-pointer truelight@0: endif truelight@0: endif truelight@0: endif Darkvater@1810: 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: darkvater@798: # If building on MingW don't link with Cygwin libs truelight@0: ifdef WIN32 darkvater@798: ifdef CYGWIN darkvater@798: BASECFLAGS += -mwin32 darkvater@798: LDFLAGS += -mwin32 darkvater@798: endif truelight@0: ifdef MINGW truelight@0: BASECFLAGS += -mno-cygwin truelight@0: LDFLAGS += -mno-cygwin 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 bjarni@2497: LDFLAGS += -lmidi -lbe -lpthread tron@421: ifdef WITH_NETWORK tron@421: ifdef BEOS_NET_SERVER tron@1051: CDEFS += -DBEOS_NET_SERVER bjarni@2497: LDFLAGS += -lnet tron@1051: else bjarni@2497: # BONE needs a few more libraries than R5 tron@1051: LDFLAGS += -lbind -lsocket tron@421: endif tron@421: endif tron@421: endif tron@421: tron@1164: ifdef MORPHOS tron@1291: # -Wstrict-prototypes generates much noise because of system headers tron@1291: CFLAGS += -Wno-strict-prototypes tron@1164: endif tron@1164: 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: bjarni@2500: # tell the source that we are building a dedicated server bjarni@2500: ifdef DEDICATED bjarni@2500: CDEFS += -DDEDICATED bjarni@2500: endif bjarni@2500: truelight@0: # SDL config truelight@0: ifdef WITH_SDL truelight@0: CDEFS += -DWITH_SDL tron@1254: CFLAGS += $(shell $(SDL-CONFIG) --cflags) truelight@0: ifdef STATIC tron@1254: LIBS += $(shell $(SDL-CONFIG) --static-libs) truelight@0: else tron@1254: LIBS += $(shell $(SDL-CONFIG) --libs) truelight@0: endif truelight@0: endif 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 pasky@1492: # 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 tron@2315: CFLAGS += $(shell $(LIBPNG-CONFIG) --cppflags --I_opts) 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@1955: LIBS += $(shell $(LIBPNG-CONFIG) --prefix)/lib/libpng.a bjarni@583: else bjarni@1955: LIBS += $(shell $(LIBPNG-CONFIG) --static $(PNGCONFIG_FLAGS)) bjarni@583: endif truelight@0: else bjarni@1955: LIBS += $(shell $(LIBPNG-CONFIG) --L_opts $(PNGCONFIG_FLAGS)) truelight@0: endif truelight@0: endif truelight@0: bjarni@9956: ifdef OSX bjarni@9956: ifndef JAGUAR bjarni@9956: LIBS += -liconv bjarni@9956: endif bjarni@9956: endif bjarni@9956: 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: bjarni@2555: # OSX specific setup truelight@0: ifdef OSX bjarni@2719: # set the endian flag for OSX, that can't fail bjarni@2719: ENDIAN_FORCE:=PREPROCESSOR bjarni@2719: bjarni@2555: ifndef DEDICATED bjarni@2555: LIBS += -framework QuickTime bjarni@2555: endif bjarni@2555: bjarni@2736: ifdef WITH_COCOA bjarni@2736: CDEFS += -DWITH_COCOA bjarni@2736: LIBS += -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit bjarni@2736: endif bjarni@2736: bjarni@2555: # OSX path setup bjarni@2555: ifndef SECOND_DATA_PATH bjarni@2555: SECOND_DATA_PATH:="$(OSXAPP)/Contents/Data/" bjarni@2555: endif bjarni@2555: bjarni@2555: ifndef CUSTOM_LANG_DIR bjarni@2555: ifndef DEDICATED bjarni@2555: CUSTOM_LANG_DIR:="$(OSXAPP)/Contents/Lang/" bjarni@2555: endif bjarni@2555: endif bjarni@2500: 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: bjarni@2672: ifdef MAX_NUM_AUTOSAVES bjarni@2672: CDEFS += -DMAX_NUM_AUTOSAVES=$(MAX_NUM_AUTOSAVES) bjarni@2672: endif bjarni@2672: truelight@0: ifdef WITH_NETWORK truelight@0: CDEFS += -DENABLE_NETWORK truelight@543: ifdef QNX truelight@543: LIBS += -lsocket truelight@543: 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@1692: LIBS += -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32 TrueLight@1692: ifdef WITH_DIRECTMUSIC TrueLight@1692: LIBS += -lstdc++ TrueLight@1692: endif truelight@0: TTDLDFLAGS += -Wl,--subsystem,windows truelight@0: endif truelight@0: pasky@1476: ifndef DEST_DIR pasky@1476: DEST_DIR = $(DESTDIR) pasky@1476: endif pasky@1476: 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) matthijs@2901: ICON_DIR_PREFIXED:=$(PREFIX)/$(ICON_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) matthijs@2901: ICON_DIR_INSTALL=$(DEST_DIR)/$(ICON_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: bjarni@2713: # clean up C_SOURCES first. Needed since building universal binaries on OSX calls the makefile recursively (just one time) tron@2735: SRCS := bjarni@2713: tron@2735: SRCS += aircraft_cmd.c tron@2735: SRCS += aircraft_gui.c tron@2735: SRCS += airport.c tron@2735: SRCS += airport_gui.c tron@2735: SRCS += aystar.c tron@2735: SRCS += bridge_gui.c tron@2735: SRCS += callback_table.c tron@2735: SRCS += clear_cmd.c tron@2735: SRCS += command.c tron@2735: SRCS += console.c tron@2735: SRCS += console_cmds.c tron@2735: SRCS += currency.c tron@2735: SRCS += debug.c tron@2735: SRCS += dedicated.c tron@2735: SRCS += depot.c tron@2735: SRCS += disaster_cmd.c tron@2735: SRCS += dock_gui.c tron@2735: SRCS += driver.c tron@2735: SRCS += dummy_land.c tron@2735: SRCS += economy.c tron@2735: SRCS += engine.c tron@2735: SRCS += engine_gui.c tron@2735: SRCS += fileio.c tron@2735: SRCS += gfx.c tron@2735: SRCS += gfxinit.c tron@2735: SRCS += graph_gui.c tron@2735: SRCS += industry_cmd.c tron@2735: SRCS += industry_gui.c tron@2735: SRCS += intro_gui.c tron@2735: SRCS += landscape.c tron@2735: SRCS += main_gui.c tron@2735: SRCS += map.c tron@2735: SRCS += md5.c tron@2735: SRCS += mersenne.c tron@2735: SRCS += minilzo.c tron@2735: SRCS += misc.c tron@2735: SRCS += misc_cmd.c tron@2735: SRCS += misc_gui.c tron@2735: SRCS += mixer.c tron@2735: SRCS += music_gui.c tron@2735: SRCS += namegen.c tron@2735: SRCS += network.c tron@2735: SRCS += network_client.c tron@2735: SRCS += network_data.c tron@2735: SRCS += network_gamelist.c tron@2735: SRCS += network_gui.c tron@2735: SRCS += network_server.c tron@2735: SRCS += network_udp.c tron@2735: SRCS += newgrf.c tron@2735: SRCS += news_gui.c tron@2735: SRCS += npf.c tron@2735: SRCS += oldloader.c tron@2735: SRCS += openttd.c tron@2735: SRCS += order_cmd.c tron@2735: SRCS += order_gui.c tron@2735: SRCS += pathfind.c tron@2735: SRCS += player_gui.c tron@2735: SRCS += players.c tron@2735: SRCS += pool.c tron@2735: SRCS += queue.c tron@2735: SRCS += rail.c tron@2735: SRCS += rail_cmd.c tron@2735: SRCS += rail_gui.c tron@2735: SRCS += rev.c tron@2735: SRCS += road_cmd.c tron@2735: SRCS += road_gui.c tron@2735: SRCS += roadveh_cmd.c tron@2735: SRCS += roadveh_gui.c tron@2735: SRCS += saveload.c tron@2735: SRCS += screenshot.c tron@2735: SRCS += settings.c tron@2735: SRCS += settings_gui.c tron@2735: SRCS += ship_cmd.c tron@2735: SRCS += ship_gui.c tron@2735: SRCS += signs.c tron@2735: SRCS += smallmap_gui.c tron@2735: SRCS += sound.c tron@2735: SRCS += sprite.c tron@2735: SRCS += spritecache.c tron@2735: SRCS += station_cmd.c tron@2735: SRCS += station_gui.c tron@2735: SRCS += station_newgrf.c tron@2735: SRCS += string.c tron@2735: SRCS += strings.c tron@2735: SRCS += subsidy_gui.c tron@2735: SRCS += terraform_gui.c tron@2735: SRCS += texteff.c tron@2735: SRCS += thread.c tron@2735: SRCS += tile.c tron@2735: SRCS += town_cmd.c tron@2735: SRCS += town_gui.c tron@2735: SRCS += train_cmd.c tron@2735: SRCS += train_gui.c tron@2735: SRCS += tree_cmd.c tron@2735: SRCS += tunnelbridge_cmd.c tron@2735: SRCS += unmovable_cmd.c tron@2735: SRCS += vehicle.c tron@2735: SRCS += vehicle_gui.c tron@2735: SRCS += viewport.c tron@2735: SRCS += water_cmd.c tron@2735: SRCS += waypoint.c tron@2735: SRCS += widget.c tron@2735: SRCS += window.c tron@2735: SRCS += music/null_m.c tron@2735: SRCS += sound/null_s.c tron@2735: SRCS += video/dedicated_v.c tron@2735: SRCS += video/null_v.c tron@677: truelight@2395: # AI related files tron@2735: SRCS += ai/ai.c tron@2735: SRCS += ai/default/default.c tron@2735: SRCS += ai/trolly/build.c tron@2735: SRCS += ai/trolly/pathfinder.c tron@2735: SRCS += ai/trolly/shared.c tron@2735: SRCS += ai/trolly/trolly.c bjarni@2188: Darkvater@1829: ifdef WITH_SDL tron@2735: SRCS += sdl.c tron@2735: SRCS += sound/sdl_s.c tron@2735: SRCS += video/sdl_v.c Darkvater@1829: endif Darkvater@1829: truelight@0: ifdef WIN32 tron@2735: SRCS += win32.c tron@2735: SRCS += music/win32_m.c tron@2735: SRCS += sound/win32_s.c tron@2735: SRCS += video/win32_v.c truelight@0: else tron@2735: SRCS += unix.c tron@2735: SRCS += music/extmidi.c truelight@0: endif truelight@0: bjarni@2188: ifdef OSX bjarni@2736: SRCS += os/macosx/macos.m bjarni@2736: ifndef DEDICATED bjarni@2736: SRCS += music/qtmidi.c bjarni@2736: endif bjarni@2736: ifdef WITH_COCOA bjarni@2736: SRCS += video/cocoa_v.m bjarni@2736: SRCS += sound/cocoa_s.c bjarni@2736: SRCS += os/macosx/splash.c bjarni@2736: endif bjarni@2500: endif bjarni@2188: tron@421: ifdef BEOS tron@2735: SRCS += music/bemidi.cpp tron@421: endif truelight@0: truelight@0: ifdef WIN32 tron@2742: SRCS += ottdres.rc truelight@0: endif truelight@0: truelight@0: ifdef WITH_DIRECTMUSIC tron@2735: SRCS += music/dmusic.cpp truelight@0: endif truelight@0: tron@2735: OBJS += $(filter %.o, $(SRCS:%.cpp=%.o) $(SRCS:%.m=%.o) $(SRCS:%.c=%.o) $(SRCS:%.rc=%.o)) tron@1170: DEPS = $(OBJS:%.o=.deps/%.d) truelight@0: truelight@0: LANG_TXT = $(filter-out %.unfinished.txt,$(wildcard lang/*.txt)) truelight@0: LANGS = $(LANG_TXT:%.txt=%.lng) truelight@0: bjarni@162: truelight@0: ############################################################################## truelight@0: # pasky@1413: # Build commands pasky@1413: # pasky@1413: tron@2369: # If we are verbose, we will show commands prefixed by $(Q). tron@2369: # The $(Q)s get replaced by @ in non-verbose mode. pasky@1413: # Inspired by the Linux kernel build system. pasky@1413: ifdef VERBOSE pasky@1413: Q = pasky@1413: else pasky@1413: Q = @ pasky@1413: endif pasky@1413: pasky@1413: pasky@1413: ############################################################################## pasky@1413: # truelight@0: # Targets truelight@0: # truelight@0: truelight@0: truelight@0: ### Normal build rules truelight@0: truelight@0: truelight@0: ifdef OSX bjarni@2713: # needs to be before all truelight@0: OSX:=OSX truelight@0: endif truelight@0: truelight@0: truelight@2576: all: endian_target.h endian_host.h $(UPDATECONFIG) $(LANGS) $(TTD) $(OSX) truelight@0: bjarni@2714: ifdef OSX bjarni@2714: -include os/macosx/Makefile bjarni@2714: endif bjarni@2714: truelight@1721: endian_host.h: $(ENDIAN_CHECK) truelight@1721: @echo '===> Testing endianness for host' truelight@1721: $(Q)./$(ENDIAN_CHECK) > $@ truelight@1721: truelight@1721: endian_target.h: $(ENDIAN_CHECK) truelight@1721: @echo '===> Testing endianness for target' TrueLight@1692: $(Q)./$(ENDIAN_CHECK) $(ENDIAN_FORCE) > $@ truelight@157: truelight@157: $(ENDIAN_CHECK): endian_check.c tron@2315: @echo '===> Compiling and Linking $@' tron@2315: $(Q)$(CC_HOST) $(CFLAGS_HOST) $(CDEFS) $< -o $@ darkvater@222: truelight@0: tron@2315: $(TTD): $(OBJS) $(MAKE_CONFIG) tron@2315: @echo '===> Linking $@' tron@2315: $(Q)$(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@ truelight@0: truelight@1721: $(STRGEN): strgen/strgen.c endian_host.h tron@2315: @echo '===> Compiling and Linking $@' tron@2315: $(Q)$(CC_HOST) $(CFLAGS_HOST) $(CDEFS) $< -o $@ truelight@0: tron@474: table/strings.h: lang/english.txt $(STRGEN) tron@1118: @echo '===> Generating $@' pasky@1413: $(Q)$(STRGEN) darkvater@222: tron@476: lang/%.lng: lang/%.txt $(STRGEN) lang/english.txt tron@1118: @echo '===> Compiling language $(*F)' tron@2106: $(Q)$(STRGEN) $(STRGEN_FLAGS) $< $(LANG_ERRORS) || rm -f $@ truelight@0: bjarni@770: ifdef MORPHOS bjarni@770: release: all pasky@1413: $(Q)rm -fr "/t/openttd-$(RELEASE)-morphos.lha" pasky@1413: $(Q)mkdir -p "/t/" pasky@1413: $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos" pasky@1413: $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/docs" pasky@1413: $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/data" pasky@1413: $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/lang" pasky@1413: $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/scenario" pasky@1413: $(Q)cp -R $(TTD) "/t/openttd-$(RELEASE)-morphos/" pasky@1413: $(Q)cp data/* "/t/openttd-$(RELEASE)-morphos/data/" pasky@1413: $(Q)cp lang/*.lng "/t/openttd-$(RELEASE)-morphos/lang/" pasky@1413: $(Q)cp scenario/* "/t/openttd-$(RELEASE)-morphos/scenario/" pasky@1413: $(Q)cp readme.txt "/t/openttd-$(RELEASE)-morphos/docs/ReadMe" pasky@1413: $(Q)cp docs/console.txt "/t/openttd-$(RELEASE)-morphos/docs/Console" pasky@1413: $(Q)cp COPYING "/t/openttd-$(RELEASE)-morphos/docs/" pasky@1413: $(Q)cp changelog.txt "/t/openttd-$(RELEASE)-morphos/docs/ChangeLog" pasky@1413: $(Q)cp known-bugs.txt "/t/openttd-$(RELEASE)-morphos/docs/known-bugs.txt" pasky@1413: $(Q)cp os/morphos/icons/openttd.info "/t/openttd-$(RELEASE)-morphos/$(TTD).info" pasky@1413: $(Q)cp os/morphos/icons/docs.info "/t/openttd-$(RELEASE)-morphos/docs.info" pasky@1413: $(Q)cp os/morphos/icons/drawer.info "/t/openttd-$(RELEASE)-morphos.info" pasky@1413: $(Q)cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/ReadMe.info" pasky@1413: $(Q)cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/Console.info" pasky@1413: $(Q)cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/COPYING.info" pasky@1413: $(Q)cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/ChangeLog.info" pasky@1413: $(Q)strip --strip-all --strip-unneeded --remove-section .comment "/t/openttd-$(RELEASE)-morphos/$(TTD)" pasky@1413: $(Q)lha a -r "t:openttd-$(RELEASE)-morphos.lha" "t:openttd-$(RELEASE)-morphos" pasky@1413: $(Q)lha a "t:openttd-$(RELEASE)-morphos.lha" "t:openttd-$(RELEASE)-morphos.info" pasky@1413: $(Q)rm -fr "/t/openttd-$(RELEASE)-morphos" pasky@1413: $(Q)rm -fr "/t/openttd-$(RELEASE)-morphos.info" bjarni@770: @echo "Release archive can be found in RAM:t/ now." bjarni@770: tron@1251: .PHONY: release bjarni@770: endif bjarni@770: 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: @# some additions for MorphOS versions tag truelight@0: @echo '#ifdef __MORPHOS__' >>rev.c.new Darkvater@2378: @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: tron@1118: @echo '===> Cleaning up' truelight@1721: # endian.h is out-dated and no longer in use, so it can be removed soon truelight@1721: $(Q)rm -rf .deps *~ $(TTD) $(STRGEN) core table/strings.h $(LANGS) $(OBJS) $(OSX_MIDI_PLAYER_FILE) endian.h endian_host.h endian_target.h $(ENDIAN_CHECK) truelight@0: truelight@0: mrproper: clean pasky@1413: $(Q)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\ pasky@1492: 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), ) pasky@1492: $(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),) pasky@1492: $(error no data path set - check Makefile.config) bjarni@285: endif bjarni@285: ifeq ($(BINARY_DIR),) pasky@1492: $(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 pasky@1491: install -d $(DATA_DIR_INSTALL)/lang \ pasky@1491: $(DATA_DIR_INSTALL)/data \ pasky@1491: $(DATA_DIR_INSTALL)/gm \ matthijs@9951: $(ICON_DIR_INSTALL) \ pasky@1491: $(BINARY_DIR_INSTALL) matthijs@1865: ifndef USE_HOMEDIR matthijs@1865: mkdir -p $(PERSONAL_DIR)/scenario matthijs@1865: else matthijs@1865: mkdir -p $(DATA_DIR_INSTALL)/scenario matthijs@1865: endif pasky@1491: install $(TTD) $(BINARY_DIR_INSTALL) pasky@1491: install -m 644 lang/*.lng $(DATA_DIR_INSTALL)/lang pasky@1491: install -m 644 data/*.grf $(DATA_DIR_INSTALL)/data pasky@1491: install -m 644 data/opntitle.dat $(DATA_DIR_INSTALL)/data matthijs@2901: install -m 644 media/openttd.64.png $(ICON_DIR_INSTALL) matthijs@2901: install -m 644 media/openttd.32.xpm $(ICON_DIR_INSTALL) matthijs@1865: ifndef USE_HOMEDIR bjarni@1160: cp scenario/* $(PERSONAL_DIR)/scenario/ matthijs@1865: else matthijs@1865: cp scenario/* $(DATA_DIR_INSTALL)/scenario/ matthijs@1865: endif 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@2576: .PHONY: clean all $(OSX) install 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) pasky@1413: $(Q)rm $(MAKE_CONFIG) pasky@1413: $(Q)$(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. tron@2792: DEPS_MAGIC := $(shell mkdir -p $(sort $(dir $(DEPS)))) tron@2792: tron@2792: depend: tron@2792: @true # The include handles this automagically truelight@0: truelight@0: # Introduce the dependencies tron@2792: ifeq ($(findstring $(MAKECMDGOALS), clean info),) tron@1167: -include $(DEPS) tron@2315: endif truelight@0: tron@2792: # Silence stale header dependency errors tron@2792: %.h: tron@2792: @true tron@1170: tron@2327: .deps/%.d: %.c $(MAKE_CONFIG) table/strings.h endian_target.h tron@2792: @echo '===> DEP $<' tron@2800: $(Q)$(CC) $(CFLAGS) $(CDEFS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:.deps/%.d=%.o):#' > $@ bjarni@2188: tron@2327: .deps/%.d: %.cpp $(MAKE_CONFIG) table/strings.h endian_target.h tron@2792: @echo '===> DEP $<' truelight@2918: $(Q)$(CXX) $(CFLAGS) $(CDEFS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:.deps/%.d=%.o):#' > $@ tron@2315: tron@2327: .deps/%.d: %.m $(MAKE_CONFIG) table/strings.h endian_target.h tron@2792: @echo '===> DEP $<' tron@2800: $(Q)$(CC) $(OBJCFLAGS) $(CDEFS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:.deps/%.d=%.o):#' > $@ tron@2315: tron@2315: tron@2315: %.o: %.c $(MAKE_CONFIG) tron@2315: @echo '===> Compiling $<' tron@2315: $(Q)$(CC) $(CFLAGS) $(CDEFS) -c -o $@ $< tron@2315: tron@2315: %.o: %.cpp $(MAKE_CONFIG) tron@2315: @echo '===> Compiling $<' tron@2315: $(Q)$(CXX) $(CFLAGS) $(CDEFS) -c -o $@ $< tron@2315: tron@2315: %.o: %.m $(MAKE_CONFIG) tron@2315: @echo '===> Compiling $<' tron@2317: $(Q)$(CC) $(CFLAGS) $(CDEFS) -c -o $@ $< tron@1163: tron@2742: %.o: %.rc tron@2742: @echo '===> Compiling resource $<' tron@2742: $(Q)$(WINDRES) -o $@ $< tron@2742: tron@1163: tron@1163: info: tron@1435: @echo 'CFLAGS = $(CFLAGS)' tron@1163: @echo 'LDFLAGS = $(LDFLAGS)' tron@1163: @echo 'LIBS = $(LIBS)' tron@2327: @echo 'CDEFS = $(CDEFS)'