1 # This file is part of OpenTTD.
2 # 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.
3 # 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.
4 # 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/>.
6 # Check if we want to show what we are doing
15 CONFIG_CACHE_PWD
= !!CONFIG_CACHE_PWD
!!
16 CONFIG_CACHE_SOURCE_LIST
= !!CONFIG_CACHE_SOURCE_LIST
!!
18 ICON_THEME_DIR
= !!ICON_THEME_DIR
!!
20 MENU_DIR
= !!MENU_DIR
!!
22 ROOT_DIR
= !!ROOT_DIR
!!
23 BUNDLE_DIR
= "$(ROOT_DIR)/bundle"
24 BUNDLES_DIR
= "$(ROOT_DIR)/bundles"
25 INSTALL_DIR
= !!INSTALL_DIR
!!
26 INSTALL_BINARY_DIR
= "$(INSTALL_DIR)/"!!BINARY_DIR
!!
27 INSTALL_MAN_DIR
= "$(INSTALL_DIR)/$(MAN_DIR)"
28 INSTALL_MENU_DIR
= "$(INSTALL_DIR)/$(MENU_DIR)"
29 INSTALL_ICON_DIR
= "$(INSTALL_DIR)/"!!ICON_DIR
!!
30 INSTALL_ICON_THEME_DIR
= "$(INSTALL_DIR)/$(ICON_THEME_DIR)"
31 INSTALL_DATA_DIR
= "$(INSTALL_DIR)/"!!DATA_DIR
!!
32 INSTALL_DOC_DIR
= "$(INSTALL_DIR)/"!!DOC_DIR
!!
33 SOURCE_LIST
= !!SOURCE_LIST
!!
34 CONFIGURE_FILES
= !!CONFIGURE_FILES
!!
35 BINARY_NAME
= !!BINARY_NAME
!!
38 TTDS
= $(SRC_DIRS
:%=%/$(TTD
))
46 RES
:= $(shell if
[ ! -f
$(CONFIG_CACHE_PWD
) ] ||
[ "`pwd`" != "`cat $(CONFIG_CACHE_PWD)`" ]; then echo
"`pwd`" > $(CONFIG_CACHE_PWD
); fi
)
47 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
)
49 all: config.pwd config.cache
51 @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
53 @for
dir in
$(DIRS
); do \
54 $(MAKE
) -C
$$dir all || exit
1; \
57 # Lipo is an OSX thing. If it is defined, it means we are building for universal,
58 # and so we have have to combine the binaries into one big binary
60 # Remove the last binary made by the last compiled target
61 $(Q
)rm -f
$(BIN_DIR
)/$(TTD
)
62 # Make all the binaries into one
63 $(Q
)$(LIPO
) -create
-output
$(BIN_DIR
)/$(TTD
) $(TTDS
)
67 @echo
"Available make commands:"
70 @echo
" all compile the executable and the lang files"
71 @echo
" lang compile the lang files only"
73 @echo
" clean remove the files generated during compilation"
74 @echo
" mrproper remove the files generated during configuration and compilation"
75 @echo
"Run after compilation:"
76 @echo
" run execute openttd after the compilation"
77 @echo
" run-gdb execute openttd in debug mode after the compilation"
78 @echo
" run-prof execute openttd in profiling mode after the compilation"
80 @echo
" install install the compiled files and the data-files after the compilation"
81 @echo
" bundle create the base for an installation bundle"
82 @echo
" bundle_zip create the zip installation bundle"
83 @echo
" bundle_gzip create the gzip installation bundle"
84 @echo
" bundle_bzip2 create the bzip2 installation bundle"
85 @echo
" bundle_lha create the lha installation bundle"
86 @echo
" bundle_dmg create the dmg installation bundle"
88 config.pwd
: $(CONFIG_CACHE_PWD
)
91 config.cache
: $(CONFIG_CACHE_SOURCE_LIST
) $(CONFIGURE_FILES
)
95 ifeq ($(shell if
test -f config.cache
; then echo
1; fi
), 1)
96 @echo
"----------------"
97 @echo
"The system detected that source.list or any configure file is altered."
98 @echo
" Going to reconfigure with last known settings..."
99 @echo
"----------------"
100 # Make sure we don't lock config.cache
101 @
$(shell cat config.cache | sed
's@\\ @\\\\ @g') || exit
1
102 @echo
"----------------"
103 @echo
"Reconfig done. Please re-execute make."
104 @echo
"----------------"
106 @echo
"----------------"
107 @echo
"Have not found a configuration, please run configure first."
108 @echo
"----------------"
113 @for
dir in
$(DIRS
); do \
114 $(MAKE
) -C
$$dir clean; \
116 $(Q
)rm -rf
$(BUNDLE_TARGET
)
119 @for
dir in
$(LANG_DIRS
); do \
120 $(MAKE
) -C
$$dir all; \
124 @for
dir in
$(DIRS
); do \
125 $(MAKE
) -C
$$dir mrproper
; \
127 # Don't be tempted to merge these two for loops. Doing that breaks make
128 # --dry-run, since make has this "feature" that it always runs commands
129 # containing $(MAKE), even when --dry-run is passed. The objective is of
130 # course to also get a dry-run of submakes, but make is not smart enough
131 # to see that a for loop runs both a submake and an actual command.
132 @for
dir in
$(DIRS
); do \
133 rm -f
$$dir/Makefile
; \
136 $(Q
)rm -f Makefile Makefile.am Makefile.bundle
137 $(Q
)rm -f media
/openttd.desktop media
/openttd.desktop.
install
138 $(Q
)rm -f
$(CONFIG_CACHE_SOURCE_LIST
) config.cache config.pwd config.log
$(CONFIG_CACHE_PWD
)
139 # directories for bundle generation
140 $(Q
)rm -rf
$(BUNDLE_DIR
)
141 $(Q
)rm -rf
$(BUNDLES_DIR
)
142 # output of profiling
143 $(Q
)rm -f
$(BIN_DIR
)/gmon.out
144 # output of generating 'API' documentation
145 $(Q
)rm -rf
$(ROOT_DIR
)/docs
/source
146 $(Q
)rm -rf
$(ROOT_DIR
)/docs
/aidocs
147 $(Q
)rm -rf
$(ROOT_DIR
)/docs
/gamedocs
148 # directories created by OpenTTD on regression testing
149 $(Q
)rm -rf
$(BIN_DIR
)/ai
/regression
/content_download
$(BIN_DIR
)/ai
/regression
/save
$(BIN_DIR
)/ai
/regression
/scenario
152 maintainer-clean
: distclean
153 $(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
156 @for
dir in
$(SRC_DIRS
); do \
157 $(MAKE
) -C
$$dir depend
; \
161 $(Q
)cd
!!BIN_DIR
!! && .
/!!TTD
!! $(OPENTTD_ARGS
)
164 $(Q
)cd
!!BIN_DIR
!! && gdb
--ex run
--args .
/!!TTD
!! $(OPENTTD_ARGS
)
167 $(Q
)cd
!!BIN_DIR
!! && .
/!!TTD
!! $(OPENTTD_ARGS
) && gprof
!!TTD
!! | less
170 $(Q
)cd
!!BIN_DIR
!! && sh ai
/regression
/run.sh
174 @for
dir in
$(SRC_DIRS
); do \
175 $(MAKE
) -C
$$dir $(@
:src
/%=%); \
179 @for
dir in
$(LANG_DIRS
); do \
180 $(MAKE
) -C
$$dir $@
; \
183 .PHONY
: test distclean mrproper
clean
185 include Makefile.bundle