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
17 CONFIG_CACHE_PWD
= !!CONFIG_CACHE_PWD
!!
18 CONFIG_CACHE_SOURCE_LIST
= !!CONFIG_CACHE_SOURCE_LIST
!!
20 ICON_THEME_DIR
= !!ICON_THEME_DIR
!!
22 MENU_DIR
= !!MENU_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
!!
40 TTDS
= $(SRC_DIRS
:%=%/$(TTD
))
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
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
55 @for
dir in
$(DIRS
); do \
56 $(MAKE
) -C
$$dir all || exit
1; \
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
)
69 @echo
"Available make commands:"
72 @echo
" all compile the executable and the lang files"
73 @echo
" lang compile the lang files only"
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"
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
)
93 config.cache
: $(CONFIG_CACHE_SOURCE_LIST
) $(CONFIGURE_FILES
)
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
"----------------"
108 @echo
"----------------"
109 @echo
"Have not found a configuration, please run configure first."
110 @echo
"----------------"
115 @for
dir in
$(DIRS
); do \
116 $(MAKE
) -C
$$dir clean; \
118 $(Q
)rm -rf
$(BUNDLE_TARGET
)
121 @for
dir in
$(LANG_DIRS
); do \
122 $(MAKE
) -C
$$dir all; \
126 @for
dir in
$(DIRS
); do \
127 $(MAKE
) -C
$$dir mrproper
; \
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
; \
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 -f
$(ROOT_DIR
)/openttd.tag
148 $(Q
)rm -rf
$(ROOT_DIR
)/docs
/source
149 # output of generating AI API documentation
150 $(Q
)rm -f
$(SRC_DIR
)/ai
/api
/openttd.tag
151 $(Q
)rm -rf
$(ROOT_DIR
)/docs
/aidocs
152 # directories created by OpenTTD on regression testing
153 $(Q
)rm -rf
$(BIN_DIR
)/ai
/regression
/content_download
$(BIN_DIR
)/ai
/regression
/save
$(BIN_DIR
)/ai
/regression
/scenario
156 maintainer-clean
: distclean
157 $(Q
)rm -f
$(BIN_DIR
)/baseset
/openttd.grf
160 @for
dir in
$(SRC_DIRS
); do \
161 $(MAKE
) -C
$$dir depend
; \
165 $(Q
)cd
!!BIN_DIR
!! && .
/!!TTD
!! $(OPENTTD_ARGS
)
168 $(Q
)cd
!!BIN_DIR
!! && gdb
--ex run
--args .
/!!TTD
!! $(OPENTTD_ARGS
)
171 $(Q
)cd
!!BIN_DIR
!! && .
/!!TTD
!! $(OPENTTD_ARGS
) && gprof
!!TTD
!! | less
174 $(Q
)cd
!!BIN_DIR
!! && sh ai
/regression
/run.sh
178 @for
dir in
$(SRC_DIRS
); do \
179 $(MAKE
) -C
$$dir $(@
:src
/%=%); \
183 @for
dir in
$(LANG_DIRS
); do \
184 $(MAKE
) -C
$$dir $@
; \
187 .PHONY
: test distclean mrproper
clean
189 include Makefile.bundle