Files @ r23774:59b54c2b48f6
Branch filter:

Location: cpp/openttd-patchpack/source/Makefile.src.in - annotation

Niels Martin Hansen
Change: Limit in-editor warnings in VS 2019

The AllRules ruleset causes the VS 2019 editor to litter warning squiggles all over the place, about things that would never be fixed. Limit it to the smallest ruleset available. Warnings shown now mainly concern potential arithmetic overflows.
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12960:22590457aed1
r12960:22590457aed1
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r17424:86055418d01f
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r12951:0cd9683b75be
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5941:09e955ca9251
r5475:3f5cd13d1b63
r5941:09e955ca9251
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r22836:7ecb38ec6e8e
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r17424:86055418d01f
r17431:9cebd3c06e25
r14500:437319d09620
r14500:437319d09620
r14500:437319d09620
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5610:703a9e6a9c45
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r10085:5185635441a9
r10085:5185635441a9
r10085:5185635441a9
r10091:1b45da6e3444
r9457:ecfeb802c57a
r10085:5185635441a9
r22791:414bb6dc82f3
r22791:414bb6dc82f3
r23295:4b549b966442
r23312:bc9643b48a23
r23395:4086e419f0ab
r6812:2b2e29b47062
r22791:414bb6dc82f3
r22791:414bb6dc82f3
r22791:414bb6dc82f3
r9765:c3e5347475e9
r22791:414bb6dc82f3
r22791:414bb6dc82f3
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r18351:542adacdaa0f
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5587:034e5e185dc2
r22791:414bb6dc82f3
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r22836:7ecb38ec6e8e
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r12736:5e34acd4fb85
r12736:5e34acd4fb85
r12736:5e34acd4fb85
r12736:5e34acd4fb85
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r18351:542adacdaa0f
r5475:3f5cd13d1b63
r5941:09e955ca9251
r5941:09e955ca9251
r23585:0208f1ed780c
r5475:3f5cd13d1b63
r5478:085917b9fb9b
r13887:657b67d5b221
r5478:085917b9fb9b
r5478:085917b9fb9b
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r22836:7ecb38ec6e8e
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r11902:1d7b999e8b04
r11902:1d7b999e8b04
r11902:1d7b999e8b04
r11902:1d7b999e8b04
r18351:542adacdaa0f
r11902:1d7b999e8b04
r11902:1d7b999e8b04
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r23163:4fe2df111fb0
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r11902:1d7b999e8b04
r5475:3f5cd13d1b63
r12031:c8f1248b280d
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r23163:4fe2df111fb0
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r6081:185aed7a2254
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r12008:976162879be1
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r11004:c3324735a1cb
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r22363:fb80f5d6c1ba
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r10696:8dfe83e30d01
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r10696:8dfe83e30d01
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r12736:5e34acd4fb85
r12736:5e34acd4fb85
r12736:5e34acd4fb85
r12736:5e34acd4fb85
r21109:b9fde9f27123
r5475:3f5cd13d1b63
r18351:542adacdaa0f
r5475:3f5cd13d1b63
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r21109:b9fde9f27123
r5941:09e955ca9251
r5941:09e955ca9251
r23585:0208f1ed780c
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r23206:57613cba3143
r5475:3f5cd13d1b63
r5610:703a9e6a9c45
r18079:b942dd7f3de8
r18079:b942dd7f3de8
r18374:ea9fdd784480
r18079:b942dd7f3de8
r18082:511b09ab8219
r18374:ea9fdd784480
r18082:511b09ab8219
r5610:703a9e6a9c45
r7564:3b7ac73c8322
r5475:3f5cd13d1b63
r16917:d6808c2ce4e9
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r16862:22a22a8e90c5
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r7564:3b7ac73c8322
r23395:4086e419f0ab
r5475:3f5cd13d1b63
r12836:aa53aa9303d2
r23395:4086e419f0ab
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r22836:7ecb38ec6e8e
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r12836:aa53aa9303d2
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5970:1ccb377ec8de
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
# $Id$

# 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/>.

CC_HOST        = !!CC_HOST!!
CXX_HOST       = !!CXX_HOST!!
CC_BUILD       = !!CC_BUILD!!
CXX_BUILD      = !!CXX_BUILD!!
WINDRES        = !!WINDRES!!
STRIP          = !!STRIP!!
CFLAGS         = !!CFLAGS!!
CFLAGS_BUILD   = !!CFLAGS_BUILD!!
CXXFLAGS       = !!CXXFLAGS!!
CXXFLAGS_BUILD = !!CXXFLAGS_BUILD!!
LIBS           = !!LIBS!!
LDFLAGS        = !!LDFLAGS!!
LDFLAGS_BUILD  = !!LDFLAGS_BUILD!!
ROOT_DIR       = !!ROOT_DIR!!
BIN_DIR        = !!BIN_DIR!!
LANG_DIR       = !!LANG_DIR!!
SRC_OBJS_DIR   = !!SRC_OBJS_DIR!!
LANG_OBJS_DIR  = !!LANG_OBJS_DIR!!
SETTING_OBJS_DIR= !!SETTING_OBJS_DIR!!
SRC_DIR        = !!SRC_DIR!!
SCRIPT_SRC_DIR = !!SCRIPT_SRC_DIR!!
MEDIA_DIR      = !!MEDIA_DIR!!
TTD            = !!TTD!!
STRGEN         = !!STRGEN!!
DEPEND         = !!DEPEND!!
OS             = !!OS!!
STAGE          = !!STAGE!!
MAKEDEPEND     = !!MAKEDEPEND!!
CFLAGS_MAKEDEP = !!CFLAGS_MAKEDEP!!
SORT           = !!SORT!!
AWK            = !!AWK!!
CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!!
CONFIG_CACHE_LINKER   = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!!
CONFIG_CACHE_SOURCE   = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_SOURCE!!
CONFIG_CACHE_VERSION  = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_VERSION!!

OBJS_C   := !!OBJS_C!!
OBJS_CPP := !!OBJS_CPP!!
OBJS_MM  := !!OBJS_MM!!
OBJS_RC  := !!OBJS_RC!!
OBJS     := $(OBJS_C) $(OBJS_CPP) $(OBJS_MM) $(OBJS_RC)
SRCS     := !!SRCS!!

# All C-files depend on those 3 files
FILE_DEP := $(CONFIG_CACHE_COMPILER)
# Create all dirs and subdirs
RES      := $(shell mkdir -p $(BIN_DIR) $(sort $(dir $(OBJS))))

CFLAGS += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SETTING_OBJS_DIR)
CFLAGS_MAKEDEP += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SETTING_OBJS_DIR)
ifdef SCRIPT_SRC_DIR
	CFLAGS_MAKEDEP += -I $(SCRIPT_SRC_DIR)
endif

# Check if we want to show what we are doing
ifdef VERBOSE
	Q =
	E = @true
else
	Q = @
	E = @echo
endif

# Our default target
all: $(BIN_DIR)/$(TTD)

# This are 2 rules that are pointing back to STRGEN stuff.
#  There is not really a need to have them here, but in case
#  some weirdo wants to run 'make' in the 'src' dir and expects
#  the languages to be recompiled, this catches that case and
#  takes care of it nicely.
$(LANG_OBJS_DIR)/$(STRGEN):
	$(MAKE) -C $(LANG_OBJS_DIR) $(STRGEN)

$(LANG_OBJS_DIR)/table/strings.h: $(LANG_DIR)/english.txt $(LANG_OBJS_DIR)/$(STRGEN)
	$(MAKE) -C $(LANG_OBJS_DIR) table/strings.h

# Always run version detection, so we always have an accurate modified
# flag
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d'	')

# Use autodetected revisions
VERSION  := $(shell echo "$(VERSIONS)" | cut -f 1 -d'	')
ISODATE  := $(shell echo "$(VERSIONS)" | cut -f 2 -d'	')
GITHASH  := $(shell echo "$(VERSIONS)" | cut -f 4 -d'	')
ISTAG    := $(shell echo "$(VERSIONS)" | cut -f 5 -d'	')
ISSTABLETAG := $(shell echo "$(VERSIONS)" | cut -f 6 -d'	')

# Make sure we have something in VERSION and ISODATE
ifeq ($(VERSION),)
VERSION := norev000
endif
ifeq ($(ISODATE),)
ISODATE := 00000000
endif

# This helps to recompile if flags change
RES := $(shell if [ "`cat $(CONFIG_CACHE_COMPILER) 2>/dev/null`" != "$(CFLAGS) $(CXXFLAGS)" ]; then echo "$(CFLAGS) $(CXXFLAGS)" > $(CONFIG_CACHE_COMPILER); fi )
RES := $(shell if [ "`cat $(CONFIG_CACHE_LINKER) 2>/dev/null`" != "$(LDFLAGS) $(LIBS)" ]; then echo "$(LDFLAGS) $(LIBS)" > $(CONFIG_CACHE_LINKER); fi )

# If there is a change in the source-file-list, make sure we recheck the deps
RES := $(shell if [ "`cat $(CONFIG_CACHE_SOURCE) 2>/dev/null`" != "$(SRCS)" ]; then echo "$(SRCS)" > $(CONFIG_CACHE_SOURCE); fi )
# If there is a change in the revision, make sure we recompile rev.cpp
RES := $(shell if [ "`cat $(CONFIG_CACHE_VERSION) 2>/dev/null`" != "$(VERSION) $(MODIFIED)" ]; then echo "$(VERSION) $(MODIFIED)" > $(CONFIG_CACHE_VERSION); fi )

ifndef MAKEDEPEND
# The slow, but always correct, dep-check
DEP_MASK := %.d
DEPS     := $(OBJS:%.o=%.d)

# Only include the deps if we are compiling everything
ifeq ($(filter %.o clean mrproper, $(MAKECMDGOALS)),)
-include $(DEPS)
else
# In case we want to compile a single target, include the .d file for it
ifneq ($(filter %.o, $(MAKECMDGOALS)),)
SINGLE_DEP := $(filter %.o, $(MAKECMDGOALS))
-include $(SINGLE_DEP:%.o=%.d)
endif
endif

# Find the deps via GCC. Rarely wrong, but a bit slow

$(OBJS_C:%.o=%.d): %.d: $(SRC_DIR)/%.c $(FILE_DEP)
	$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.c=%.c)'
	$(Q)$(CC_HOST) $(CFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@

$(OBJS_CPP:%.o=%.d): %.d: $(SRC_DIR)/%.cpp $(FILE_DEP)
	$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.cpp=%.cpp)'
	$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@

$(OBJS_MM:%.o=%.d): %.d: $(SRC_DIR)/%.mm $(FILE_DEP)
	$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.mm=%.mm)'
	$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@

$(OBJS_RC:%.o=%.d): %.d: $(SRC_DIR)/%.rc $(FILE_DEP)
	$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.rc=%.rc)'
	$(Q)touch $@

else
# The much faster, but can be wrong, dep-check
DEP_MASK :=
DEPS     := Makefile.dep

# Only include the deps if we are not cleaning
ifeq ($(filter depend clean mrproper, $(MAKECMDGOALS)),)
-include Makefile.dep
endif

ifeq ("$(SRC_OBJS_DIR)/$(DEPEND)","$(MAKEDEPEND)")
DEP := $(MAKEDEPEND)
$(SRC_OBJS_DIR)/$(DEPEND): $(SRC_DIR)/depend/depend.cpp
	$(E) '$(STAGE) Compiling and linking $(DEPEND)'
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) -o $@ $<
endif

# Macro for invoking a command on groups of 100 words at a time
# (analogous to xargs(1)).  The macro invokes itself recursively
# until the list of words is depleted.
#
# Usage: $(call xargs,COMMAND,LIST)
#
# COMMAND should be a shell command to which the words will be
# appended as arguments in groups of 100.
define xargs
$(1) $(wordlist 1,100,$(2))
$(if $(word 101,$(2)),$(call xargs,$(1),$(wordlist 101,$(words $(2)),$(2))))
endef

# Make sure that only 'make depend' ALWAYS triggers a recheck
ifeq ($(filter depend, $(MAKECMDGOALS)),)
Makefile.dep: $(FILE_DEP) $(SRCS:%=$(SRC_DIR)/%) $(CONFIG_CACHE_SOURCE) $(DEP)
else
Makefile.dep: $(FILE_DEP) $(SRCS:%=$(SRC_DIR)/%) $(DEP) FORCE
endif
	$(E) '$(STAGE) DEP CHECK (all files)'
	$(Q)rm -f Makefile.dep.tmp
	$(Q)touch Makefile.dep.tmp

# Calculate the deps via makedepend
	$(call xargs,$(Q)$(MAKEDEPEND) -f$(SRC_OBJS_DIR)/Makefile.dep.tmp -o.o -Y -v -a -- $(CFLAGS_MAKEDEP) -- 2>/dev/null,$(SRCS:%=$(SRC_DIR)/%))

# Remove all comments and includes that don't start with $(SRC_DIR)
# Remove $(SRC_DIR) from object-file-name
	@$(AWK) '                           \
	/^# DO NOT/ { print $$0 ; next}     \
	/^#/ {next}                         \
	/: / {                               \
		left = NF - 1;                    \
		for (n = 2; n <= NF; n++) {       \
			if (match($$n, "^$(ROOT_DIR)") == 0) { \
				$$n = "";                     \
				left--;                       \
			}                               \
		}                                 \
		gsub("$(SRC_DIR)/", "", $$1);     \
		if (left > 0) {                   \
			print $$0;                      \
			$$1 = "Makefile.dep:";          \
			print $$0;                      \
		}                                 \
		next                              \
	}                                   \
	{                                   \
		print $$0                         \
	}                                   \
	' < Makefile.dep.tmp | sed 's@  *@ @g;s@ $$@@' | LC_ALL=C $(SORT) > Makefile.dep

	$(Q)rm -f Makefile.dep.tmp Makefile.dep.tmp.bak

endif

# Avoid problems with deps if a .h/.hpp/.hpp.sq file is deleted without the deps
#  being updated. Now the Makefile continues, the deps are recreated
#  and all will be fine.
%.h %.hpp %.hpp.sq:
	@true


# Compile all the files according to the targets

$(OBJS_C): %.o: $(SRC_DIR)/%.c $(DEP_MASK) $(FILE_DEP)
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.c=%.c)'
	$(Q)$(CC_HOST) $(CFLAGS) -c -o $@ $<

$(filter-out %sse2.o, $(filter-out %ssse3.o, $(filter-out %sse4.o, $(OBJS_CPP)))): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
	$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<

$(filter %sse2.o, $(OBJS_CPP)): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
	$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -msse2 -o $@ $<

$(filter %ssse3.o, $(OBJS_CPP)): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
	$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -mssse3 -o $@ $<

$(filter %sse4.o, $(OBJS_CPP)): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
	$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -msse4.1 -o $@ $<

$(OBJS_MM): %.o: $(SRC_DIR)/%.mm $(DEP_MASK) $(FILE_DEP)
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.mm=%.mm)'
	$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<

$(OBJS_RC): %.o: $(SRC_DIR)/%.rc $(FILE_DEP)
	$(E) '$(STAGE) Compiling resource $(<:$(SRC_DIR)/%.rc=%.rc)'
	$(Q)$(WINDRES) -o $@ $<

$(BIN_DIR)/$(TTD): $(TTD)
	$(Q)cp $(TTD) $(BIN_DIR)/$(TTD)
ifeq ($(OS), UNIX)
	$(Q)cp $(MEDIA_DIR)/openttd.32.bmp $(BIN_DIR)/baseset/
endif
ifeq ($(OS), OSX)
	$(Q)cp $(ROOT_DIR)/os/macosx/splash.png $(BIN_DIR)/baseset/
endif

$(TTD): $(OBJS) $(CONFIG_CACHE_LINKER)
	$(E) '$(STAGE) Linking $@'
	$(Q)+$(CXX_HOST) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
ifdef STRIP
	$(Q)$(STRIP) $@
endif

# Revision files

$(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in
	$(Q)cat $(SRC_DIR)/rev.cpp.in      | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!MODIFIED!!@$(MODIFIED)@g;s@!!DATE!!@`date +%d.%m.%y`@g;s@!!GITHASH!!@$(GITHASH)@g;s@!!ISTAG!!@$(ISTAG)@g;s@!!ISSTABLETAG!!@$(ISSTABLETAG)@g" > $(SRC_DIR)/rev.cpp

$(SRC_DIR)/os/windows/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/os/windows/ottdres.rc.in
	$(Q)cat $(SRC_DIR)/os/windows/ottdres.rc.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!DATE!!@`date +%d.%m.%y`@g;s@!!GITHASH!!@$(GITHASH)@g;s@!!ISTAG!!@$(ISTAG)@g;s@!!ISSTABLETAG!!@$(ISSTABLETAG)@g" > $(SRC_DIR)/os/windows/ottdres.rc

FORCE:

depend: $(DEPS)

clean:
	$(E) '$(STAGE) Cleaning up object files'
	$(Q)rm -f $(DEPS) $(OBJS) $(TTD) $(DEPEND) $(TTD:%=$(BIN_DIR)/%) $(BIN_DIR)/baseset/openttd.32.bmp $(CONFIG_CACHE_COMPILER) $(CONFIG_CACHE_LINKER) $(CONFIG_CACHE_SOURCE)

mrproper: clean
	$(Q)rm -f $(SRC_DIR)/rev.cpp $(SRC_DIR)/os/windows/ottdres.rc

%.o:
	@echo '$(STAGE) No such source-file: $(@:%.o=%).[c|cpp|mm|rc]'

.PHONY: all mrproper depend clean FORCE