Changeset - r11911:68c886dabb52
[Not reviewed]
master
0 9 0
rubidium - 15 years ago 2009-05-16 12:36:33
rubidium@openttd.org
(svn r16318) -Change: use !! instead of @@ in src/*.in too.
-Change: use @ instead of ~ in configure/Makefiles so Debian's build system(s) can also build RC binaries.
9 files changed with 112 insertions and 112 deletions:
0 comments (0 inline, 0 general)
Makefile.in
Show inline comments
 
# Check if we want to show what we are doing
 
ifdef VERBOSE
 
	Q =
 
else
 
	Q = @
 
endif
 

	
 
include Makefile.am
 

	
 
SOURCE_LIST = !!SOURCE_LIST!!
 
CONFIG_CACHE_SOURCE_LIST = !!CONFIG_CACHE_SOURCE_LIST!!
 
CONFIG_CACHE_PWD = !!CONFIG_CACHE_PWD!!
 
CONFIGURE_FILES = !!CONFIGURE_FILES!!
 
LIPO = !!LIPO!!
 
BIN_DIR = !!BIN_DIR!!
 
ICON_THEME_DIR = !!ICON_THEME_DIR!!
 
MAN_DIR = !!MAN_DIR!!
 
MENU_DIR = !!MENU_DIR!!
 
SRC_DIR = !!SRC_DIR!!
 
ROOT_DIR = !!ROOT_DIR!!
 
BUNDLE_DIR = "$(ROOT_DIR)/bundle"
 
BUNDLES_DIR = "$(ROOT_DIR)/bundles"
 
INSTALL_DIR = !!INSTALL_DIR!!
 
INSTALL_BINARY_DIR = "$(INSTALL_DIR)/"!!BINARY_DIR!!
 
INSTALL_MAN_DIR = "$(INSTALL_DIR)/$(MAN_DIR)"
 
INSTALL_MENU_DIR = "$(INSTALL_DIR)/$(MENU_DIR)"
 
INSTALL_ICON_DIR = "$(INSTALL_DIR)/"!!ICON_DIR!!
 
INSTALL_ICON_THEME_DIR = "$(INSTALL_DIR)/$(ICON_THEME_DIR)"
 
INSTALL_DATA_DIR = "$(INSTALL_DIR)/"!!DATA_DIR!!
 
INSTALL_DOC_DIR = "$(INSTALL_DIR)/"!!DOC_DIR!!
 
BINARY_NAME = !!BINARY_NAME!!
 
STRIP = !!STRIP!!
 
TTD = !!TTD!!
 
TTDS = $(SRC_DIRS:%=%/$(TTD))
 
OS = !!OS!!
 
OSXAPP = !!OSXAPP!!
 
REVISION = !!REVISION!!
 
AWK = !!AWK!!
 
DISTCC = !!DISTCC!!
 

	
 
RES := $(shell if [ ! -f $(CONFIG_CACHE_PWD) ] || [ "`pwd`" != "`cat $(CONFIG_CACHE_PWD)`" ]; then echo "`pwd`" > $(CONFIG_CACHE_PWD); fi )
 
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 )
 

	
 
all: config.pwd config.cache
 
ifdef DISTCC
 
	@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
 
endif
 
	@for dir in $(DIRS); do \
 
		$(MAKE) -C $$dir all; \
 
	done
 
ifdef LIPO
 
# Lipo is an OSX thing. If it is defined, it means we are building for universal,
 
# and so we have have to combine the binaries into one big binary
 

	
 
# Remove the last binary made by the last compiled target
 
	$(Q)rm -f $(BIN_DIR)/$(TTD)
 
# Make all the binaries into one
 
	$(Q)$(LIPO) -create -output $(BIN_DIR)/$(TTD) $(TTDS)
 
endif
 

	
 
help:
 
	@echo "Available make commands:"
 
	@echo ""
 
	@echo "Compilation:"
 
	@echo "  all           compile the executable and the lang files"
 
	@echo "  lang          compile the lang files only"
 
	@echo "Clean up:"
 
	@echo "  clean         remove the files generated during compilation"
 
	@echo "  mrproper      remove the files generated during configuration and compilation"
 
	@echo "Run after compilation:"
 
	@echo "  run           execute openttd after the compilation"
 
	@echo "  run-gdb       execute openttd in debug mode after the compilation"
 
	@echo "  run-prof      execute openttd in profiling mode after the compilation"
 
	@echo "Installation:"
 
	@echo "  install       install the compiled files and the data-files after the compilation"
 
	@echo "  bundle        create the base for an installation bundle"
 
	@echo "  bundle_zip    create the zip installation bundle"
 
	@echo "  bundle_gzip   create the gzip installation bundle"
 
	@echo "  bundle_bzip2  create the bzip2 installation bundle"
 
	@echo "  bundle_lha    create the lha installation bundle"
 
	@echo "  bundle_dmg    create the dmg installation bundle"
 

	
 
config.pwd: $(CONFIG_CACHE_PWD)
 
	$(MAKE) reconfigure
 

	
 
config.cache: $(CONFIG_CACHE_SOURCE_LIST) $(CONFIGURE_FILES)
 
	$(MAKE) reconfigure
 

	
 
reconfigure:
 
ifeq ($(shell if test -f config.cache; then echo 1; fi), 1)
 
	@echo "----------------"
 
	@echo "The system detected that source.list or any configure file is altered."
 
	@echo " Going to reconfigure with last known settings..."
 
	@echo "----------------"
 
# Make sure we don't lock config.cache
 
	@$(shell cat config.cache | sed 's~\\ ~\\\\ ~g') || exit 1
 
	@$(shell cat config.cache | sed 's@\\ @\\\\ @g') || exit 1
 
	@echo "----------------"
 
	@echo "Reconfig done. Please re-execute make."
 
	@echo "----------------"
 
else
 
	@echo "----------------"
 
	@echo "Have not found a configuration, please run configure first."
 
	@echo "----------------"
 
	@exit 1
 
endif
 

	
 
clean:
 
	@for dir in $(DIRS); do \
 
		$(MAKE) -C $$dir clean; \
 
	done
 
	$(Q)rm -rf $(BUNDLE_TARGET)
 

	
 
lang:
 
	@for dir in $(LANG_DIRS); do \
 
		$(MAKE) -C $$dir all; \
 
	done
 

	
 
mrproper:
 
	@for dir in $(DIRS); do \
 
		$(MAKE) -C $$dir mrproper; \
 
		rm -f $$dir/Makefile; \
 
	done
 
	$(Q)rm -rf objs
 
	$(Q)rm -f Makefile Makefile.am Makefile.bundle
 
	$(Q)rm -f media/openttd.desktop
 
	$(Q)rm -f $(CONFIG_CACHE_SOURCE_LIST) config.cache config.pwd config.log $(CONFIG_CACHE_PWD)
 
	$(Q)rm -rf $(BUNDLE_DIR)
 
	$(Q)rm -rf $(BUNDLES_DIR)
 

	
 
depend:
 
	@for dir in $(SRC_DIRS); do \
 
		$(MAKE) -C $$dir depend; \
 
	done
 

	
 
run: all
 
	$(Q)cd !!BIN_DIR!! && ./!!TTD!! $(OPENTTD_ARGS)
 

	
 
run-gdb: all
 
	$(Q)cd !!BIN_DIR!! && gdb --ex run --args ./!!TTD!! $(OPENTTD_ARGS)
 

	
 
run-prof: all
 
	$(Q)cd !!BIN_DIR!! && ./!!TTD!! $(OPENTTD_ARGS) && gprof !!TTD!! | less
 

	
 
regression: all
 
	$(Q)cd !!BIN_DIR!! && sh ai/regression/run.sh
 

	
 
%.o:
 
	@for dir in $(SRC_DIRS); do \
 
		$(MAKE) -C $$dir $(@:src/%=%); \
 
	done
 

	
 
%.lng:
 
	@for dir in $(LANG_DIRS); do \
 
		$(MAKE) -C $$dir $@; \
 
	done
 

	
 
include Makefile.bundle
Makefile.msvc
Show inline comments
 
#
 
# Makefile for creating bundles of MSVC's binaries in the same way as we make
 
# the zip bundles for ALL other OSes.
 
#
 
# Usage: make -f Makefile.msvc PLATFORM=[Win32|x64] BUNDLE_NAME=openttd-<version>-win[32|64]
 
#   or   make -f Makefile.msvc PLATFORM=[Win32|x64] BUNDLE_NAME=OTTD-win[32|64]-nightly-<revision>
 
#
 

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

	
 
AWK = "awk"
 
ROOT_DIR := $(shell pwd)
 
BIN_DIR = "$(ROOT_DIR)/bin"
 
SRC_DIR = "$(ROOT_DIR)/src"
 
BUNDLE_DIR = "$(ROOT_DIR)/bundle"
 
BUNDLES_DIR = "$(ROOT_DIR)/bundles"
 
TTD = "openttd.exe"
 
TARGET := $(shell echo $(PLATFORM) | sed "s~win64~x64~;s~win32~Win32~")
 
TARGET := $(shell echo $(PLATFORM) | sed "s@win64@x64@;s@win32@Win32@")
 

	
 
all:
 
	$(Q)cp objs/$(TARGET)/Release/$(TTD) $(BIN_DIR)/$(TTD)
 

	
 
include Makefile.bundle.in
Makefile.src.in
Show inline comments
 
CC_HOST      = !!CC_HOST!!
 
CXX_HOST     = !!CXX_HOST!!
 
CC_BUILD     = !!CC_BUILD!!
 
CXX_BUILD    = !!CXX_BUILD!!
 
WINDRES      = !!WINDRES!!
 
STRIP        = !!STRIP!!
 
CC_CFLAGS    = !!CC_CFLAGS!!
 
CFLAGS       = !!CFLAGS!!
 
CFLAGS_BUILD = !!CFLAGS_BUILD!!
 
LIBS         = !!LIBS!!
 
LDFLAGS      = !!LDFLAGS!!
 
ROOT_DIR     = !!ROOT_DIR!!
 
BIN_DIR      = !!BIN_DIR!!
 
LANG_DIR     = !!LANG_DIR!!
 
SRC_OBJS_DIR = !!SRC_OBJS_DIR!!
 
LANG_OBJS_DIR= !!LANG_OBJS_DIR!!
 
SRC_DIR      = !!SRC_DIR!!
 
SCRIPT_SRC_DIR=!!SCRIPT_SRC_DIR!!
 
MEDIA_DIR    = !!MEDIA_DIR!!
 
TTD          = !!TTD!!
 
STRGEN       = !!STRGEN!!
 
ENDIAN_CHECK = !!ENDIAN_CHECK!!
 
DEPEND       = !!DEPEND!!
 
ENDIAN_FORCE = !!ENDIAN_FORCE!!
 
OS           = !!OS!!
 
STAGE        = !!STAGE!!
 
MAKEDEPEND   = !!MAKEDEPEND!!
 
CFLAGS_MAKEDEP= !!CFLAGS_MAKEDEP!!
 
SORT         = !!SORT!!
 
REVISION     = !!REVISION!!
 
AWK          = !!AWK!!
 
GCC295       = !!GCC295!!
 
CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!!
 
CONFIG_CACHE_LINKER   = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!!
 
CONFIG_CACHE_ENDIAN   = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_ENDIAN!!
 
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) endian_target.h
 
# Create all dirs and subdirs
 
RES      := $(shell mkdir -p $(BIN_DIR) $(sort $(dir $(OBJS))))
 

	
 
# Make sure endian_target.h is reasable as if it was in the src/ dir
 
CFLAGS += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR)
 
CFLAGS_MAKEDEP += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SCRIPT_SRC_DIR)
 

	
 
ENDIAN_TARGETS := endian_target.h $(ENDIAN_CHECK)
 

	
 
# This 'sed' basicly just removes 'const' from the line if it is a 2+D array
 
# For more information, please check:
 
#  http://maillist.openttd.org/pipermail/devs/2007-April/000284.html
 
#  http://maillist.openttd.org/pipermail/devs/2007-February/000248.html
 
GCC295_FIX=sed -r 's~^(\t*)(.*)( const )([A-Za-z0-9_ ]+(\[.*\]){2,})(( = \{)|(;))(.*)$$~\1\2 \4\6\8\9~g'
 
GCC295_FIX=sed -r 's@^(\t*)(.*)( const )([A-Za-z0-9_ ]+(\[.*\]){2,})(( = \{)|(;))(.*)$$@\1\2 \4\6\8\9@g'
 
# This 'sed' removes the 3rd '4' in the # lines of the -E output of
 
#  gcc 2.95.3 and lower, as it should indicate that it is a C-linkage, but the
 
#  compiler can't handle that information (just don't ask). So we remove it
 
#  and then it compiles happily and without bitching :)
 
# Furthermore gcc 2.95 has some trouble with protected and private when
 
#  accessing the protected/private stuff of the enclosing class (or the
 
#  super class of the enclosing class).
 
GCC295_FIX_2=sed -e 's~\(^\# [0-9][0-9]* "[^"]*"[ 0-9]*\) 4$$~\1~g;s~private:~public:~g;s~protected:~public:~g'
 
GCC295_FIX_2=sed -e 's@\(^\# [0-9][0-9]* "[^"]*"[ 0-9]*\) 4$$@\1@g;s@private:@public:@g;s@protected:@public:@g'
 

	
 
# 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'	')
 

	
 
ifdef REVISION
 
# Use specified revision (which should be of the form "r000").
 
REV := $(REVISION)
 
REV_NR := $(shell echo $(REVISION) | sed "s~[^0-9]~~g")
 
REV_NR := $(shell echo $(REVISION) | sed "s@[^0-9]@@g")
 
else
 
# Use autodetected revisions
 
REV      := $(shell echo "$(VERSIONS)" | cut -f 1 -d'	')
 
REV_NR   := $(shell echo "$(VERSIONS)" | cut -f 2 -d'	')
 
endif
 

	
 
# Make sure we have something in REV and REV_NR
 
ifeq ($(REV),)
 
REV := norev000
 
endif
 
ifeq ($(REV_NR),)
 
REV_NR := 0
 
endif
 

	
 
# This helps to recompile if flags change
 
RES := $(shell if [ "`cat $(CONFIG_CACHE_COMPILER) 2>/dev/null`" != "$(CC_CFLAGS) $(CFLAGS)" ]; then echo "$(CC_CFLAGS) $(CFLAGS)" > $(CONFIG_CACHE_COMPILER); fi )
 
RES := $(shell if [ "`cat $(CONFIG_CACHE_LINKER) 2>/dev/null`" != "$(LDFLAGS) $(LIBS)" ]; then echo "$(LDFLAGS) $(LIBS)" > $(CONFIG_CACHE_LINKER); fi )
 
RES := $(shell if [ "`cat $(CONFIG_CACHE_ENDIAN) 2>/dev/null`" != "$(ENDIAN_FORCE)" ]; then echo "$(ENDIAN_FORCE)" > $(CONFIG_CACHE_ENDIAN); 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`" != "$(REV) $(MODIFIED)" ]; then echo "$(REV) $(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 $(ENDIAN_TARGETS) %.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) $(CC_CFLAGS) $(CFLAGS) -MM $< | sed 's~^$(@F:%.d=%.o):~$@ $(@:%.d=%.o):~' > $@
 
	$(Q)$(CC_HOST) $(CC_CFLAGS) $(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) -MM $< | sed 's~^$(@F:%.d=%.o):~$@ $(@:%.d=%.o):~' > $@
 
	$(Q)$(CXX_HOST) $(CFLAGS) -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)$(CC_HOST) $(CFLAGS) -MM $< | sed 's~^$(@F:%.d=%.o):~$@ $(@:%.d=%.o):~' > $@
 
	$(Q)$(CC_HOST) $(CFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@
 

	
 
$(OBJS_RC:%.o=%.d): %.d: $(SRC_DIR)/%.rc $(FILE_DEP)
 
	$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.mm=%.mm)'
 
	$(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 $(ENDIAN_TARGETS) 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_HOST) -o $@ $<
 
endif
 

	
 
# 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: $(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
 
	$(Q)$(MAKEDEPEND) -f$(SRC_OBJS_DIR)/Makefile.dep.tmp -o.o -Y -v -- $(CFLAGS_MAKEDEP) -- $(SRCS:%=$(SRC_DIR)/%) 2>/dev/null
 

	
 
# Convert x:/... paths to /x/... for mingw
 
ifeq ($(OS), MINGW)
 
	@cat Makefile.dep.tmp | sed 's~\([a-zA-Z]\):\/~\/\1\/~g' > Makefile.dep.tmp.mingw
 
	@cat Makefile.dep.tmp | sed 's@\([a-zA-Z]\):\/@\/\1\/@g' > Makefile.dep.tmp.mingw
 
	@cp Makefile.dep.tmp.mingw Makefile.dep.tmp
 
	@rm -f Makefile.dep.tmp.mingw
 
endif
 

	
 
# 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~ $$~~' | $(SORT) > Makefile.dep
 
	' < Makefile.dep.tmp | sed 's@  *@ @g;s@ $$@@' | $(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) $(CC_CFLAGS) $(CFLAGS) -c -o $@ $<
 

	
 
$(OBJS_CPP): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
 
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
 
ifeq ($(GCC295), 1)
 
	$(Q)$(CXX_HOST) -E $(CFLAGS) $< | $(GCC295_FIX) | $(GCC295_FIX_2) | $(CXX_HOST) $(CFLAGS) -c -o $@ -x c++ -
 
else
 
	$(Q)$(CXX_HOST) $(CFLAGS) -c -o $@ $<
 
endif
 

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

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

	
 
$(BIN_DIR)/$(TTD): $(TTD)
 
	$(Q)cp $< $@
 

	
 
$(TTD): $(OBJS) $(CONFIG_CACHE_LINKER)
 
	$(E) '$(STAGE) Linking $@'
 
ifeq ($(OS), PSP)
 
	# Because of a bug in the PSP GCC tools, linking via CXX results
 
	#  in total chaos and more problems then you can handle. So we need
 
	#  CC to link OpenTTD for PSP
 
	$(Q)$(CC_HOST) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
 
else
 
	$(Q)$(CXX_HOST) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
 
endif
 
ifdef STRIP
 
	$(Q)$(STRIP) $@
 
ifeq ($(OS), DOS)
 
	$(E) '$(STAGE) Adding CWSDPMI stub to $@'
 
	$(Q)$(ROOT_DIR)/os/dos/make_dos_binary_selfcontained.sh $(SRC_OBJS_DIR)/$@
 
endif
 
endif
 

	
 
# The targets to compile the endian-code
 

	
 
endian_target.h: $(ENDIAN_CHECK) $(CONFIG_CACHE_ENDIAN)
 
	$(E) '$(STAGE) Testing endianness for target'
 
	$(Q)./$(ENDIAN_CHECK) $(ENDIAN_FORCE) > $@
 

	
 
$(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp
 
	$(E) '$(STAGE) Compiling and Linking $@'
 
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $< -o $@
 

	
 
# Revision files
 

	
 
$(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in
 
	$(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
 
	$(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
 

	
 
$(SRC_DIR)/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/ottdres.rc.in
 
	$(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
 
	$(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
 

	
 
FORCE:
 

	
 
depend: $(DEPS)
 

	
 
clean:
 
	$(E) '$(STAGE) Cleaning up object files'
 
	$(Q)rm -f $(DEPS) $(OBJS) $(TTD) $(DEPEND) $(TTD:%=$(BIN_DIR)/%) $(CONFIG_CACHE_COMPILER) $(CONFIG_CACHE_LINKER) $(CONFIG_CACHE_ENDIAN) $(CONFIG_CACHE_SOURCE) $(ENDIAN_TARGETS)
 

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

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

	
 
.PHONY: all mrproper depend clean FORCE
config.lib
Show inline comments
 
@@ -328,193 +328,193 @@ detect_params() {
 
			--with-fontconfig=*)          with_fontconfig="$optarg";;
 
			--with-libfontconfig)         with_fontconfig="2";;
 
			--without-libfontconfig)      with_fontconfig="0";;
 
			--with-libfontconfig=*)       with_fontconfig="$optarg";;
 

	
 
			--with-icu)                   with_icu="2";;
 
			--without-icu)                with_icu="0";;
 
			--with-icu=*)                 with_icu="$optarg";;
 
			--with-libicu)                with_icu="2";;
 
			--without-libicu)             with_icu="0";;
 
			--with-libicu=*)              with_icu="$optarg";;
 

	
 
			--with-psp-config)            with_psp_config="2";;
 
			--without-psp-config)         with_psp_config="0";;
 
			--with-psp-config=*)          with_psp_config="$optarg";;
 

	
 
			--disable-builtin-depend)     enable_builtin_depend="0";;
 
			--enable-builtin-depend)      enable_builtin_depend="2";;
 
			--enable-builtin-depend=*)    enable_builtin_depend="$optarg";;
 

	
 
			--with-makedepend)            with_makedepend="2";;
 
			--without-makedepend)         with_makedepend="0";;
 
			--with-makedepend=*)          with_makedepend="$optarg";;
 

	
 
			--with-direct-music)          with_direct_music="2";;
 
			--without-direct-music)       with_direct_music="0";;
 
			--with-direct-music=*)        with_direct_music="$optarg";;
 

	
 
			--with-sort)                  with_sort="2";;
 
			--without-sort)               with_sort="0";;
 
			--with-sort=*)                with_sort="$optarg";;
 

	
 
			--with-iconv)                 with_iconv="2";;
 
			--without-iconv)              with_iconv="0";;
 
			--with-iconv=*)               with_iconv="$optarg";;
 

	
 
			--with-midi=*)                with_midi="$optarg";;
 
			--with-midi-arg=*)            with_midi_arg="$optarg";;
 

	
 
			--without-distcc)             with_distcc="0";;
 
			--with-distcc)                with_distcc="2";;
 
			--with-distcc=*)              with_distcc="$optarg";;
 

	
 
			--without-ccache)             with_ccache="0";;
 
			--with-ccache)                with_ccache="2";;
 
			--with-ccache=*)              with_ccache="$optarg";;
 

	
 
			--without-osx-sysroot)        with_osx_sysroot="0";;
 
			--with-osx-sysroot)           with_osx_sysroot="2";;
 
			--with-osx-sysroot=*)         with_osx_sysroot="$optarg";;
 

	
 
			--without-application-bundle) with_application_bundle="0";;
 
			--with-application-bundle)    with_application_bundle="1";;
 
			--with-application-bundle=*)  with_application_bundle="$optarg";;
 

	
 
			--without-threads)            with_threads="0";;
 
			--with-threads)               with_threads="1";;
 
			--with-threads=*)             with_threads="$optarg";;
 

	
 
			CC=* | --CC=*)                CC="$optarg";;
 
			CXX=* | --CXX=*)              CXX="$optarg";;
 
			CFLAGS=* | --CFLAGS=*)        CFLAGS="$optarg";;
 
			LDFLAGS=* | --LDFLAGS=*)      LDFLAGS="$optarg";;
 

	
 
			--ignore-extra-parameters)    ignore_extra_parameters="1";;
 

	
 
			--* | -*)
 
				if [ "$ignore_extra_parameters" = "0" ]; then
 
					log 1 "Unknown option $p"
 
					exit 1
 
				else
 
					log 1 "Unknown option $p ignored"
 
				fi
 
				;;
 
		esac
 
	done
 

	
 
	if [ -n "$prev_p" ]; then
 
		log 1 "configure: error: missing argument to --$prev_p"
 
		exit 1
 
	fi
 

	
 
	# Clean the logfile
 
	echo "" > $config_log
 
}
 

	
 
save_params() {
 
	# Here we save all params, so we can later on do an exact redo of this
 
	#  configuration, without having the user to re-input stuff
 

	
 
	echo "Running configure with following options:" >> $config_log
 
	echo "" >> $config_log
 

	
 
	configure="$CONFIGURE_EXECUTABLE --ignore-extra-parameters"
 
	for p in $save_params_array; do
 
		eval "v=\"\$$p\""
 
		p=`echo "$p" | sed 's~_~-~g;s~\n~~g;s~ ~\\ ~g'`
 
		p=`echo "$p" | sed 's@_@-@g;s@\n@@g;s@ @\\ @g'`
 
		# Only save those params that aren't empty
 
		configure="$configure --$p=\"$v\""
 
	done
 

	
 
	echo "$configure" >> $config_log
 
	echo "$configure" > config.cache
 
	echo "" >> $config_log
 
}
 

	
 
check_params() {
 
	# Some params want to be in full uppercase, else they might not work as
 
	# expected.. fix that here
 

	
 
	endian=`echo $endian | tr '[a-z]' '[A-Z]'`
 
	os=`echo $os | tr '[a-z]' '[A-Z]'`
 
	cpu_type=`echo $cpu_type | tr '[a-z]' '[A-Z]'`
 

	
 
	# Check if all params have valid values
 

	
 
	# Endian only allows AUTO, LE and, BE
 
	if [ -z "`echo $endian | egrep '^(AUTO|LE|BE|PREPROCESSOR)$'`" ]; then
 
		log 1 "configure: error: invalid option --endian=$endian"
 
		log 1 " Available options are: --endian=[AUTO|LE|BE]"
 
		exit 1
 
	fi
 
	if [ "$endian" = "PREPROCESSOR" ] && [ "$os" != "OSX" ]; then
 
		log 1 "configure: error: invalid option --endian=$endian"
 
		log 1 " PREPROCESSOR is only available for OSX"
 
		exit 1
 
	fi
 
	# OS only allows DETECT, UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
 
	if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP)$'`" ]; then
 
		log 1 "configure: error: invalid option --os=$os"
 
		log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP]"
 
		exit 1
 
	fi
 
	# cpu_type can be either 32 or 64
 
	if [ -z "`echo $cpu_type | egrep '^(32|64|DETECT)$'`" ]; then
 
		log 1 "configure: error: invalid option --cpu-type=$cpu_type"
 
		log 1 " Available options are: --cpu-type[=DETECT|32|64]"
 
		exit 1
 
	fi
 
	# enable_debug should be between 0 and 4
 
	if [ -z "`echo $enable_debug | egrep '^[0123]$'`" ]; then
 
		log 1 "configure: error: invalid option --enable-debug=$enable_debug"
 
		log 1 " Available options are: --enable-debug[=0123]"
 
		exit 1
 
	fi
 

	
 
	# enable_desync_debug should be between 0 and 3
 
	if [ -z "`echo $enable_desync_debug | egrep '^[012]$'`" ]; then
 
		log 1 "configure: error: invalid option --enable-desync-debug=$enable_desync_debug"
 
		log 1 " Available options are: --enable-desync-debug[=012]"
 
		exit 1
 
	fi
 

	
 
	detect_awk
 

	
 
	detect_os
 

	
 
	check_build
 
	check_host
 

	
 
# We might enable universal builds always on OSX targets.. but currently we don't
 
#	if [ "$enable_universal" = "1" ]  && [ "$os" != "OSX" ]; then
 
	if [ "$enable_universal" = "1" ]; then
 
		enable_universal="0"
 
	fi
 
	if [ "$enable_universal" = "2" ]  && [ "$os" != "OSX" ]; then
 
		log 1 "configure: error: --enable-universal only works on OSX"
 
		exit 1
 
	fi
 
	if [ "$enable_universal" = "0" ]; then
 
		log 1 "checking universal build... no"
 
	else
 
		if [ "$enable_universal" = "64" ]; then
 
			log 1 "checking universal build... yes (including 64 bits)"
 
		else
 
			log 1 "checking universal build... yes (without 64 bits)"
 
		fi
 
	fi
 

	
 
	# Already detected by check_build
 
	log 1 "checking build cc... $cc_build"
 
	log 1 "checking host cc... $cc_host"
 

	
 
	check_cxx_build
 
	check_cxx_host
 
	check_windres
 
	if [ "$enable_strip" != "0" ]; then
 
		check_strip
 
	else
 
		log 1 "checking strip... disabled"
 
	fi
 
	check_lipo
 

	
 
@@ -829,248 +829,248 @@ check_params() {
 
	if [ "$os" = "OSX" ] && [ "$with_application_bundle" = "1" ]; then
 
		OSXAPP="OpenTTD.app"
 
	else
 
		OSXAPP=""
 
	fi
 

	
 
	if [ "$os" = "OSX" ]; then
 
		check_osx_sdk
 
		# Test on G5
 

	
 
		if [ "$enable_osx_g5" != "0" ]; then
 
			log 1 "detecting G5... yes (forced)"
 
		else
 
			# First, are we a real OSX system, else we can't detect it
 
			native=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | grep darwin`
 
			# If $host doesn't match $build , we are cross-compiling
 
			if [ -n "$native" ] && [ "$build" = "$host" ]; then
 
				$cxx_build $SRC_DIR/os/macosx/G5_detector.cpp -o G5_detector
 
				res=`./G5_detector`
 
				rm -f G5_detector
 
				if [ -n "$res" ]; then
 
					# This is G5, add flags for it
 
					enable_osx_g5="2"
 

	
 
					log 1 "detecting G5... yes"
 
				else
 
					enable_osx_g5="0"
 

	
 
					log 1 "detecting G5... no"
 
				fi
 
			else
 
				enable_osx_g5="0"
 

	
 
				log 1 "detecting G5... no (cross-compiling)"
 
			fi
 
		fi
 
	else
 
		if [ "$enable_osx_g5" != "0" ]; then
 
			log 1 "configure: error: OSX G5 selected, but not compiling for OSX"
 
			log 1 "configure: error: either select OSX as OS, or deselect OSX G5"
 

	
 
			exit 1
 
		fi
 
	fi
 

	
 
	if [ -n "$released_version" ]; then
 
		log 1 "checking revision... release ($released_version)"
 
		if [ -n "$revision" ] && [ "$revision" != "$released_version" ]; then
 
			log 1 "WARNING: overriding of the revision is NOT possible for releases"
 
			log 1 "WARNING: the given revision is IGNORED"
 

	
 
			sleep 5
 
		fi
 
		revision=$released_version
 
	else
 
		if [ -n "$revision" ]; then
 
			log 1 "checking revision... $revision"
 
			log 1 "WARNING: we do not advise you to use this setting"
 
			log 1 "WARNING: in most cases it is not safe for network use"
 
			log 1 "WARNING: USE WITH CAUTION!"
 

	
 
			sleep 5
 
		elif [ -f "$ROOT_DIR/version" ]; then
 
			revision="`cat $ROOT_DIR/version`"
 

	
 
			log 1 "checking revision... $revision"
 
		elif [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
 
			revision=""
 
			log 1 "checking revision... svn detection"
 
		elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
 
			revision=""
 
			log 1 "checking revision... git detection"
 
		elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then
 
			revision=""
 
			log 1 "checking revision... hg detection"
 
		else
 
			revision=""
 
			log 1 "checking revision... no detection"
 
			log 1 "WARNING: there is no means to determine the version."
 
			log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
 
			log 1 "WARNING: you can only join game servers that have been compiled without"
 
			log 1 "WARNING:   version detection."
 
			log 1 "WARNING: there is a great chance you desync."
 
			log 1 "WARNING: USE WITH CAUTION!"
 

	
 
			sleep 5
 
		fi
 
	fi
 

	
 
	if [ "$doc_dir" = "1" ]; then
 
		if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
 
			doc_dir="share/doc/openttd"
 
		else
 
			doc_dir="$data_dir/docs"
 
		fi
 
	else
 
		doc_dir="`echo $doc_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
 
		doc_dir="`echo $doc_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
 
	fi
 

	
 
	if [ "$icon_theme_dir" = "1" ]; then
 
		if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
 
			icon_theme_dir="share/icons/hicolor"
 
		else
 
			icon_theme_dir=""
 
		fi
 
	else
 
		icon_theme_dir="`echo $icon_theme_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
 
		icon_theme_dir="`echo $icon_theme_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
 
	fi
 

	
 
	if [ "$personal_dir" = "1" ]; then
 
		if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ] || [ "$os" = "DOS" ]; then
 
			personal_dir="OpenTTD"
 
		elif [ "$os" = "OSX" ]; then
 
			personal_dir="Documents/OpenTTD"
 
		else
 
			personal_dir=".openttd"
 
		fi
 
	else
 
		personal_dir="`echo $personal_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
 
		personal_dir="`echo $personal_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
 
	fi
 

	
 
	if [ "$shared_dir" = "1" ]; then
 
		# we are using default values
 
		if [ "$os" = "OSX" ]; then
 
			shared_dir="/Library/Application\\\\ Support/OpenTTD"
 
		else
 
			shared_dir=""
 
		fi
 
	else
 
		shared_dir="`echo $shared_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
 
		shared_dir="`echo $shared_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
 
	fi
 

	
 
	if [ "$man_dir" = "1" ]; then
 
		# add manpage on UNIX systems
 
		if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OSX" ]; then
 
			man_dir="share/man/man6"
 
		else
 
			man_dir=""
 
		fi
 
	else
 
		man_dir="`echo $man_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
 
		man_dir="`echo $man_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
 
	fi
 

	
 
	if [ "$menu_dir" = "1" ]; then
 
		# add a freedesktop menu item only for some UNIX systems
 
		if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
 
			menu_dir="share/applications"
 
		else
 
			menu_dir=""
 
		fi
 
	else
 
		menu_dir="`echo $menu_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
 
		menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
 
	fi
 

	
 
	# "set_universal_binary_flags" needs to be before "detect_iconv"
 
	set_universal_binary_flags
 
	detect_iconv
 

	
 
	if [ -n "$personal_dir" ]
 
	then
 
		log 1 "personal home directory... $personal_dir"
 
	else
 
		log 1 "personal home directory... none"
 
	fi
 

	
 
	if [ -n "$shared_dir" ]
 
	then
 
		log 1 "shared data directory... $shared_dir"
 
	else
 
		log 1 "shared data directory... none"
 
	fi
 

	
 
	if [ -n "$install_dir" ]
 
	then
 
		log 1 "installation directory... $install_dir"
 
	else
 
		log 1 "installation directory... none"
 
	fi
 

	
 
	if [ -n "$icon_theme_dir" ]
 
	then
 
		log 1 "icon theme directory... $icon_theme_dir"
 
	else
 
		log 1 "icon theme directory... none"
 
	fi
 

	
 
	if [ -n "$man_dir" ]
 
	then
 
		log 1 "manual page directory... $man_dir"
 
	else
 
		log 1 "manual page directory... none"
 
	fi
 

	
 
	if [ -n "$menu_dir" ]
 
	then
 
		log 1 "menu item directory... $menu_dir"
 
	else
 
		log 1 "menu item directory... none"
 
	fi
 
}
 

	
 
make_cflags_and_ldflags() {
 
	# General CFlags for BUILD
 
	CFLAGS_BUILD=""
 
	# General CFlags for HOST
 
	CFLAGS="$CFLAGS -D$os"
 
	# CFlags for HOST and C-Compiler
 
	CC_FLAGS=""
 
	# Libs to compile. In fact this is just LDFLAGS
 
	LIBS="-lstdc++"
 
	# LDFLAGS used for HOST
 
	LDFLAGS="$LDFLAGS"
 

	
 
	if [ $enable_debug = 0 ]; then
 
		# No debug, add default stuff
 
		OBJS_SUBDIR="release"
 
		if [ "$os" = "OSX" ]; then
 
			# these compilerflags makes the app run as fast as possible without making the app unstable. It works on G3 or newer
 
			CFLAGS="-O3 -funroll-loops -fsched-interblock -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-jumps-max-skip=15 -falign-loops-max-skip=15 -mdynamic-no-pic $CFLAGS"
 
		else
 
			if [ "$os" = "MORPHOS" ]; then
 
				CFLAGS="-I/gg/os-include -noixemul -fstrict-aliasing -fexpensive-optimizations -mcpu=604 -fno-inline -mstring -mmultiple $CFLAGS"
 
				LDFLAGS="$LDFLAGS -noixemul"
 
			fi
 

	
 
			CFLAGS="-O2 -fomit-frame-pointer $CFLAGS"
 
		fi
 
	else
 
		OBJS_SUBDIR="debug"
 

	
 
		# Each debug level reduces the optimization by a bit
 
		if [ $enable_debug -ge 1 ]; then
 
			CFLAGS="$CFLAGS -g -D_DEBUG -D_FORTIFY_SOURCE=2"
 
			if [ "$os" = "PSP" ]; then
 
				CFLAGS="$CFLAGS -G0"
 
			fi
 
		fi
 
		if [ $enable_debug -ge 2 ]; then
 
			CFLAGS="$CFLAGS -fno-inline"
 
		fi
 
		if [ $enable_debug -ge 3 ]; then
 
			CFLAGS="$CFLAGS -O0"
 
		else
 
			CFLAGS="$CFLAGS -O2"
 
		fi
 
	fi
 

	
 
	if [ "$enable_profiling" != "0" ]; then
 
@@ -1144,390 +1144,390 @@ make_cflags_and_ldflags() {
 
		fi
 

	
 
		if [ "$os" = "CYGWIN" ] || [ "$os" = "MINGW" ]; then
 
			LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
 
			LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
 
		fi
 

	
 
		# GCC 4.0+ complains about that we break strict-aliasing.
 
		#  On most places we don't see how to fix it, and it doesn't
 
		#  break anything. So disable strict-aliasing to make the
 
		#  compiler all happy.
 
		if [ $cc_version -ge 40 ]; then
 
			CFLAGS="$CFLAGS -fno-strict-aliasing"
 
		fi
 

	
 
		# GCC 4.2+ automatically assumes that signed overflows do
 
		# not occur in signed arithmetics, whereas we are not
 
		# sure that they will not happen. It furthermore complains
 
		# about it's own optimized code in some places.
 
		if [ $cc_version -ge 42 ]; then
 
			CFLAGS="$CFLAGS -fno-strict-overflow"
 
		fi
 
	fi
 

	
 
	if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
 
		LIBS="$LIBS -lpthread"
 
	fi
 

	
 
	if [ "$os" != "CYGWIN" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then
 
		LIBS="$LIBS -lc"
 
	fi
 
	if [ "$os" = "WINCE" ]; then
 
		LIBS="$LIBS -lcoredll -lcorelibc -laygshell -lws2 -e WinMainCRTStartup"
 
	fi
 
	if [ "$os" = "PSP" ]; then
 
		CFLAGS="$CFLAGS -I`$psp_config -p`/include"
 
		LDFLAGS="$LDFLAGS -L`$psp_config -p`/lib"
 

	
 
		CFLAGS="$CFLAGS -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150"
 
		LIBS="$LIBS -D_PSP_FW_VERSION=150 -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -lm"
 
	fi
 

	
 
	if [ "$os" = "MORPHOS" ]; then
 
		# -Wstrict-prototypes generates much noise because of system headers
 
		CFLAGS="$CFLAGS -Wno-strict-prototypes"
 
	fi
 

	
 
	if [ "$os" = "OPENBSD" ]; then
 
		LIBS="$LIBS -pthread"
 
	fi
 

	
 
	if [ "$os" = "FREEBSD" ]; then
 
		LIBS="$LIBS -lpthread"
 
	fi
 

	
 
	if [ "$os" = "OSX" ]; then
 
		LDFLAGS="$LDFLAGS -framework Cocoa"
 
		if [ "$enable_dedicated" = "0" ] && [ "$cpu_type" = "32" ]; then
 
			LIBS="$LIBS -framework QuickTime"
 
		else
 
			CFLAGS="$CFLAGS -DNO_QUICKTIME"
 
		fi
 

	
 
		if [ "$cpu_type" = "64" ]; then
 
			CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
 
		fi
 
	fi
 

	
 
	if [ "$os" = "BEOS" ]; then
 
		LIBS="$LIBS -lmidi -lbe"
 
	fi
 

	
 
	# Most targets act like UNIX, just with some additions
 
	if [ "$os" = "BEOS" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
 
		CFLAGS="$CFLAGS -DUNIX"
 
	fi
 
	# And others like Windows
 
	if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
 
		CFLAGS="$CFLAGS -DWIN"
 
	fi
 

	
 
	if [ -n "$allegro_config" ]; then
 
		CFLAGS="$CFLAGS -DWITH_ALLEGRO"
 
		CFLAGS="$CFLAGS `$allegro_config --cflags`"
 
		if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
 
			if [ "$enable_static" != "0" ]; then
 
				LIBS="$LIBS `$allegro_config --static --libs`"
 
			else
 
				LIBS="$LIBS `$allegro_config --libs`"
 
			fi
 
		fi
 
	fi
 

	
 
	if [ -n "$sdl_config" ]; then
 
		CFLAGS="$CFLAGS -DWITH_SDL"
 
		# SDL must not add _GNU_SOURCE as it breaks many platforms
 
		CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's~-D_GNU_SOURCE[^ ]*~~'`"
 
		CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's@-D_GNU_SOURCE[^ ]*@@'`"
 
		if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
 
			if [ "$enable_static" != "0" ]; then
 
				LIBS="$LIBS `$sdl_config --static-libs`"
 
			else
 
				LIBS="$LIBS `$sdl_config --libs`"
 
			fi
 
		fi
 
	fi
 

	
 
	if [ "$with_cocoa" != "0" ]; then
 
		CFLAGS="$CFLAGS -DWITH_COCOA"
 
		LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit"
 

	
 
		if [ "$enable_cocoa_quartz" != "0" ]; then
 
			CFLAGS="$CFLAGS -DENABLE_COCOA_QUARTZ"
 
		fi
 

	
 
		if [ "$enable_cocoa_quickdraw" != "0" ]; then
 
			CFLAGS="$CFLAGS -DENABLE_COCOA_QUICKDRAW"
 
		fi
 
	fi
 

	
 
	if [ "$with_zlib" != "0" ]; then
 
		if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
 
			LIBS="$LIBS $zlib"
 
		else
 
			LIBS="$LIBS -lz"
 
		fi
 
		CFLAGS="$CFLAGS -DWITH_ZLIB"
 
	fi
 

	
 
	# 64bit machines need -D_SQ64
 
	if [ "$cpu_type" = "64" ]; then
 
		CFLAGS="$CFLAGS -D_SQ64"
 
	fi
 
	CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
 

	
 
	if [ -n "$png_config" ]; then
 
		CFLAGS="$CFLAGS -DWITH_PNG"
 
		CFLAGS="$CFLAGS `$png_config --cppflags --I_opts | tr '\n\r' '  '`"
 

	
 
		# The extra flags are unneeded for latest libpng-config, but some versions are so broken...
 
		if [ "$enable_static" != "0" ]; then
 
			if [ "$os" = "OSX" ]; then
 
				LIBS="$LIBS `$png_config --prefix`/lib/libpng.a"
 
			else
 
				LIBS="$LIBS `$png_config --static --ldflags | tr '\n\r' '  '`"
 
			fi
 
		else
 
			LIBS="$LIBS `$png_config --ldflags | tr '\n\r' '  '`"
 
		fi
 
	fi
 

	
 
	if [ -n "$fontconfig_config" ]; then
 
		CFLAGS="$CFLAGS -DWITH_FONTCONFIG"
 
		CFLAGS="$CFLAGS `$fontconfig_config --cflags | tr '\n\r' '  '`"
 

	
 
		if [ "$enable_static" != "0" ]; then
 
			if [ "$os" = "OSX" ]; then
 
				# fontconfig_config goes via pkg-config on all systems, which doesn't know --prefix
 
				# Also, despite the reason we link to the .a file ourself (because we can't use -static), we do need to ask pkg-config about possible other deps
 
				LIBS="$LIBS `$fontconfig_config --variable=prefix`/lib/libfontconfig.a `$fontconfig_config --libs --static | sed s~-lfontconfig~~`"
 
				LIBS="$LIBS `$fontconfig_config --variable=prefix`/lib/libfontconfig.a `$fontconfig_config --libs --static | sed s@-lfontconfig@@`"
 
			else
 
				LIBS="$LIBS `$fontconfig_config --libs --static | tr '\n\r' '  '`"
 
			fi
 
		else
 
			LIBS="$LIBS `$fontconfig_config --libs | tr '\n\r' '  '`"
 
		fi
 
	fi
 

	
 
	if [ -n "$freetype_config" ]; then
 
		CFLAGS="$CFLAGS -DWITH_FREETYPE"
 
		CFLAGS="$CFLAGS `$freetype_config --cflags | tr '\n\r' '  '`"
 

	
 
		if [ "$enable_static" != "0" ]; then
 
			if [ "$os" = "OSX" ]; then
 
				LIBS="$LIBS `$freetype_config --prefix`/lib/libfreetype.a"
 
			else
 
				# Is it possible to do static with freetype, if so: how?
 
				LIBS="$LIBS `$freetype_config --libs | tr '\n\r' '  '`"
 
			fi
 
		else
 
			LIBS="$LIBS `$freetype_config --libs | tr '\n\r' '  '`"
 
		fi
 
	fi
 

	
 
	if [ -n "$icu_config" ]; then
 
		CFLAGS="$CFLAGS -DWITH_ICU"
 
		CFLAGS="$CFLAGS `$icu_config --cppflags | tr '\n\r' '  '`"
 

	
 
		LIBS="$LIBS `$icu_config --ldflags-libsonly | tr '\n\r' '  '`"
 
	fi
 

	
 

	
 
	if [ "$with_direct_music" != "0" ]; then
 
		CFLAGS="$CFLAGS -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT"
 
		# GCC 4.0+ doesn't like the DirectX includes (gives tons of
 
		#  warnings on it we won't be able to fix). For now just
 
		#  suppress those warnings.
 
		if [ $cc_version -ge 40 ]; then
 
			CFLAGS="$CFLAGS -Wno-non-virtual-dtor"
 
		fi
 
	fi
 

	
 
	if [ -n "$libtimidity" ]; then
 
		if [ "$enable_static" != "0" ]; then
 
			LIBS="$LIBS $libtimidity"
 
		else
 
			LIBS="$LIBS -ltimidity"
 
		fi
 
		CFLAGS="$CFLAGS -DLIBTIMIDITY"
 
	fi
 

	
 
	if [ "$with_iconv" != "0" ]; then
 
		CFLAGS="$CFLAGS -DWITH_ICONV"
 
		if [ "$link_to_iconv" = "yes" ]; then
 
			LIBS="$LIBS -liconv"
 
			if [ "$with_iconv" != "2" ]; then
 
				CFLAGS="$CFLAGS -I$with_iconv/include"
 
				LIBS="$LIBS -L$with_iconv/lib"
 
			fi
 
		fi
 

	
 
		if [ "$have_broken_iconv" != "no" ]; then
 
			CFLAGS="$CFLAGS -DHAVE_BROKEN_ICONV"
 
		fi
 
	fi
 

	
 
	if [ -n "$with_midi" ]; then
 
		CFLAGS="$CFLAGS -DEXTERNAL_PLAYER=\\\\\"$with_midi\\\\\""
 
	fi
 
	if [ -n "$with_midi_arg" ]; then
 
		CFLAGS="$CFLAGS -DMIDI_ARG=\\\\\"$with_midi_arg\\\\\""
 
	fi
 

	
 
	if [ "$enable_dedicated" != "0" ]; then
 
		CFLAGS="$CFLAGS -DDEDICATED"
 
	fi
 

	
 
	if [ "$enable_unicode" != "0" ]; then
 
		CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
 
	fi
 

	
 
	if [ "$enable_network" != "0" ]; then
 
		CFLAGS="$CFLAGS -DENABLE_NETWORK"
 

	
 
		if [ "$os" = "BEOS" ]; then
 
			LDFLAGS="$LDFLAGS -lbind -lsocket"
 
		fi
 

	
 
		if [ "$os" = "SUNOS" ]; then
 
			LDFLAGS="$LDFLAGS -lnsl -lsocket"
 
		fi
 
	fi
 

	
 
	if [ "$enable_static" != "0" ]; then
 
		# OSX can't handle -static in LDFLAGS
 
		if [ "$os" != "OSX" ]; then
 
			LDFLAGS="$LDFLAGS -static"
 
		fi
 
	fi
 

	
 
	if [ "$enable_assert" = "0" ]; then
 
		CFLAGS="$CFLAGS -DNDEBUG"
 
	fi
 

	
 
	if [ "$enable_desync_debug" != "0" ]; then
 
		CFLAGS="$CFLAGS -DRANDOM_DEBUG"
 
	fi
 

	
 
	if [ "$enable_osx_g5" != "0" ]; then
 
		CFLAGS="$CFLAGS -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
 
	fi
 

	
 
	if [ -n "$personal_dir" ]; then
 
		CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
 
	fi
 

	
 
	if [ -n "$shared_dir" ]; then
 
		CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
 
	fi
 

	
 
	CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
 

	
 
	log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS"
 
	log 1 "using LDFLAGS... $LIBS $LDFLAGS"
 

	
 
	# Makedepend doesn't like something like: -isysroot /OSX/blabla
 
	#  so convert it to: -isysroot -OSX/blabla. makedepend just ignores
 
	#  any - command it doesn't know, so we are pretty save.
 
	# Lovely hackish, not?
 
	# Btw, this almost always comes from outside the configure, so it is
 
	#  not something we can control.
 
	# Also make makedepend aware of compiler's built-in defines.
 
	if [ "$with_makedepend" != "0" ] || [ "$enable_builtin_depend" != "0" ]; then
 
		cflags_makedep="`echo | $cxx_host -E -x c++ -dM - | sed 's~.define ~-D~g;s~ .*~ ~g;s~(.*)~~g' | tr -d '\r\n'`"
 
		cflags_makedep="$cflags_makedep `echo "$CFLAGS" | sed 's~ /~ -~g;s~-I[ ]*[^ ]*~~g'`"
 
		cflags_makedep="`echo | $cxx_host -E -x c++ -dM - | sed 's@.define @-D@g;s@ .*@ @g;s@(.*)@@g' | tr -d '\r\n'`"
 
		cflags_makedep="$cflags_makedep `echo "$CFLAGS" | sed 's@ /@ -@g;s@-I[ ]*[^ ]*@@g'`"
 
	else
 
		makedepend=""
 
	fi
 

	
 
	if [ "$with_distcc" != "0" ]; then
 
		cc_host="$distcc $cc_host"
 
		cxx_host="$distcc $cxx_host"
 
		log 1 ""
 
		log 1 " NOTICE: remind yourself to use 'make -jN' to make use of distcc"
 
		log 1 ""
 
	fi
 

	
 
	if [ "$with_ccache" != "0" ]; then
 
		cc_host="$ccache $cc_host"
 
		cxx_host="$ccache $cxx_host"
 
	fi
 
}
 

	
 
check_compiler() {
 
	# Params:
 
	# $1 - Type for message (build / host)
 
	# $2 - What to fill with the found compiler
 
	# $3 - System to try
 
	# $4 - Compiler to try
 
	# $5 - Env-setting to try
 
	# $6 - GCC alike to try
 
	# $7 - CC alike to try
 
	# $8 - "0" gcc, "1" g++, "2" windres, "3" strip, "4" lipo
 
	# $9 - What the command is to check for
 

	
 
	if [ -n "$3" ]; then
 
		# Check for system
 
		if [ -z "$6" ]; then
 
			compiler="$3"
 
		else
 
			compiler="$3-$6"
 
		fi
 
		machine=`eval $compiler $9 2>/dev/null`
 
		ret=$?
 
		eval "$2=$compiler"
 

	
 
		log 2 "executing $compiler $9"
 
		log 2 "  returned $machine"
 
		log 2 "  exit code $ret"
 

	
 
		if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
 
			log 1 "checking $1... $compiler not found"
 
			log 1 "I couldn't detect any $6 binary for $3"
 
			exit 1
 
		fi
 

	
 
		if [ "$machine" != "$3" ] && ( [ "$8" = "0" ] || [ "$8" = "1" ] ); then
 
			log 1 "checking $1... expected $3, found $machine"
 
			log 1 "the compiler suggests it doesn't build code for the machine you specified"
 
			exit 1
 
		fi
 
	elif [ -n "$4" ]; then
 
		# Check for manual compiler
 
		machine=`$4 $9 2>/dev/null`
 
		ret=$?
 
		eval "$2=$4"
 

	
 
		log 2 "executing $4 $9"
 
		log 2 "  returned $machine"
 
		log 2 "  exit code $ret"
 

	
 
		if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
 
			log 1 "checking $1... $4 not found"
 
			log 1 "the selected binary doesn't seem to be a $6 binary"
 
			exit 1
 
		fi
 
	else
 
		# Nothing given, autodetect
 

	
 
		if [ -n "$5" ]; then
 
			machine=`$5 $9 2>/dev/null`
 
			ret=$?
 
			eval "$2=$5"
 

	
 
			log 2 "executing $5 $9"
 
			log 2 "  returned $machine"
 
			log 2 "  exit code $ret"
 

	
 
			# The user defined a GCC that doesn't reply to $9.. abort
 
			if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
 
				log 1 "checking $1... $5 unusable"
 
				log 1 "the CC environment variable is set, but it doesn't seem to be a $6 binary"
 
				log 1 "please redefine the CC/CXX environment to a $6 binary"
 
				exit 1
 
			fi
 
		else
 
			log 2 "checking $1... CC/CXX not set (skipping)"
 

	
 
			# No $5, so try '$6'
 
			machine=`$6 $9 2>/dev/null`
 
			ret=$?
 
@@ -2511,291 +2511,291 @@ b"
 
b
 
c
 
d"
 

	
 
	log 2 "running echo <array> | $1"
 

	
 
	if [ "`echo \"$sort_test_in\" | $1 2>/dev/null`" = "$sort_test_out" ]; then
 
		sort="$1"
 
		log 2 "  result was valid"
 
	else
 
		log 2 "  result was invalid"
 
	fi
 
}
 

	
 
detect_sort() {
 
	if [ "$with_sort" = "0" ]; then
 
		log 1 "checking sort... disabled"
 

	
 
		return
 
	fi
 

	
 
	if [ "$with_sort" = "1" ] || [ "$with_sort" = "2" ]; then
 
		_detect_sort "sort"
 
		if [ -z "$sort" ]; then _detect_sort "/sbin/sort"; fi
 
		if [ -z "$sort" ]; then _detect_sort "/usr/sbin/sort"; fi
 
		if [ -z "$sort" ]; then _detect_sort "/usr/local/sbin/sort"; fi
 
		if [ -z "$sort" ]; then _detect_sort "/bin/sort"; fi
 
		if [ -z "$sort" ]; then _detect_sort "/usr/bin/sort"; fi
 
		if [ -z "$sort" ]; then _detect_sort "/usr/local/bin/sort"; fi
 
	else
 
		_detect_sort "$with_sort"
 
	fi
 

	
 
	if [ -z "$sort" ]; then
 
		if [ "$with_sort" = "2" ]; then
 
			log 1 "checking sort... not found"
 

	
 
			log 1 "configure: error: couldn't detect sort on your system"
 
			exit 1
 
		elif [ "$with_sort" != "1" ]; then
 
			log 1 "checking sort... $with_sort not found"
 

	
 
			log 1 "configure: error: '$with_sort' doesn't look like a sort to me"
 
			log 1 "configure: error: please verify its location and function and try again"
 

	
 
			exit 1
 
		else
 
			log 1 "checking sort... not found"
 
		fi
 
	else
 
		log 1 "checking sort... $sort"
 
	fi
 
}
 

	
 
detect_cputype() {
 
	if [ -n "$cpu_type" ] && [ "$cpu_type" != "DETECT" ]; then
 
		log 1 "forcing cpu-type... $cpu_type bits"
 
		return;
 
	fi
 
	echo "#define _SQ64 1" > tmp.64bit.cpp
 
	echo "#include \"src/stdafx.h\"" >> tmp.64bit.cpp
 
	echo "assert_compile(sizeof(size_t) == 8);" >> tmp.64bit.cpp
 
	echo "int main() { return 0; }" >> tmp.64bit.cpp
 
	execute="$cxx_host $CFLAGS tmp.64bit.cpp -o tmp.64bit -DTESTING 2>&1"
 
	cpu_type="`eval $execute 2>/dev/null`"
 
	ret=$?
 
	log 2 "executing $execute"
 
	log 2 "  returned $cpu_type"
 
	log 2 "  exit code $ret"
 
	if [ "$ret" = "0" ]; then cpu_type="64"; else cpu_type="32"; fi
 
	log 1 "detecting cpu-type... $cpu_type bits"
 
	rm -f tmp.64bit tmp.64bit.cpp
 
}
 

	
 
make_sed() {
 
	T_CFLAGS="$CFLAGS"
 
	T_LDFLAGS="$LDFLAGS"
 

	
 
	# We check here if we are PPC, because then we need to enable FOUR_BYTE_BOOL
 
	#  We do this here, and not sooner, so universal builds also have this
 
	#  automatically correct
 
	# FOUR_BYTE_BOOL is needed, because C++ uses 4byte for a bool on PPC, where
 
	#  we use 1 byte per bool normally in C part. So convert that last one to 4
 
	#  bytes too, but only for PPC.
 
	ppc=`$cc_host -dumpmachine | egrep "powerpc|ppc"`
 
	if [ -n "$ppc" ]; then
 
		T_CFLAGS="$T_CFLAGS -DFOUR_BYTE_BOOL"
 
	fi
 

	
 
	SRC_OBJS_DIR="$BASE_SRC_OBJS_DIR/$OBJS_SUBDIR"
 

	
 
	# All the data needed to compile a single target
 
	#  Make sure if you compile multiple targets to
 
	#  use multiple OBJS_DIR, because all in-between
 
	#  binaries are stored in there, and nowhere else.
 
	SRC_REPLACE="
 
		s~!!CC_HOST!!~$cc_host~g;
 
		s~!!CXX_HOST!!~$cxx_host~g;
 
		s~!!CC_BUILD!!~$cc_build~g;
 
		s~!!CXX_BUILD!!~$cxx_build~g;
 
		s~!!WINDRES!!~$windres~g;
 
		s~!!STRIP!!~$strip $strip_arg~g;
 
		s~!!LIPO!!~$lipo~g;
 
		s~!!CC_CFLAGS!!~$CC_CFLAGS~g;
 
		s~!!CFLAGS!!~$T_CFLAGS~g;
 
		s~!!CFLAGS_BUILD!!~$CFLAGS_BUILD~g;
 
		s~!!STRGEN_FLAGS!!~$strgen_flags~g;
 
		s~!!LIBS!!~$LIBS~g;
 
		s~!!LDFLAGS!!~$T_LDFLAGS~g;
 
		s~!!BIN_DIR!!~$BIN_DIR~g;
 
		s~!!ROOT_DIR!!~$ROOT_DIR~g;
 
		s~!!MEDIA_DIR!!~$MEDIA_DIR~g;
 
		s~!!SOURCE_LIST!!~$SOURCE_LIST~g;
 
		s~!!SRC_OBJS_DIR!!~$SRC_OBJS_DIR~g;
 
		s~!!LANG_OBJS_DIR!!~$LANG_OBJS_DIR~g;
 
		s~!!SRC_DIR!!~$SRC_DIR~g;
 
		s~!!SCRIPT_SRC_DIR!!~$SCRIPT_SRC_DIR~g;
 
		s~!!OSXAPP!!~$OSXAPP~g;
 
		s~!!LANG_DIR!!~$LANG_DIR~g;
 
		s~!!TTD!!~$TTD~g;
 
		s~!!BINARY_DIR!!~$prefix_dir/$binary_dir~g;
 
		s~!!DATA_DIR!!~$prefix_dir/$data_dir~g;
 
		s~!!DOC_DIR!!~$prefix_dir/$doc_dir~g;
 
		s~!!MAN_DIR!!~$prefix_dir/$man_dir~g;
 
		s~!!ICON_DIR!!~$prefix_dir/$icon_dir~g;
 
		s~!!ICON_THEME_DIR!!~$prefix_dir/$icon_theme_dir~g;
 
		s~!!PERSONAL_DIR!!~$personal_dir~g;
 
		s~!!SHARED_DIR!!~$shared_dir~g;
 
		s~!!INSTALL_DIR!!~$install_dir~g;
 
		s~!!BINARY_NAME!!~$binary_name~g;
 
		s~!!STRGEN!!~$STRGEN~g;
 
		s~!!ENDIAN_CHECK!!~$ENDIAN_CHECK~g;
 
		s~!!DEPEND!!~$DEPEND~g;
 
		s~!!ENDIAN_FORCE!!~$endian~g;
 
		s~!!STAGE!!~$STAGE~g;
 
		s~!!MAKEDEPEND!!~$makedepend~g;
 
		s~!!CFLAGS_MAKEDEP!!~$cflags_makedep~g;
 
		s~!!SORT!!~$sort~g;
 
		s~!!CONFIG_CACHE_COMPILER!!~config.cache.compiler~g;
 
		s~!!CONFIG_CACHE_LINKER!!~config.cache.linker~g;
 
		s~!!CONFIG_CACHE_ENDIAN!!~config.cache.endian~g;
 
		s~!!CONFIG_CACHE_SOURCE!!~config.cache.source~g;
 
		s~!!CONFIG_CACHE_VERSION!!~config.cache.version~g;
 
		s~!!CONFIG_CACHE_SOURCE_LIST!!~config.cache.source.list~g;
 
		s~!!CONFIG_CACHE_PWD!!~config.cache.pwd~g;
 
		s~!!LANG_SUPPRESS!!~$lang_suppress~g;
 
		s~!!OBJS_C!!~$OBJS_C~g;
 
		s~!!OBJS_CPP!!~$OBJS_CPP~g;
 
		s~!!OBJS_MM!!~$OBJS_MM~g;
 
		s~!!OBJS_RC!!~$OBJS_RC~g;
 
		s~!!SRCS!!~$SRCS~g;
 
		s~!!OS!!~$os~g;
 
		s~!!CONFIGURE_FILES!!~$CONFIGURE_FILES~g;
 
		s~!!REVISION!!~$revision~g;
 
		s~!!AWK!!~$awk~g;
 
		s~!!GCC295!!~$gcc295~g;
 
		s~!!DISTCC!!~$distcc~g;
 
		s@!!CC_HOST!!@$cc_host@g;
 
		s@!!CXX_HOST!!@$cxx_host@g;
 
		s@!!CC_BUILD!!@$cc_build@g;
 
		s@!!CXX_BUILD!!@$cxx_build@g;
 
		s@!!WINDRES!!@$windres@g;
 
		s@!!STRIP!!@$strip $strip_arg@g;
 
		s@!!LIPO!!@$lipo@g;
 
		s@!!CC_CFLAGS!!@$CC_CFLAGS@g;
 
		s@!!CFLAGS!!@$T_CFLAGS@g;
 
		s@!!CFLAGS_BUILD!!@$CFLAGS_BUILD@g;
 
		s@!!STRGEN_FLAGS!!@$strgen_flags@g;
 
		s@!!LIBS!!@$LIBS@g;
 
		s@!!LDFLAGS!!@$T_LDFLAGS@g;
 
		s@!!BIN_DIR!!@$BIN_DIR@g;
 
		s@!!ROOT_DIR!!@$ROOT_DIR@g;
 
		s@!!MEDIA_DIR!!@$MEDIA_DIR@g;
 
		s@!!SOURCE_LIST!!@$SOURCE_LIST@g;
 
		s@!!SRC_OBJS_DIR!!@$SRC_OBJS_DIR@g;
 
		s@!!LANG_OBJS_DIR!!@$LANG_OBJS_DIR@g;
 
		s@!!SRC_DIR!!@$SRC_DIR@g;
 
		s@!!SCRIPT_SRC_DIR!!@$SCRIPT_SRC_DIR@g;
 
		s@!!OSXAPP!!@$OSXAPP@g;
 
		s@!!LANG_DIR!!@$LANG_DIR@g;
 
		s@!!TTD!!@$TTD@g;
 
		s@!!BINARY_DIR!!@$prefix_dir/$binary_dir@g;
 
		s@!!DATA_DIR!!@$prefix_dir/$data_dir@g;
 
		s@!!DOC_DIR!!@$prefix_dir/$doc_dir@g;
 
		s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
 
		s@!!ICON_DIR!!@$prefix_dir/$icon_dir@g;
 
		s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
 
		s@!!PERSONAL_DIR!!@$personal_dir@g;
 
		s@!!SHARED_DIR!!@$shared_dir@g;
 
		s@!!INSTALL_DIR!!@$install_dir@g;
 
		s@!!BINARY_NAME!!@$binary_name@g;
 
		s@!!STRGEN!!@$STRGEN@g;
 
		s@!!ENDIAN_CHECK!!@$ENDIAN_CHECK@g;
 
		s@!!DEPEND!!@$DEPEND@g;
 
		s@!!ENDIAN_FORCE!!@$endian@g;
 
		s@!!STAGE!!@$STAGE@g;
 
		s@!!MAKEDEPEND!!@$makedepend@g;
 
		s@!!CFLAGS_MAKEDEP!!@$cflags_makedep@g;
 
		s@!!SORT!!@$sort@g;
 
		s@!!CONFIG_CACHE_COMPILER!!@config.cache.compiler@g;
 
		s@!!CONFIG_CACHE_LINKER!!@config.cache.linker@g;
 
		s@!!CONFIG_CACHE_ENDIAN!!@config.cache.endian@g;
 
		s@!!CONFIG_CACHE_SOURCE!!@config.cache.source@g;
 
		s@!!CONFIG_CACHE_VERSION!!@config.cache.version@g;
 
		s@!!CONFIG_CACHE_SOURCE_LIST!!@config.cache.source.list@g;
 
		s@!!CONFIG_CACHE_PWD!!@config.cache.pwd@g;
 
		s@!!LANG_SUPPRESS!!@$lang_suppress@g;
 
		s@!!OBJS_C!!@$OBJS_C@g;
 
		s@!!OBJS_CPP!!@$OBJS_CPP@g;
 
		s@!!OBJS_MM!!@$OBJS_MM@g;
 
		s@!!OBJS_RC!!@$OBJS_RC@g;
 
		s@!!SRCS!!@$SRCS@g;
 
		s@!!OS!!@$os@g;
 
		s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
 
		s@!!REVISION!!@$revision@g;
 
		s@!!AWK!!@$awk@g;
 
		s@!!GCC295!!@$gcc295@g;
 
		s@!!DISTCC!!@$distcc@g;
 
	"
 

	
 
	if [ "$icon_theme_dir" != "" ]; then
 
		SRC_REPLACE="$SRC_REPLACE
 
			s~!!ICON_THEME_DIR!!~$prefix_dir/$icon_theme_dir~g;
 
			s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
 
		"
 
	else
 
		SRC_REPLACE="$SRC_REPLACE
 
			s~!!ICON_THEME_DIR!!~~g;
 
			s@!!ICON_THEME_DIR!!@@g;
 
		"
 
	fi
 

	
 
	if [ "$man_dir" != "" ]; then
 
		SRC_REPLACE="$SRC_REPLACE
 
			s~!!MAN_DIR!!~$prefix_dir/$man_dir~g;
 
			s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
 
		"
 
	else
 
		SRC_REPLACE="$SRC_REPLACE
 
			s~!!MAN_DIR!!~~g;
 
			s@!!MAN_DIR!!@@g;
 
		"
 
	fi
 

	
 
	if [ "$menu_dir" != "" ]; then
 
		SRC_REPLACE="$SRC_REPLACE
 
			s~!!MENU_DIR!!~$prefix_dir/$menu_dir~g;
 
			s@!!MENU_DIR!!@$prefix_dir/$menu_dir@g;
 
		"
 
	else
 
		SRC_REPLACE="$SRC_REPLACE
 
			s~!!MENU_DIR!!~~g;
 
			s@!!MENU_DIR!!@@g;
 
		"
 
	fi
 
}
 

	
 
generate_menu_item() {
 
	MENU_REPLACE="
 
		s~!!TTD!!~$TTD~g;
 
		s~!!MENU_GROUP!!~$menu_group~g;
 
		s~!!MENU_NAME!!~$menu_name~g
 
		s@!!TTD!!@$TTD@g;
 
		s@!!MENU_GROUP!!@$menu_group@g;
 
		s@!!MENU_NAME!!@$menu_name@g
 
	"
 
	log 1 "Generating menu item..."
 
	mkdir -p media
 
	< $ROOT_DIR/media/openttd.desktop.in sed "$MENU_REPLACE" > media/openttd.desktop
 
}
 

	
 
generate_main() {
 
	STAGE="[MAIN]"
 

	
 
	make_sed
 

	
 
	# Create the main Makefile
 
	log 1 "Generating Makefile..."
 
	echo "# Auto-generated file from 'Makefile.in' -- DO NOT EDIT" > Makefile
 
	< $ROOT_DIR/Makefile.in sed "$SRC_REPLACE" >> Makefile
 
	cp $ROOT_DIR/Makefile.bundle.in Makefile.bundle
 
	echo "# Auto-generated file -- DO NOT EDIT" > Makefile.am
 
	echo >> Makefile.am
 
	# Make the copy of the source-list, so we don't trigger an unwanted recompile
 
	cp $SOURCE_LIST config.cache.source.list
 
	# Add the current directory, so we don't trigger an unwanted recompile
 
	echo "`pwd`" > config.cache.pwd
 
	# Make sure config.cache is OLDER then config.cache.source.list
 
	touch config.cache
 
	touch config.pwd
 

	
 
	if [ "$menu_dir" != "" ]; then
 
		generate_menu_item
 
	fi
 
}
 

	
 
generate_lang() {
 
	STAGE="[LANG]"
 

	
 
	make_sed
 

	
 
	# Create the language file
 
	mkdir -p $LANG_OBJS_DIR
 

	
 
	log 1 "Generating lang/Makefile..."
 
	echo "# Auto-generated file from 'Makefile.lang.in' -- DO NOT EDIT" > $LANG_OBJS_DIR/Makefile
 
	< $ROOT_DIR/Makefile.lang.in sed "$SRC_REPLACE" >> $LANG_OBJS_DIR/Makefile
 
	echo "DIRS += $LANG_OBJS_DIR" >> Makefile.am
 
	echo "LANG_DIRS += $LANG_OBJS_DIR" >> Makefile.am
 
}
 

	
 
generate_src_normal() {
 
	STAGE=$1
 

	
 
	make_sed
 

	
 
	# Create the source file
 
	mkdir -p $SRC_OBJS_DIR
 

	
 
	log 1 "Generating $2/Makefile..."
 
	echo "# Auto-generated file from 'Makefile.src.in' -- DO NOT EDIT" > $SRC_OBJS_DIR/Makefile
 
	< $ROOT_DIR/Makefile.src.in sed "$SRC_REPLACE" >> $SRC_OBJS_DIR/Makefile
 
	echo "DIRS += $SRC_OBJS_DIR" >> Makefile.am
 
	echo "SRC_DIRS += $SRC_OBJS_DIR" >> Makefile.am
 
}
 

	
 
generate_src_osx() {
 
	CLEAN_CFLAGS="$CFLAGS"
 
	CLEAN_LDFLAGS="$LDFLAGS"
 
	cc_host_orig="$cc_host"
 
	cxx_host_orig="$cxx_host"
 

	
 
	BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc"
 
	cc_host="$cc_host_orig -arch ppc -mmacosx-version-min=10.3"
 
	cxx_host="$cxx_host_orig -arch ppc -mmacosx-version-min=10.3"
 
	generate_src_normal "[PowerPC]" "objs/ppc"
 

	
 
	BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc970"
 
	cc_host="$cc_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
 
	cxx_host="$cxx_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
 
	generate_src_normal "[PowerPC G5]" "objs/ppc970"
 

	
 
	BASE_SRC_OBJS_DIR="$OBJS_DIR/intel"
 
	cc_host="$cc_host_orig -arch i386 -mmacosx-version-min=10.4"
 
	cxx_host="$cxx_host_orig -arch i386 -mmacosx-version-min=10.4"
 
	generate_src_normal "[Intel]" "objs/intel"
 

	
 
	if [ "$enable_universal" = "64" ]; then
 
		# 64 bits is always 10.5 or higher. Furthermore it has a broken ICONV
 
		# and they also removed support for QuickTime/QuickDraw
 
		CFLAGS="$CFLAGS -D_SQ64 -DHAVE_BROKEN_ICONV -DNO_QUICKTIME -UENABLE_COCOA_QUICKDRAW"
 
		LIBS="`echo $LIBS | sed 's/-framework QuickTime//'`"
 

	
 
		BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc64"
 
		cc_host="$cc_host_orig -arch ppc64 -mmacosx-version-min=10.5"
 
		cxx_host="$cxx_host_orig -arch ppc64 -mmacosx-version-min=10.5"
 
		generate_src_normal "[PowerPC 64 bits]" "objs/ppc64"
 

	
 
		BASE_SRC_OBJS_DIR="$OBJS_DIR/intel64"
 
		cc_host="$cc_host_orig -arch x86_64 -mmacosx-version-min=10.5"
 
		cxx_host="$cxx_host_orig -arch x86_64 -mmacosx-version-min=10.5"
configure
Show inline comments
 
#!/bin/sh
 

	
 
check_path_characters() {
 
	if [ -n "`echo $ROOT_DIR | grep '[^-_A-Za-z0-9\/\\\.:]'`" ]; then
 
		echo "WARNING: The path contains a non-alphanumeric character that might cause"
 
		echo "         failures in subsequent build stages. Any failures with the build"
 
		echo "         will most likely be caused by this."
 
	fi
 
}
 

	
 
CONFIGURE_EXECUTABLE="$_"
 
# On *nix systems those two are equal when ./configure is done
 
if [ "$0" != "$CONFIGURE_EXECUTABLE" ]; then
 
	# On some systems, when ./configure is triggered from 'make'
 
	#  the $_ is filled with 'make'. So if that is true, skip 'make'
 
	#  and use $0 (and hope that is correct ;))
 
	if [ -n "`echo $CONFIGURE_EXECUTABLE | grep make`" ]; then
 
		CONFIGURE_EXECUTABLE="$0"
 
	else
 
		CONFIGURE_EXECUTABLE="$CONFIGURE_EXECUTABLE $0"
 
	fi
 
fi
 
# Find out where configure is (in what dir)
 
ROOT_DIR="`dirname $0`"
 
ROOT_DIR="`cd $ROOT_DIR && pwd`"
 

	
 
check_path_characters
 

	
 
PWD="`pwd`"
 
PREFIX="$PWD/bin"
 

	
 
. $ROOT_DIR/config.lib
 

	
 
# Set default dirs
 
OBJS_DIR="$PWD/objs"
 
BASE_SRC_OBJS_DIR="$OBJS_DIR"
 
LANG_OBJS_DIR="$OBJS_DIR/lang"
 
BIN_DIR="$PREFIX"
 
SRC_DIR="$ROOT_DIR/src"
 
LANG_DIR="$SRC_DIR/lang"
 
MEDIA_DIR="$ROOT_DIR/media"
 
SOURCE_LIST="$ROOT_DIR/source.list"
 

	
 
if [ "$1" = "--reconfig" ] || [ "$1" = "--reconfigure" ]; then
 
	if [ ! -f "config.cache" ]; then
 
		echo "can't reconfigure, because never configured before"
 
		exit 1
 
	fi
 
	# Make sure we don't lock config.cache
 
	cat config.cache | sed 's~\\ ~\\\\ ~g' > cache.tmp
 
	cat config.cache | sed 's@\\ @\\\\ @g' > cache.tmp
 
	sh cache.tmp
 
	rm -f cache.tmp
 
	exit $?
 
fi
 

	
 
set_default
 
detect_params "$@"
 
check_params
 
save_params
 
make_cflags_and_ldflags
 

	
 
EXE=""
 
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "OS2" ] || [ "$os" = "DOS" ] || [ "$os" = "WINCE" ]; then
 
	EXE=".exe"
 
fi
 

	
 
TTD="openttd$EXE"
 
STRGEN="strgen$EXE"
 
ENDIAN_CHECK="endian_check$EXE"
 
DEPEND="depend$EXE"
 

	
 
if [ -z "$sort" ]; then
 
	PIPE_SORT="sed s~a~a~"
 
	PIPE_SORT="sed s@a@a@"
 
else
 
	PIPE_SORT="$sort"
 
fi
 

	
 
if [ ! -f "$LANG_DIR/english.txt" ]; then
 
	echo "Languages not found in $LANG_DIR. Can't continue without it."
 
	echo "Please make sure the dir exists and contains at least english.txt"
 
fi
 

	
 
# Read the source.list and process it
 
SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | $awk '
 
	{  }
 
	/^(	*)#end/  { if (deep == skip) { skip -= 1; } deep -= 1; next; }
 
	/^(	*)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
 
	/^(	*)#if/   {
 
		gsub("	", "", $0);
 
		gsub("^#if ", "", $0);
 

	
 
		if (deep != skip) { deep += 1; next; }
 

	
 
		deep += 1;
 

	
 
		if ($0 == "ALLEGRO"     && "'$allegro_config'" == "")      { next; }
 
		if ($0 == "SDL"         && "'$sdl_config'" == "")          { next; }
 
		if ($0 == "PNG"         && "'$png_config'" == "")          { next; }
 
		if ($0 == "OSX"         && "'$os'" != "OSX")               { next; }
 
		if ($0 == "OS2"         && "'$os'" != "OS2")               { next; }
 
		if ($0 == "PSP"         && "'$os'" != "PSP")               { next; }
 
		if ($0 == "DEDICATED"   && "'$enable_dedicated'" != "1")   { next; }
 
		if ($0 == "COCOA"       && "'$with_cocoa'" == "0")         { next; }
 
		if ($0 == "DOS"         && "'$os'" != "DOS")               { next; }
 
		if ($0 == "BEOS"        && "'$os'" != "BEOS")              { next; }
 
		if ($0 == "WIN32"       && "'$os'" != "MINGW" &&
 
		                "'$os'" != "CYGWIN" && "'$os'" != "MSVC" ) { next; }
 
		if ($0 == "MORPHOS"     && "'$os'" != "MORPHOS")           { next; }
 
		if ($0 == "WINCE"       && "'$os'" != "WINCE")             { next; }
 
		if ($0 == "MSVC"        && "'$os'" != "MSVC")              { next; }
 
		if ($0 == "DIRECTMUSIC" && "'$with_direct_music'" == "0")  { next; }
 
		if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" )        { next; }
 
		if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0")       { next; }
 

	
 
		skip += 1;
 

	
 
		next;
 
	}
 
	/^(	*)#/ { next }
 
	/^$/ { next }
 
	/\.h$/ { next }
 
	/\.hpp$/ { next }
 
	{
 
		if (deep == skip) {
 
			gsub("	", "", $0);
 
			print $0;
 
		}
 
	}
 
' | $PIPE_SORT`"
 

	
 
OBJS_C="`  echo \"$SRCS\" | $awk ' { ORS = " " } /\.c$/   { gsub(".c$",   ".o", $0); print $0; }'`"
 
OBJS_CPP="`echo \"$SRCS\" | $awk ' { ORS = " " } /\.cpp$/ { gsub(".cpp$", ".o", $0); print $0; }'`"
 
OBJS_MM="` echo \"$SRCS\" | $awk ' { ORS = " " } /\.mm$/  { gsub(".mm$",  ".o", $0); print $0; }'`"
 
OBJS_RC="` echo \"$SRCS\" | $awk ' { ORS = " " } /\.rc$/  { gsub(".rc$",  ".o", $0); print $0; }'`"
 
SRCS="`    echo \"$SRCS\" | $awk ' { ORS = " " } { print $0; }'`"
 

	
 
# In makefiles, we always use -u for sort
 
if [ -z "$sort" ]; then
 
	sort="sed s~a~a~"
 
	sort="sed s@a@a@"
 
else
 
	sort="$sort -u"
 
fi
 

	
 
CONFIGURE_FILES="$ROOT_DIR/configure $ROOT_DIR/config.lib $ROOT_DIR/Makefile.in $ROOT_DIR/Makefile.lang.in $ROOT_DIR/Makefile.src.in $ROOT_DIR/Makefile.bundle.in"
 

	
 
generate_main
 
generate_lang
 
generate_src
 

	
 
check_path_characters
findversion.sh
Show inline comments
 
#!/bin/sh
 

	
 
# $Id$
 

	
 
# Arguments given? Show help text.
 
if [ "$#" != "0" ]; then
 
	cat <<EOF
 
Usage: ./findversion.sh
 
Finds the current revision and if the code is modified.
 

	
 
Output: <REV>\t<REV_NR>\t<MODIFIED>\t<CLEAN_REV>
 
REV
 
    a string describing what version of the code the current checkout is
 
    based on. The exact format of this string depends on the version
 
    control system in use, but it tries to identify the revision used as
 
    close as possible (using the svn revision number or hg/git hash).
 
    This also includes an indication of whether the checkout was
 
    modified and which branch was checked out. This value is not
 
    guaranteed to be sortable, but is mainly meant for identifying the
 
    revision and user display.
 

	
 
    If no revision identifier could be found, this is left empty.
 
REV_NR
 
    the revision number of the svn revision this checkout is based on.
 
    This can be used to determine which functionality is present in this
 
    checkout. For trunk svn checkouts and hg/git branches based upon it,
 
    this number should be accurate. For svn branch checkouts, this
 
    number is mostly meaningless, at least when comparing with the
 
    REV_NR from other branches or trunk.
 

	
 
    This number should be sortable. Within a given branch or trunk, a
 
    higher number means a newer version. However, when using git or hg,
 
    this number will not increase on new commits.
 

	
 
    If no revision number could be found, this is left empty.
 
MODIFIED
 
    Whether (the src directory of) this checkout is modified or not. A
 
    value of 0 means not modified, a value of 2 means it was modified.
 
    Modification is determined in relation to the commit identified by
 
    REV, so not in relation to the svn revision identified by REV_NR.
 

	
 
    A value of 1 means that the modified status is unknown, because this
 
    is not an svn/git/hg checkout for example.
 

	
 
CLEAN_REV
 
    the same as REV but without branch name
 

	
 
By setting the AWK environment variable, a caller can determine which
 
version of "awk" is used. If nothing is set, this script defaults to
 
"awk".
 
EOF
 
exit 1;
 
fi
 

	
 
# Allow awk to be provided by the caller.
 
if [ -z "$AWK" ]; then
 
	AWK=awk
 
fi
 

	
 
# Find out some dirs
 
cd `dirname "$0"`
 
ROOT_DIR=`pwd`
 
SRC_DIR=src
 

	
 
# Determine if we are using a modified version
 
# Assume the dir is not modified
 
MODIFIED="0"
 
if [ -d "$ROOT_DIR/.svn" ]; then
 
	# We are an svn checkout
 
	if [ -n "`svnversion \"$SRC_DIR\" | grep 'M'`" ]; then
 
		MODIFIED="2"
 
	fi
 
	# Find the revision like: rXXXXM-branch
 
	BRANCH=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^URL:.*branches/ { split($2, a, "/"); for(i in a) if (a[i]=="branches") { print a[i+1]; break } }'`
 
	TAG=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^URL:.*tags/ { split($2, a, "/"); for(i in a) if (a[i]=="tags") { print a[i+1]; break } }'`
 
	REV_NR=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^Last Changed Rev:/ { print $4 }'`
 
	if [ -n "$TAG" ]; then
 
		REV=$TAG
 
	else
 
		REV="r$REV_NR"
 
	fi
 
elif [ -d "$ROOT_DIR/.git" ]; then
 
	# We are a git checkout
 
	if [ -n "`git diff-index HEAD \"$SRC_DIR\"`" ]; then
 
		MODIFIED="2"
 
	fi
 
	HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
 
	REV="g`echo $HASH | cut -c1-8`"
 
	BRANCH=`git branch|grep '[*]' | sed 's~\* ~~;s~^master$~~'`
 
	REV_NR=`LC_ALL=C git log --pretty=format:%s "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s~.*(svn r\([0-9]*\)).*~\1~"`
 
	BRANCH=`git branch|grep '[*]' | sed 's@\* @@;s@^master$@@'`
 
	REV_NR=`LC_ALL=C git log --pretty=format:%s "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"`
 
elif [ -d "$ROOT_DIR/.hg" ]; then
 
	# We are a hg checkout
 
	if [ -n "`hg status \"$SRC_DIR\" | grep -v '^?'`" ]; then
 
		MODIFIED="2"
 
	fi
 
	HASH=`LC_ALL=C hg parents 2>/dev/null | head -n 1 | cut -d: -f3`
 
	REV="h`echo $HASH | cut -c1-8`"
 
	BRANCH=`hg branch | sed 's~^default$~~'`
 
	REV_NR=`LC_ALL=C hg log -r $HASH:0 -k "svn" -l 1 --template "{desc}\n" "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s~.*(svn r\([0-9]*\)).*~\1~"`
 
	BRANCH=`hg branch | sed 's@^default$@@'`
 
	REV_NR=`LC_ALL=C hg log -r $HASH:0 -k "svn" -l 1 --template "{desc}\n" "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"`
 
else
 
	# We don't know
 
	MODIFIED="1"
 
	BRANCH=""
 
	REV=""
 
	REV_NR=""
 
fi
 

	
 
if [ "$MODIFIED" -eq "2" ]; then
 
	REV="${REV}M"
 
fi
 

	
 
CLEAN_REV=${REV}
 

	
 
if [ -n "$BRANCH" ]; then
 
	REV="${REV}-$BRANCH"
 
fi
 

	
 
echo "$REV	$REV_NR	$MODIFIED	$CLEAN_REV"
projects/determineversion.vbs
Show inline comments
 
Option Explicit
 

	
 
Dim FSO
 
Set FSO = CreateObject("Scripting.FileSystemObject")
 

	
 
Sub FindReplaceInFile(filename, to_find, replacement)
 
	Dim file, data
 
	Set file = FSO.OpenTextFile(filename, 1, 0, 0)
 
	data = file.ReadAll
 
	file.Close
 
	data = Replace(data, to_find, replacement)
 
	Set file = FSO.CreateTextFile(filename, -1, 0)
 
	file.Write data
 
	file.Close
 
End Sub
 

	
 
Sub UpdateFile(modified, revision, version, cur_date, filename)
 
	FSO.CopyFile filename & ".in", filename
 
	FindReplaceInFile filename, "@@MODIFIED@@", modified
 
	FindReplaceInFile filename, "@@REVISION@@", revision
 
	FindReplaceInFile filename, "@@VERSION@@", version
 
	FindReplaceInFile filename, "@@DATE@@", cur_date
 
	FindReplaceInFile filename, "!!MODIFIED!!", modified
 
	FindReplaceInFile filename, "!!REVISION!!", revision
 
	FindReplaceInFile filename, "!!VERSION!!", version
 
	FindReplaceInFile filename, "!!DATE!!", cur_date
 
End Sub
 

	
 
Sub UpdateFiles(version)
 
	Dim modified, revision, cur_date
 
	cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
 

	
 
	If InStr(version, Chr(9)) Then
 
		revision = Mid(version, InStr(version, Chr(9)) + 1)
 
		revision = Mid(revision, 1, InStr(revision, Chr(9)) - 1)
 
		modified = Mid(version, InStrRev(version, Chr(9)) + 1)
 
		version  = Mid(version, 1, InStr(version, Chr(9)) - 1)
 
	Else
 
		revision = 0
 
		modified = 1
 
	End If
 

	
 
	UpdateFile modified, revision, version, cur_date, "../src/rev.cpp"
 
	UpdateFile modified, revision, version, cur_date, "../src/ottdres.rc"
 
End Sub
 

	
 
Function ReadRegistryKey(shive, subkey, valuename, architecture)
 
	Dim hiveKey, objCtx, objLocator, objServices, objReg, Inparams, Outparams
 

	
 
	' First, get the Registry Provider for the requested architecture
 
	Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
 
	objCtx.Add "__ProviderArchitecture", architecture ' Must be 64 of 32
 
	Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
 
	Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx)
 
	Set objReg = objServices.Get("StdRegProv")
 

	
 
	' Check the hive and give it the right value
 
	Select Case shive
 
		Case "HKCR", "HKEY_CLASSES_ROOT"
 
			hiveKey = &h80000000
 
		Case "HKCU", "HKEY_CURRENT_USER"
 
			hiveKey = &H80000001
 
		Case "HKLM", "HKEY_LOCAL_MACHINE"
 
			hiveKey = &h80000002
 
		Case "HKU", "HKEY_USERS"
 
			hiveKey = &h80000003
 
		Case "HKCC", "HKEY_CURRENT_CONFIG"
 
			hiveKey = &h80000005
 
		Case "HKDD", "HKEY_DYN_DATA" ' Only valid for Windows 95/98
 
			hiveKey = &h80000006
 
		Case Else
 
			MsgBox "Hive not valid (ReadRegistryKey)"
 
	End Select
 

	
 
	Set Inparams = objReg.Methods_("GetStringValue").Inparameters
 
	Inparams.Hdefkey = hiveKey
 
	Inparams.Ssubkeyname = subkey
 
	Inparams.Svaluename = valuename
 
	Set Outparams = objReg.ExecMethod_("GetStringValue", Inparams,,objCtx)
 

	
 
	ReadRegistryKey = Outparams.SValue
 
End Function
 

	
 
Function DetermineSVNVersion()
 
	Dim WshShell, version, branch, modified, revision, url, oExec, line, hash
 
	Set WshShell = CreateObject("WScript.Shell")
 
	On Error Resume Next
 

	
 
	revision = 0
 

	
 
	' Try TortoiseSVN
 
	' Get the directory where TortoiseSVN (should) reside(s)
 
	Dim sTortoise
 
	' First, try with 32-bit architecture
 
	sTortoise = ReadRegistryKey("HKLM", "SOFTWARE\TortoiseSVN", "Directory", 32)
 
	If sTortoise = "" Then
 
		' No 32-bit version of TortoiseSVN installed, try 64-bit version (doesn't hurt on 32-bit machines, it returns nothing or is ignored)
 
		sTortoise = ReadRegistryKey("HKLM", "SOFTWARE\TortoiseSVN", "Directory", 64)
 
	End If
 

	
 
	' If TortoiseSVN is installed, try to get the revision number
 
	If sTortoise <> "" Then
 
		Dim SubWCRev
 
		Set SubWCRev = WScript.CreateObject("SubWCRev.object")
 
		SubWCRev.GetWCInfo FSO.GetAbsolutePathName("../src"), 0, 0
 
		revision = SubWCRev.Revision
 
		version = "r" & revision
 
		modified = 0
 
		if SubWCRev.HasModifications then modified = 2
 
		url = SubWCRev.Url
 
	End If
 

	
 
	' Looks like there is no TortoiseSVN installed either. Then we don't know it.
 
	If revision = 0 Then
 
		' Reset error and version
 
		Err.Clear
 
		version = "norev000"
 
		modified = 0
 

	
 
		' Set the environment to english
 
		WshShell.Environment("PROCESS")("LANG") = "en"
 

	
src/ottdres.rc.in
Show inline comments
 
//Microsoft Developer Studio generated resource script.
 
// $Id$
 
//
 
/////////////////////////////////////////////////////////////////////////////
 
//
 
// Generated from the TEXTINCLUDE 2 resource.
 
//
 
#define APSTUDIO_READONLY_SYMBOLS
 
#define APSTUDIO_HIDDEN_SYMBOLS
 
#include "windows.h"
 
#undef APSTUDIO_HIDDEN_SYMBOLS
 
#ifdef MSVC
 
#include "winres.h"
 
#else
 
#define IDC_STATIC              (-1)     // all static controls
 
#endif
 

	
 
/////////////////////////////////////////////////////////////////////////////
 
#undef APSTUDIO_READONLY_SYMBOLS
 

	
 
/////////////////////////////////////////////////////////////////////////////
 
// Neutral (Default) resources
 

	
 
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
 
#ifdef _WIN32
 
LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
 
#pragma code_page(1252)
 
#endif //_WIN32
 

	
 
/////////////////////////////////////////////////////////////////////////////
 
//
 
// Icon
 
//
 

	
 
// Icon with lowest ID value placed first to ensure application icon
 
// remains consistent on all systems.
 
100                     ICON    DISCARDABLE     "../media/openttd.ico"
 

	
 
/////////////////////////////////////////////////////////////////////////////
 
//
 
// Dialog
 
//
 

	
 
100 DIALOG DISCARDABLE  0, 0, 305, 77
 
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 
CAPTION "Fatal Application Failure"
 
FONT 8, "MS Sans Serif"
 
BEGIN
 
    PUSHBUTTON      "&Close",12,7,58,50,14
 
//    PUSHBUTTON      "&Submit report",14,81,58,68,14,WS_DISABLED
 
    PUSHBUTTON      "&Emergency save",13,155,58,68,14
 
    PUSHBUTTON      "",15,243,58,55,14
 
    EDITTEXT        11,7,79,291,118,ES_MULTILINE | ES_READONLY | WS_VSCROLL |
 
                    WS_HSCROLL | NOT WS_TABSTOP
 
    LTEXT           "",10,36,7,262,43
 
    ICON            100,IDC_STATIC,9,9,20,20
 
END
 

	
 

	
 
#ifndef _MAC
 
/////////////////////////////////////////////////////////////////////////////
 
//
 
// Version
 
//
 

	
 
VS_VERSION_INFO VERSIONINFO
 
 FILEVERSION 0,8,0,@@REVISION@@
 
 PRODUCTVERSION 0,8,0,@@REVISION@@
 
 FILEVERSION 0,8,0,!!REVISION!!
 
 PRODUCTVERSION 0,8,0,!!REVISION!!
 
 FILEFLAGSMASK 0x3fL
 
#ifdef _DEBUG
 
 FILEFLAGS 0x1L
 
#else
 
 FILEFLAGS 0x0L
 
#endif
 
 FILEOS 0x4L
 
 FILETYPE 0x1L
 
 FILESUBTYPE 0x0L
 
BEGIN
 
    BLOCK "StringFileInfo"
 
    BEGIN
 
        BLOCK "000004b0"
 
        BEGIN
 
            VALUE "Comments", "This program is licensed under the GNU General Public License.\0"
 
            VALUE "CompanyName", "OpenTTD Development Team\0"
 
            VALUE "FileDescription", "OpenTTD\0"
 
            VALUE "FileVersion", "Development @@VERSION@@\0"
 
            VALUE "FileVersion", "Development !!VERSION!!\0"
 
            VALUE "InternalName", "openttd\0"
 
            VALUE "LegalCopyright", "Copyright \xA9 OpenTTD Developers 2002-2009. All Rights Reserved.\0"
 
            VALUE "LegalTrademarks", "\0"
 
            VALUE "OriginalFilename", "openttd.exe\0"
 
            VALUE "PrivateBuild", "\0"
 
            VALUE "ProductName", "OpenTTD\0"
 
            VALUE "ProductVersion", "Development @@VERSION@@\0"
 
            VALUE "ProductVersion", "Development !!VERSION!!\0"
 
            VALUE "SpecialBuild", "-\0"
 
        END
 
    END
 
    BLOCK "VarFileInfo"
 
    BEGIN
 
        VALUE "Translation", 0x0, 1200
 
    END
 
END
 

	
 
#endif    // !_MAC
 

	
 
#endif    // Neutral (Default) resources
 
/////////////////////////////////////////////////////////////////////////////
src/rev.cpp.in
Show inline comments
 
/* $Id$ */
 

	
 
/** @file rev.cpp Autogenerated file with the revision and such of OpenTTD. */
 

	
 
#include "stdafx.h"
 
#include "rev.h"
 

	
 
/**
 
 * The text version of OpenTTD's revision.
 
 * This will be either "<major>.<minor>.<build>[-RC<rc>]",
 
 * "r<revision number>[M][-<branch>]" or "norev000".
 
 *
 
 * The major, minor and build are the numbers that describe releases of
 
 * OpenTTD (like 0.5.3). "-RC" is used to flag release candidates.
 
 *
 
 * The revision number is fairly straight forward. The M is to show that
 
 * the binary is made from modified source code. The branch shows the
 
 * branch the revision is of and will not be there when it is trunk.
 
 *
 
 * norev000 is for non-releases that are made on systems without
 
 * subversion or sources that are not a checkout of subversion.
 
 */
 
const char _openttd_revision[] = "@@VERSION@@";
 
const char _openttd_revision[] = "!!VERSION!!";
 

	
 
/**
 
 * Let us know if current build was modified. This detection
 
 * works even in the case when revision string is overriden by
 
 * --revision argument.
 
 * Value 0 means no modification, 1 is for unknown state
 
 * (compiling from sources without any version control software)
 
 * and 2 is for modified revision.
 
 */
 
const byte _openttd_revision_modified = @@MODIFIED@@;
 
const byte _openttd_revision_modified = !!MODIFIED!!;
 

	
 
/**
 
 * The NewGRF revision of OTTD:
 
 * bits  meaning.
 
 * 28-31 major version
 
 * 24-27 minor version
 
 * 20-23 build
 
 *    19 1 if it is a release, 0 if it is not.
 
 *  0-18 revision number; 0 for releases and when the revision is unknown.
 
 *
 
 * The 19th bit is there so the development/betas/alpha, etc. leading to a
 
 * final release will always have a lower version number than the released
 
 * version, thus making comparisions on specific revisions easy.
 
 */
 
const uint32 _openttd_newgrf_version = 0 << 28 | 8 << 24 | 0 << 20 | 0 << 19 | (@@REVISION@@ & ((1 << 19) - 1));
 
const uint32 _openttd_newgrf_version = 0 << 28 | 8 << 24 | 0 << 20 | 0 << 19 | (!!REVISION!! & ((1 << 19) - 1));
 

	
 
#ifdef __MORPHOS__
 
/**
 
 * Variable used by MorphOS to show the version.
 
 */
 
extern const char morphos_versions_tag[] = "$VER: OpenTTD @@VERSION@@ (@@DATE@@) OpenTTD Team [MorphOS, PowerPC]";
 
extern const char morphos_versions_tag[] = "$VER: OpenTTD !!VERSION!! (!!DATE!!) OpenTTD Team [MorphOS, PowerPC]";
 
#endif
0 comments (0 inline, 0 general)