rubidium@5726: # Auto-generated file -- DO NOT EDIT rubidium@5726: rubidium@5726: CC_HOST = !!CC_HOST!! rubidium@5726: CXX_HOST = !!CXX_HOST!! rubidium@5726: CC_BUILD = !!CC_BUILD!! rubidium@5838: CXX_BUILD = !!CXX_BUILD!! rubidium@5726: WINDRES = !!WINDRES!! rubidium@5726: STRIP = !!STRIP!! rubidium@5726: CC_CFLAGS = !!CC_CFLAGS!! rubidium@5726: CFLAGS = !!CFLAGS!! rubidium@5726: CFLAGS_BUILD = !!CFLAGS_BUILD!! rubidium@5726: LIBS = !!LIBS!! rubidium@5726: LDFLAGS = !!LDFLAGS!! rubidium@5726: BIN_DIR = !!BIN_DIR!! rubidium@5726: LANG_DIR = !!LANG_DIR!! rubidium@5726: SRC_OBJS_DIR = !!SRC_OBJS_DIR!! rubidium@5726: LANG_OBJS_DIR= !!LANG_OBJS_DIR!! rubidium@5726: SRC_DIR = !!SRC_DIR!! rubidium@5726: MEDIA_DIR = !!MEDIA_DIR!! rubidium@5726: TTD = !!TTD!! rubidium@5726: STRGEN = !!STRGEN!! rubidium@5726: ENDIAN_CHECK = !!ENDIAN_CHECK!! rubidium@5726: ENDIAN_FORCE = !!ENDIAN_FORCE!! rubidium@5726: OS = !!OS!! rubidium@5726: STAGE = !!STAGE!! rubidium@5726: MAKEDEPEND = !!MAKEDEPEND!! rubidium@5726: CFLAGS_MAKEDEP= !!CFLAGS_MAKEDEP!! rubidium@5726: SORT = !!SORT!! rubidium@5786: REVISION = !!REVISION!! truelight@6407: AWK = !!AWK!! truelight@7019: GCC295 = !!GCC295!! rubidium@5726: CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!! rubidium@5726: CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!! rubidium@5726: CONFIG_CACHE_ENDIAN = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_ENDIAN!! rubidium@5726: CONFIG_CACHE_SOURCE = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_SOURCE!! rubidium@5726: CONFIG_CACHE_VERSION = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_VERSION!! rubidium@5726: rubidium@5726: OBJS_C := !!OBJS_C!! rubidium@5726: OBJS_CPP := !!OBJS_CPP!! bjarni@6192: OBJS_MM := !!OBJS_MM!! rubidium@5726: OBJS_RC := !!OBJS_RC!! bjarni@6192: OBJS := $(OBJS_C) $(OBJS_CPP) $(OBJS_MM) $(OBJS_RC) rubidium@5726: SRCS := !!SRCS!! rubidium@5726: rubidium@5726: # All C-files depend on those 3 files rubidium@5726: FILE_DEP := $(CONFIG_CACHE_COMPILER) $(LANG_OBJS_DIR)/table/strings.h endian_target.h rubidium@5726: # Create all dirs and subdirs rubidium@5726: RES := $(shell mkdir -p $(BIN_DIR) $(sort $(dir $(OBJS)))) rubidium@5726: rubidium@5726: # Make sure endian_target.h is reasable as if it was in the src/ dir rubidium@5726: CFLAGS += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) rubidium@5726: rubidium@5726: ENDIAN_TARGETS := endian_target.h $(ENDIAN_CHECK) rubidium@5726: truelight@7019: # This 'sed' basicly just removes 'const' from the line if it is a 2+D array truelight@7019: # For more information, please check: truelight@7019: # http://maillist.openttd.org/pipermail/devs/2007-April/000284.html truelight@7019: # http://maillist.openttd.org/pipermail/devs/2007-February/000248.html truelight@7019: GCC295_FIX=sed -r 's/^(\t*)(.*)( const )([A-Za-z0-9_ ]+(\[.*\]){2,})(( = \{)|(;))(.*)$$/\1\2 \4\6\8\9/g' truelight@7019: # This 'sed' removes the 3rd '4' in the # lines of the -E output of truelight@7019: # gcc 2.95.3 and lower, as it should indicate that it is a C-linkage, but the truelight@7019: # compiler can't handle that information (just don't ask). So we remove it truelight@7019: # and then it compiles happily and without bitching :) rubidium@7752: # Furthermore gcc 2.95 has some trouble with protected and private when rubidium@7752: # accessing the protected/private stuff of the enclosing class (or the rubidium@7752: # super class of the enclosing class). rubidium@7752: GCC295_FIX_2=sed -e 's|\(^\# [0-9][0-9]* "[^"]*"[ 0-9]*\) 4$$|\1|g;s|private:|public:|g;s|protected:|public:|g' truelight@7019: rubidium@5726: # Check if we want to show what we are doing rubidium@5726: ifdef VERBOSE rubidium@5726: Q = rubidium@5726: E = @true rubidium@5726: else rubidium@5726: Q = @ rubidium@5726: E = @echo rubidium@5726: endif rubidium@5726: rubidium@5726: # Our default target rubidium@5861: all: $(BIN_DIR)/$(TTD) rubidium@5726: rubidium@5726: # This are 2 rules that are pointing back to STRGEN stuff. rubidium@5726: # There is not really a need to have them here, but in case rubidium@5726: # some weirdo wants to run 'make' in the 'src' dir and expects rubidium@5726: # the languages to be recompiled, this catches that case and rubidium@5726: # takes care of it nicely. rubidium@5726: $(LANG_OBJS_DIR)/$(STRGEN): rubidium@5726: $(MAKE) -C $(LANG_OBJS_DIR) $(STRGEN) rubidium@5726: rubidium@5726: $(LANG_OBJS_DIR)/table/strings.h: $(LANG_DIR)/english.txt $(LANG_OBJS_DIR)/$(STRGEN) rubidium@5726: $(MAKE) -C $(LANG_OBJS_DIR) table/strings.h rubidium@5726: smatz@10824: smatz@10824: # Determine if we are using a modified version smatz@10824: ifeq ($(shell if test -d $(SRC_DIR)/.svn; then echo 1; fi), 1) smatz@10824: REV_MODIFIED := $(shell svnversion $(SRC_DIR) | sed -n 's/.*\(M\).*/\1/p' ) smatz@10824: else smatz@10824: # Are we a git dir? smatz@10824: ifeq ($(shell if test -d $(SRC_DIR)/../.git; then echo 1; fi), 1) smatz@10824: REV_MODIFIED := $(shell if cd "$(SRC_DIR)/.." && git diff-index HEAD src | read dummy; then echo M; fi) smatz@10824: else smatz@10824: # Are we a hg (Mercurial) dir? smatz@10824: ifeq ($(shell if test -d $(SRC_DIR)/../.hg; then echo 1; fi), 1) smatz@10824: REV_MODIFIED := $(shell if hg status $(SRC_DIR) | grep -v '^?' | read dummy; then echo M; fi) smatz@10824: else smatz@10824: MODIFIED="1" smatz@10824: endif smatz@10824: endif smatz@10824: endif smatz@10824: smatz@10824: ifneq ($(MODIFIED),"1") smatz@10824: ifeq ($(REV_MODIFIED),) smatz@10824: MODIFIED="0" smatz@10824: else smatz@10824: MODIFIED="2" smatz@10824: endif smatz@10824: endif smatz@10824: rubidium@5726: # Make the revision number rubidium@5726: ifdef REVISION rubidium@5726: REV := $(REVISION) truelight@8282: REV_NR := $(shell echo $(REVISION) | sed "s/[^0-9]//g") rubidium@5726: else rubidium@5726: # Are we a SVN dir? rubidium@5726: ifeq ($(shell if test -d $(SRC_DIR)/.svn; then echo 1; fi), 1) rubidium@5726: # Find if the local source if modified rubidium@5726: # Find the revision like: rXXXX-branch truelight@6407: REV := $(shell LC_ALL=C svn info $(SRC_DIR) | $(AWK) '/^URL:.*branch/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') rubidium@8276: REV_NR := $(shell LC_ALL=C svn info $(SRC_DIR) | $(AWK) '/^Last Changed Rev:/ { print $$4 }') rubidium@7308: else rubidium@7308: # Are we a git dir? rubidium@7308: ifeq ($(shell if test -d $(SRC_DIR)/../.git; then echo 1; fi), 1) rubidium@8114: # Find the revision like: gXXXXM-branch smatz@10824: REV := g$(shell if head=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`; then echo "$$head" | cut -c1-8; fi)$(REV_MODIFIED)$(shell git branch|grep '[*]' | sed 's/\* /-/;s/^-master$$//') glx@8411: REV_NR := $(shell LC_ALL=C cd "$(SRC_DIR)/.." && git log --pretty=format:%s src | grep -m 1 "^(svn r[0-9]*)" | sed "s/.*(svn r\([0-9]*\)).*/\1/" ) rubidium@8114: else rubidium@8114: # Are we a hg (Mercurial) dir? rubidium@8114: ifeq ($(shell if test -d $(SRC_DIR)/../.hg; then echo 1; fi), 1) rubidium@8114: # Find the revision like: hXXXXM-branch smatz@10824: REV := h$(shell if head=`LC_ALL=C hg tip 2>/dev/null`; then echo "$$head" | head -n 1 | cut -c19-26; fi)$(REV_MODIFIED)$(shell hg branch | sed 's/^/-/;s/^-default$$//') glx@8411: REV_NR := $(shell LC_ALL=C hg log -k "svn" -l 1 --template "{desc}\n" $(SRC_DIR) | grep -m 1 "^(svn r[0-9]*)" | sed "s/.*(svn r\([0-9]*\)).*/\1/" ) rubidium@8114: endif rubidium@5726: endif rubidium@5726: endif rubidium@7308: endif rubidium@7308: rubidium@5726: # Make sure we have something in REV rubidium@5726: ifeq ($(REV),) rubidium@5726: REV := norev000 rubidium@8276: REV_NR := 0 rubidium@5726: endif rubidium@5726: rubidium@5726: # This helps to recompile if flags change rubidium@5726: RES := $(shell if [ "`cat $(CONFIG_CACHE_COMPILER) 2>/dev/null`" != "$(CC_CFLAGS) $(CFLAGS)" ]; then echo "$(CC_CFLAGS) $(CFLAGS)" > $(CONFIG_CACHE_COMPILER); fi ) rubidium@5726: RES := $(shell if [ "`cat $(CONFIG_CACHE_LINKER) 2>/dev/null`" != "$(LDFLAGS) $(LIBS)" ]; then echo "$(LDFLAGS) $(LIBS)" > $(CONFIG_CACHE_LINKER); fi ) rubidium@5726: RES := $(shell if [ "`cat $(CONFIG_CACHE_ENDIAN) 2>/dev/null`" != "$(ENDIAN_FORCE)" ]; then echo "$(ENDIAN_FORCE)" > $(CONFIG_CACHE_ENDIAN); fi ) rubidium@5726: rubidium@5726: # If there is a change in the source-file-list, make sure we recheck the deps rubidium@5726: RES := $(shell if [ "`cat $(CONFIG_CACHE_SOURCE) 2>/dev/null`" != "$(SRCS)" ]; then echo "$(SRCS)" > $(CONFIG_CACHE_SOURCE); fi ) rubidium@5838: # If there is a change in the revision, make sure we recompile rev.cpp rubidium@5726: RES := $(shell if [ "`cat $(CONFIG_CACHE_VERSION) 2>/dev/null`" != "$(REV)" ]; then echo "$(REV)" > $(CONFIG_CACHE_VERSION); fi ) rubidium@5726: rubidium@5726: ifndef MAKEDEPEND rubidium@5726: # The slow, but always correct, dep-check rubidium@5726: DEP_MASK := %.d rubidium@5726: DEPS := $(OBJS:%.o=%.d) rubidium@5726: rubidium@5726: # Only include the deps if we are compiling everything rubidium@5726: ifeq ($(filter $(ENDIAN_TARGETS) %.o clean mrproper, $(MAKECMDGOALS)),) rubidium@5726: -include $(DEPS) rubidium@5726: else rubidium@5726: # In case we want to compile a single target, include the .d file for it rubidium@5726: ifneq ($(filter %.o, $(MAKECMDGOALS)),) rubidium@5726: SINGLE_DEP := $(filter %.o, $(MAKECMDGOALS)) rubidium@5726: -include $(SINGLE_DEP:%.o=%.d) rubidium@5726: endif rubidium@5726: endif rubidium@5726: rubidium@5726: # Find the deps via GCC. Rarely wrong, but a bit slow rubidium@5726: rubidium@5726: $(OBJS_C:%.o=%.d): %.d: $(SRC_DIR)/%.c $(FILE_DEP) rubidium@5726: $(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.c=%.c)' rubidium@5726: $(Q)$(CC_HOST) $(CC_CFLAGS) $(CFLAGS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:%.d=%.o):#' > $@ rubidium@5726: rubidium@5726: $(OBJS_CPP:%.o=%.d): %.d: $(SRC_DIR)/%.cpp $(FILE_DEP) rubidium@5726: $(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.cpp=%.cpp)' rubidium@5726: $(Q)$(CXX_HOST) $(CFLAGS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:%.d=%.o):#' > $@ rubidium@5726: bjarni@6192: $(OBJS_MM:%.o=%.d): %.d: $(SRC_DIR)/%.mm $(FILE_DEP) bjarni@6192: $(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.mm=%.mm)' bjarni@6192: $(Q)$(CC_HOST) $(CFLAGS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:%.d=%.o):#' > $@ rubidium@5726: truelight@5729: $(OBJS_RC:%.o=%.d): %.d: $(SRC_DIR)/%.rc $(FILE_DEP) bjarni@6192: $(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.mm=%.mm)' truelight@5729: $(Q)touch $@ truelight@5729: rubidium@5726: else rubidium@5726: # The much faster, but can be wrong, dep-check rubidium@5726: DEP_MASK := rubidium@5726: DEPS := Makefile.dep rubidium@5726: rubidium@5726: # Only include the deps if we are not cleaning rubidium@5726: ifeq ($(filter $(ENDIAN_TARGETS) depend clean mrproper, $(MAKECMDGOALS)),) rubidium@5726: -include Makefile.dep rubidium@5726: endif rubidium@5726: rubidium@5726: # Make sure that only 'make depend' ALWAYS triggers a recheck rubidium@5726: ifeq ($(filter depend, $(MAKECMDGOALS)),) rubidium@5726: Makefile.dep: $(FILE_DEP) $(SRCS:%=$(SRC_DIR)/%) $(CONFIG_CACHE_SOURCE) rubidium@5726: else rubidium@5726: Makefile.dep: FORCE rubidium@5726: endif rubidium@5726: $(E) '$(STAGE) DEP CHECK (all files)' rubidium@5726: $(Q)rm -f Makefile.dep.tmp rubidium@5726: $(Q)touch Makefile.dep.tmp rubidium@5726: rubidium@5726: # Calculate the deps via makedepend rubidium@5726: $(Q)$(MAKEDEPEND) -f$(SRC_OBJS_DIR)/Makefile.dep.tmp -o.o -Y -v -- $(CFLAGS_MAKEDEP) -- $(SRCS:%=$(SRC_DIR)/%) 2>/dev/null rubidium@5726: rubidium@5726: # Convert x:/... paths to /x/... for mingw rubidium@5726: ifeq ($(OS), MINGW) glx@6430: @cat Makefile.dep.tmp | sed 's@\([a-zA-Z]\):\/@\/\1\/@g' > Makefile.dep.tmp.mingw rubidium@5726: @cp Makefile.dep.tmp.mingw Makefile.dep.tmp rubidium@5726: @rm -f Makefile.dep.tmp.mingw rubidium@5726: endif rubidium@5726: rubidium@5726: # Remove all comments and includes that don't start with $(SRC_DIR) rubidium@5726: # Remove $(SRC_DIR) from object-file-name truelight@6407: @$(AWK) ' \ rubidium@5726: /^# DO NOT/ { print $$0 ; next} \ rubidium@5726: /^#/ {next} \ rubidium@5726: /:/ { \ rubidium@5726: left = NF - 1; \ rubidium@5726: for (n = 2; n <= NF; n++) { \ rubidium@5726: if (match($$n, "^$(SRC_DIR)") == 0) { \ rubidium@5726: $$n = ""; \ rubidium@5726: left--; \ rubidium@5726: } \ rubidium@5726: } \ rubidium@5726: gsub("$(SRC_DIR)/", "", $$1); \ rubidium@5726: if (left > 0) { \ rubidium@5726: print $$0; \ rubidium@5726: $$1 = "Makefile.dep:"; \ rubidium@5726: print $$0; \ rubidium@5726: } \ rubidium@5726: next \ rubidium@5726: } \ rubidium@5726: { \ rubidium@5726: print $$0 \ rubidium@5726: } \ rubidium@5726: ' < Makefile.dep.tmp | sed 's/ */ /g;s/ $$//' | $(SORT) > Makefile.dep rubidium@5726: rubidium@5726: $(Q)rm -f Makefile.dep.tmp Makefile.dep.tmp.bak rubidium@5726: rubidium@5726: endif rubidium@5726: glx@5901: # Avoid problems with deps if a .h/.hpp file is deleted without the deps rubidium@5726: # being updated. Now the Makefile continues, the deps are recreated rubidium@5726: # and all will be fine. glx@5901: %.h %.hpp: rubidium@5726: @true rubidium@5726: rubidium@5726: rubidium@5726: # Compile all the files according to the targets rubidium@5726: rubidium@5726: $(OBJS_C): %.o: $(SRC_DIR)/%.c $(DEP_MASK) $(FILE_DEP) rubidium@5726: $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.c=%.c)' rubidium@5726: $(Q)$(CC_HOST) $(CC_CFLAGS) $(CFLAGS) -c -o $@ $< rubidium@5726: rubidium@5726: $(OBJS_CPP): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP) rubidium@5726: $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' truelight@7019: ifeq ($(GCC295), 1) truelight@7019: $(Q)$(CXX_HOST) -E $(CFLAGS) $< | $(GCC295_FIX) | $(GCC295_FIX_2) | $(CXX_HOST) $(CFLAGS) -c -o $@ -x c++ - truelight@7019: else rubidium@5726: $(Q)$(CXX_HOST) $(CFLAGS) -c -o $@ $< truelight@7019: endif rubidium@5726: bjarni@6192: $(OBJS_MM): %.o: $(SRC_DIR)/%.mm $(DEP_MASK) $(FILE_DEP) bjarni@6192: $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.mm=%.mm)' bjarni@6192: $(Q)$(CC_HOST) $(CFLAGS) -c -o $@ $< rubidium@5726: rubidium@5726: $(OBJS_RC): %.o: $(SRC_DIR)/%.rc $(FILE_DEP) rubidium@5726: $(E) '$(STAGE) Compiling resource $(<:$(SRC_DIR)/%.rc=%.rc)' rubidium@5726: $(Q)$(WINDRES) -o $@ -I $(MEDIA_DIR) $< rubidium@5726: rubidium@5861: $(BIN_DIR)/$(TTD): $(TTD) rubidium@5861: $(Q)cp $< $@ rubidium@5861: rubidium@8060: $(TTD): $(OBJS) $(CONFIG_CACHE_LINKER) rubidium@5726: $(E) '$(STAGE) Linking $@' truelight@6230: ifeq ($(OS), PSP) truelight@6410: # Because of a bug in the PSP GCC tools, linking via CXX results truelight@6410: # in total chaos and more problems then you can handle. So we need truelight@6410: # CC to link OpenTTD for PSP rubidium@8060: $(Q)$(CC_HOST) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ truelight@6230: else rubidium@8060: $(Q)$(CXX_HOST) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ truelight@6230: endif rubidium@5726: ifdef STRIP rubidium@5726: $(Q)$(STRIP) $@ rubidium@5726: endif rubidium@5726: rubidium@5726: # The targets to compile the endian-code rubidium@5726: rubidium@5726: endian_target.h: $(ENDIAN_CHECK) $(CONFIG_CACHE_ENDIAN) rubidium@5726: $(E) '$(STAGE) Testing endianness for target' rubidium@5726: $(Q)./$(ENDIAN_CHECK) $(ENDIAN_FORCE) > $@ rubidium@5726: rubidium@5838: $(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp rubidium@5726: $(E) '$(STAGE) Compiling and Linking $@' rubidium@5838: $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $< -o $@ rubidium@5726: rubidium@5726: # Revision files rubidium@5726: rubidium@8060: $(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in smatz@10824: $(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s#@@REVISION@@#$(REV_NR)#g;s#@@VERSION@@#$(REV)#g;s#@@MODIFIED@@#$(MODIFIED)#g;s#@@DATE@@#`date +%d.%m.%y`#g" > $(SRC_DIR)/rev.cpp rubidium@5726: rubidium@8060: $(SRC_DIR)/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/ottdres.rc.in rubidium@8276: $(Q)cat $(SRC_DIR)/ottdres.rc.in | sed "s#@@REVISION@@#$(REV_NR)#g;s#@@VERSION@@#$(REV)#g;s#@@DATE@@#`date +%d.%m.%y`#g" > $(SRC_DIR)/ottdres.rc rubidium@5726: rubidium@5726: FORCE: rubidium@5726: rubidium@5726: depend: $(DEPS) rubidium@5726: rubidium@5726: clean: rubidium@5726: $(E) '$(STAGE) Cleaning up object files' rubidium@8060: $(Q)rm -f $(DEPS) $(OBJS) $(TTD) $(TTD:%=$(BIN_DIR)/%) $(CONFIG_CACHE_COMPILER) $(CONFIG_CACHE_LINKER) $(CONFIG_CACHE_ENDIAN) $(CONFIG_CACHE_SOURCE) $(ENDIAN_TARGETS) rubidium@5726: rubidium@5726: mrproper: clean rubidium@8060: $(Q)rm -f $(SRC_DIR)/rev.cpp $(SRC_DIR)/ottdres.rc rubidium@5726: rubidium@5726: %.o: bjarni@6221: @echo '$(STAGE) No such source-file: $(@:%.o=%).[c|cpp|mm|rc]' rubidium@5726: rubidium@5726: .PHONY: all mrproper depend clean FORCE