2009-08-21 20:21:05 +00:00
# This file is part of OpenTTD.
# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
2007-01-02 19:19:48 +00:00
# Check if we want to show what we are doing
i f d e f V E R B O S E
Q =
e l s e
Q = @
e n d i f
i n c l u d e M a k e f i l e . a m
2009-09-07 13:33:45 +00:00
CONFIG_CACHE_PWD = !!CONFIG_CACHE_PWD!!
2007-01-02 19:19:48 +00:00
CONFIG_CACHE_SOURCE_LIST = !!CONFIG_CACHE_SOURCE_LIST!!
2009-09-07 13:33:45 +00:00
BIN_DIR = !!BIN_DIR!!
2008-07-23 15:37:20 +00:00
ICON_THEME_DIR = !!ICON_THEME_DIR!!
2009-09-07 13:33:45 +00:00
MAN_DIR = !!MAN_DIR!!
MENU_DIR = !!MENU_DIR!!
SRC_DIR = !!SRC_DIR!!
ROOT_DIR = !!ROOT_DIR!!
BUNDLE_DIR = " $( ROOT_DIR) /bundle "
BUNDLES_DIR = " $( ROOT_DIR) /bundles "
INSTALL_DIR = !!INSTALL_DIR!!
INSTALL_BINARY_DIR = " $( INSTALL_DIR) / " !!BINARY_DIR!!
INSTALL_MAN_DIR = " $( INSTALL_DIR) / $( MAN_DIR) "
INSTALL_MENU_DIR = " $( INSTALL_DIR) / $( MENU_DIR) "
INSTALL_ICON_DIR = " $( INSTALL_DIR) / " !!ICON_DIR!!
2008-07-23 15:37:20 +00:00
INSTALL_ICON_THEME_DIR = " $( INSTALL_DIR) / $( ICON_THEME_DIR) "
2009-09-07 13:33:45 +00:00
INSTALL_DATA_DIR = " $( INSTALL_DIR) / " !!DATA_DIR!!
INSTALL_DOC_DIR = " $( INSTALL_DIR) / " !!DOC_DIR!!
SOURCE_LIST = !!SOURCE_LIST!!
CONFIGURE_FILES = !!CONFIGURE_FILES!!
2008-10-16 11:12:18 +00:00
BINARY_NAME = !!BINARY_NAME!!
2009-09-07 13:33:45 +00:00
STRIP = !!STRIP!!
TTD = !!TTD!!
TTDS = $( SRC_DIRS:%= %/$( TTD) )
OS = !!OS!!
OSXAPP = !!OSXAPP!!
LIPO = !!LIPO!!
AWK = !!AWK!!
2010-05-22 19:59:37 +00:00
SORT = !!SORT!!
2009-09-07 13:33:45 +00:00
DISTCC = !!DISTCC!!
2007-01-02 19:19:48 +00:00
2008-09-02 16:28:31 +00:00
RES := $( shell if [ ! -f $( CONFIG_CACHE_PWD) ] || [ "`pwd`" != " `cat $( CONFIG_CACHE_PWD) ` " ] ; then echo "`pwd`" > $( CONFIG_CACHE_PWD) ; fi )
RES := $( shell if [ ! -f $( CONFIG_CACHE_SOURCE_LIST) ] || [ -n " `cmp $( CONFIG_CACHE_SOURCE_LIST) $( SOURCE_LIST) 2>/dev/null` " ] ; then cp $( SOURCE_LIST) $( CONFIG_CACHE_SOURCE_LIST) ; fi )
2007-01-02 19:19:48 +00:00
2008-09-02 16:28:31 +00:00
all : config .pwd config .cache
2007-06-27 18:53:24 +00:00
i f d e f D I S T C C
2019-09-29 20:27:32 +00:00
@if [ -z " `echo ' $( MFLAGS) ' | grep '\-j'` " ] ; then echo; echo "WARNING: you enabled distcc support, but you don't seem to be using the -jN parameter" ; echo; fi
2007-06-27 18:53:24 +00:00
e n d i f
@for dir in $( DIRS) ; do \
2010-08-14 14:50:06 +00:00
$( MAKE) -C $$ dir all || exit 1; \
2007-06-27 18:53:24 +00:00
done
i f d e f L I P O
# Lipo is an OSX thing. If it is defined, it means we are building for universal,
# and so we have have to combine the binaries into one big binary
# Remove the last binary made by the last compiled target
$( Q) rm -f $( BIN_DIR) /$( TTD)
# Make all the binaries into one
$( Q) $( LIPO) -create -output $( BIN_DIR) /$( TTD) $( TTDS)
e n d i f
2007-06-27 18:50:18 +00:00
help :
@echo "Available make commands:"
@echo ""
@echo "Compilation:"
@echo " all compile the executable and the lang files"
@echo " lang compile the lang files only"
@echo "Clean up:"
@echo " clean remove the files generated during compilation"
@echo " mrproper remove the files generated during configuration and compilation"
@echo "Run after compilation:"
@echo " run execute openttd after the compilation"
@echo " run-gdb execute openttd in debug mode after the compilation"
@echo " run-prof execute openttd in profiling mode after the compilation"
@echo "Installation:"
@echo " install install the compiled files and the data-files after the compilation"
@echo " bundle create the base for an installation bundle"
@echo " bundle_zip create the zip installation bundle"
@echo " bundle_gzip create the gzip installation bundle"
@echo " bundle_bzip2 create the bzip2 installation bundle"
@echo " bundle_lha create the lha installation bundle"
@echo " bundle_dmg create the dmg installation bundle"
2008-09-02 16:28:31 +00:00
config.pwd : $( CONFIG_CACHE_PWD )
$( MAKE) reconfigure
2007-01-02 19:19:48 +00:00
config.cache : $( CONFIG_CACHE_SOURCE_LIST ) $( CONFIGURE_FILES )
2008-09-02 16:28:31 +00:00
$( MAKE) reconfigure
reconfigure :
2007-01-02 19:19:48 +00:00
i f e q ( $( shell if test -f config .cache ; then echo 1; fi ) , 1 )
@echo "----------------"
@echo "The system detected that source.list or any configure file is altered."
@echo " Going to reconfigure with last known settings..."
@echo "----------------"
# Make sure we don't lock config.cache
2009-05-16 12:36:33 +00:00
@$( shell cat config.cache | sed 's@\\ @\\\\ @g' ) || exit 1
2007-01-02 19:19:48 +00:00
@echo "----------------"
2008-09-02 16:28:31 +00:00
@echo "Reconfig done. Please re-execute make."
2007-01-02 19:19:48 +00:00
@echo "----------------"
e l s e
@echo "----------------"
@echo "Have not found a configuration, please run configure first."
@echo "----------------"
@exit 1
e n d i f
clean :
@for dir in $( DIRS) ; do \
$( MAKE) -C $$ dir clean; \
done
$( Q) rm -rf $( BUNDLE_TARGET)
lang :
@for dir in $( LANG_DIRS) ; do \
$( MAKE) -C $$ dir all; \
done
mrproper :
@for dir in $( DIRS) ; do \
$( MAKE) -C $$ dir mrproper; \
2012-02-07 09:57:08 +00:00
done
# Don't be tempted to merge these two for loops. Doing that breaks make
# --dry-run, since make has this "feature" that it always runs commands
# containing $(MAKE), even when --dry-run is passed. The objective is of
# course to also get a dry-run of submakes, but make is not smart enough
# to see that a for loop runs both a submake and an actual command.
@for dir in $( DIRS) ; do \
2007-01-02 19:19:48 +00:00
rm -f $$ dir/Makefile; \
done
$( Q) rm -rf objs
2008-09-02 15:34:38 +00:00
$( Q) rm -f Makefile Makefile.am Makefile.bundle
2010-02-05 16:20:04 +00:00
$( Q) rm -f media/openttd.desktop media/openttd.desktop.install
2008-09-02 16:28:31 +00:00
$( Q) rm -f $( CONFIG_CACHE_SOURCE_LIST) config.cache config.pwd config.log $( CONFIG_CACHE_PWD)
2010-02-05 16:20:04 +00:00
# directories for bundle generation
2007-01-02 19:19:48 +00:00
$( Q) rm -rf $( BUNDLE_DIR)
$( Q) rm -rf $( BUNDLES_DIR)
2010-02-05 16:20:04 +00:00
# output of profiling
$( Q) rm -f $( BIN_DIR) /gmon.out
# output of generating 'API' documentation
$( Q) rm -rf $( ROOT_DIR) /docs/source
$( Q) rm -rf $( ROOT_DIR) /docs/aidocs
2013-07-13 06:44:22 +00:00
$( Q) rm -rf $( ROOT_DIR) /docs/gamedocs
2010-02-05 16:20:04 +00:00
# directories created by OpenTTD on regression testing
$( Q) rm -rf $( BIN_DIR) /ai/regression/content_download $( BIN_DIR) /ai/regression/save $( BIN_DIR) /ai/regression/scenario
distclean : mrproper
2007-01-02 19:19:48 +00:00
2010-09-05 21:50:59 +00:00
maintainer-clean : distclean
2017-01-14 15:48:19 +00:00
$( Q) rm -f $( BIN_DIR) /baseset/openttd.grf $( BIN_DIR) /baseset/orig_extra.grf $( BIN_DIR) /baseset/*.obg $( BIN_DIR) /baseset/*.obs $( BIN_DIR) /baseset/*.obm
2010-09-05 21:50:59 +00:00
2007-01-02 19:19:48 +00:00
depend :
@for dir in $( SRC_DIRS) ; do \
$( MAKE) -C $$ dir depend; \
done
run : all
2007-03-08 12:40:45 +00:00
$( Q) cd !!BIN_DIR!! && ./!!TTD!! $( OPENTTD_ARGS)
2007-01-02 19:19:48 +00:00
2007-03-15 13:17:54 +00:00
run-gdb : all
$( Q) cd !!BIN_DIR!! && gdb --ex run --args ./!!TTD!! $( OPENTTD_ARGS)
2007-06-08 17:54:48 +00:00
run-prof : all
$( Q) cd !!BIN_DIR!! && ./!!TTD!! $( OPENTTD_ARGS) && gprof !!TTD!! | less
2009-01-12 17:11:45 +00:00
regression : all
$( Q) cd !!BIN_DIR!! && sh ai/regression/run.sh
2010-02-05 16:20:04 +00:00
test : regression
2009-01-12 17:11:45 +00:00
2007-01-02 19:19:48 +00:00
%.o :
@for dir in $( SRC_DIRS) ; do \
2007-01-06 22:58:01 +00:00
$( MAKE) -C $$ dir $( @:src/%= %) ; \
2007-01-02 19:19:48 +00:00
done
%.lng :
@for dir in $( LANG_DIRS) ; do \
$( MAKE) -C $$ dir $@ ; \
done
2010-02-05 16:20:04 +00:00
.PHONY : test distclean mrproper clean
2008-08-15 11:58:15 +00:00
i n c l u d e M a k e f i l e . b u n d l e