(svn r27763) -Update from Eints:
[openttd.git] / Makefile.in
blobd33d8a0d2a45a94666480334f2af79e4184a200c
1 # $Id$
3 # This file is part of OpenTTD.
4 # 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.
5 # 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.
6 # 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/>.
8 # Check if we want to show what we are doing
9 ifdef VERBOSE
10 Q =
11 else
12 Q = @
13 endif
15 include Makefile.am
17 CONFIG_CACHE_PWD = !!CONFIG_CACHE_PWD!!
18 CONFIG_CACHE_SOURCE_LIST = !!CONFIG_CACHE_SOURCE_LIST!!
19 BIN_DIR = !!BIN_DIR!!
20 ICON_THEME_DIR = !!ICON_THEME_DIR!!
21 MAN_DIR = !!MAN_DIR!!
22 MENU_DIR = !!MENU_DIR!!
23 SRC_DIR = !!SRC_DIR!!
24 ROOT_DIR = !!ROOT_DIR!!
25 BUNDLE_DIR = "$(ROOT_DIR)/bundle"
26 BUNDLES_DIR = "$(ROOT_DIR)/bundles"
27 INSTALL_DIR = !!INSTALL_DIR!!
28 INSTALL_BINARY_DIR = "$(INSTALL_DIR)/"!!BINARY_DIR!!
29 INSTALL_MAN_DIR = "$(INSTALL_DIR)/$(MAN_DIR)"
30 INSTALL_MENU_DIR = "$(INSTALL_DIR)/$(MENU_DIR)"
31 INSTALL_ICON_DIR = "$(INSTALL_DIR)/"!!ICON_DIR!!
32 INSTALL_ICON_THEME_DIR = "$(INSTALL_DIR)/$(ICON_THEME_DIR)"
33 INSTALL_DATA_DIR = "$(INSTALL_DIR)/"!!DATA_DIR!!
34 INSTALL_DOC_DIR = "$(INSTALL_DIR)/"!!DOC_DIR!!
35 SOURCE_LIST = !!SOURCE_LIST!!
36 CONFIGURE_FILES = !!CONFIGURE_FILES!!
37 BINARY_NAME = !!BINARY_NAME!!
38 STRIP = !!STRIP!!
39 TTD = !!TTD!!
40 TTDS = $(SRC_DIRS:%=%/$(TTD))
41 OS = !!OS!!
42 OSXAPP = !!OSXAPP!!
43 LIPO = !!LIPO!!
44 AWK = !!AWK!!
45 SORT = !!SORT!!
46 DISTCC = !!DISTCC!!
48 RES := $(shell if [ ! -f $(CONFIG_CACHE_PWD) ] || [ "`pwd`" != "`cat $(CONFIG_CACHE_PWD)`" ]; then echo "`pwd`" > $(CONFIG_CACHE_PWD); fi )
49 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 )
51 all: config.pwd config.cache
52 ifdef DISTCC
53 @if [ -z "`echo '$(MFLAGS)' | grep '\-j'`" ]; then echo; echo "WARNING: you enabled distcc support, but you don't seem to be using the -jN paramter"; echo; fi
54 endif
55 @for dir in $(DIRS); do \
56 $(MAKE) -C $$dir all || exit 1; \
57 done
58 ifdef LIPO
59 # Lipo is an OSX thing. If it is defined, it means we are building for universal,
60 # and so we have have to combine the binaries into one big binary
62 # Remove the last binary made by the last compiled target
63 $(Q)rm -f $(BIN_DIR)/$(TTD)
64 # Make all the binaries into one
65 $(Q)$(LIPO) -create -output $(BIN_DIR)/$(TTD) $(TTDS)
66 endif
68 help:
69 @echo "Available make commands:"
70 @echo ""
71 @echo "Compilation:"
72 @echo " all compile the executable and the lang files"
73 @echo " lang compile the lang files only"
74 @echo "Clean up:"
75 @echo " clean remove the files generated during compilation"
76 @echo " mrproper remove the files generated during configuration and compilation"
77 @echo "Run after compilation:"
78 @echo " run execute openttd after the compilation"
79 @echo " run-gdb execute openttd in debug mode after the compilation"
80 @echo " run-prof execute openttd in profiling mode after the compilation"
81 @echo "Installation:"
82 @echo " install install the compiled files and the data-files after the compilation"
83 @echo " bundle create the base for an installation bundle"
84 @echo " bundle_zip create the zip installation bundle"
85 @echo " bundle_gzip create the gzip installation bundle"
86 @echo " bundle_bzip2 create the bzip2 installation bundle"
87 @echo " bundle_lha create the lha installation bundle"
88 @echo " bundle_dmg create the dmg installation bundle"
90 config.pwd: $(CONFIG_CACHE_PWD)
91 $(MAKE) reconfigure
93 config.cache: $(CONFIG_CACHE_SOURCE_LIST) $(CONFIGURE_FILES)
94 $(MAKE) reconfigure
96 reconfigure:
97 ifeq ($(shell if test -f config.cache; then echo 1; fi), 1)
98 @echo "----------------"
99 @echo "The system detected that source.list or any configure file is altered."
100 @echo " Going to reconfigure with last known settings..."
101 @echo "----------------"
102 # Make sure we don't lock config.cache
103 @$(shell cat config.cache | sed 's@\\ @\\\\ @g') || exit 1
104 @echo "----------------"
105 @echo "Reconfig done. Please re-execute make."
106 @echo "----------------"
107 else
108 @echo "----------------"
109 @echo "Have not found a configuration, please run configure first."
110 @echo "----------------"
111 @exit 1
112 endif
114 clean:
115 @for dir in $(DIRS); do \
116 $(MAKE) -C $$dir clean; \
117 done
118 $(Q)rm -rf $(BUNDLE_TARGET)
120 lang:
121 @for dir in $(LANG_DIRS); do \
122 $(MAKE) -C $$dir all; \
123 done
125 mrproper:
126 @for dir in $(DIRS); do \
127 $(MAKE) -C $$dir mrproper; \
128 done
129 # Don't be tempted to merge these two for loops. Doing that breaks make
130 # --dry-run, since make has this "feature" that it always runs commands
131 # containing $(MAKE), even when --dry-run is passed. The objective is of
132 # course to also get a dry-run of submakes, but make is not smart enough
133 # to see that a for loop runs both a submake and an actual command.
134 @for dir in $(DIRS); do \
135 rm -f $$dir/Makefile; \
136 done
137 $(Q)rm -rf objs
138 $(Q)rm -f Makefile Makefile.am Makefile.bundle
139 $(Q)rm -f media/openttd.desktop media/openttd.desktop.install
140 $(Q)rm -f $(CONFIG_CACHE_SOURCE_LIST) config.cache config.pwd config.log $(CONFIG_CACHE_PWD)
141 # directories for bundle generation
142 $(Q)rm -rf $(BUNDLE_DIR)
143 $(Q)rm -rf $(BUNDLES_DIR)
144 # output of profiling
145 $(Q)rm -f $(BIN_DIR)/gmon.out
146 # output of generating 'API' documentation
147 $(Q)rm -rf $(ROOT_DIR)/docs/source
148 $(Q)rm -rf $(ROOT_DIR)/docs/aidocs
149 $(Q)rm -rf $(ROOT_DIR)/docs/gamedocs
150 # directories created by OpenTTD on regression testing
151 $(Q)rm -rf $(BIN_DIR)/ai/regression/content_download $(BIN_DIR)/ai/regression/save $(BIN_DIR)/ai/regression/scenario
152 distclean: mrproper
154 maintainer-clean: distclean
155 $(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
157 depend:
158 @for dir in $(SRC_DIRS); do \
159 $(MAKE) -C $$dir depend; \
160 done
162 run: all
163 $(Q)cd !!BIN_DIR!! && ./!!TTD!! $(OPENTTD_ARGS)
165 run-gdb: all
166 $(Q)cd !!BIN_DIR!! && gdb --ex run --args ./!!TTD!! $(OPENTTD_ARGS)
168 run-prof: all
169 $(Q)cd !!BIN_DIR!! && ./!!TTD!! $(OPENTTD_ARGS) && gprof !!TTD!! | less
171 regression: all
172 $(Q)cd !!BIN_DIR!! && sh ai/regression/run.sh
173 test: regression
175 %.o:
176 @for dir in $(SRC_DIRS); do \
177 $(MAKE) -C $$dir $(@:src/%=%); \
178 done
180 %.lng:
181 @for dir in $(LANG_DIRS); do \
182 $(MAKE) -C $$dir $@; \
183 done
185 .PHONY: test distclean mrproper clean
187 include Makefile.bundle