Changeset - r5475:3f5cd13d1b63
[Not reviewed]
master
! ! !
rubidium - 18 years ago 2007-01-02 19:19:48
rubidium@openttd.org
(svn r7759) -Merge: makefile rewrite. This merge features:
- A proper ./configure, so everything needs to be configured only once, not for every make.
- Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies.
- A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC.
- Proper support for OSX universal binaries.
- Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files.
- Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files.

Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy.
12 files changed:
0 comments (0 inline, 0 general)
Makefile
Show inline comments
 
deleted file
Makefile.in
Show inline comments
 
new file 100644
 
# Auto-generated file -- DO NOT EDIT
 

	
 
# 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!!
 
CONFIGURE_FILES = !!CONFIGURE_FILES!!
 
LIPO = !!LIPO!!
 
BIN_DIR = !!BIN_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_ICON_DIR = "$(INSTALL_DIR)/"!!ICON_DIR!!
 
INSTALL_DATA_DIR = "$(INSTALL_DIR)/"!!DATA_DIR!!
 
INSTALL_PERSONAL_DIR = !!PERSONAL_DIR!!
 
# TODO: ENABLE_INSTALL should be removed when the search path patch has been applied
 
ENABLE_INSTALL = !!ENABLE_INSTALL!!
 
TTD = !!TTD!!
 
TTDS = $(SRC_DIRS:%=%/$(TTD))
 
OS = !!OS!!
 
OSXAPP = !!OSXAPP!!
 

	
 
RES := $(shell if ! [ -f $(CONFIG_CACHE_SOURCE_LIST) ] || [ -n "`cmp $(CONFIG_CACHE_SOURCE_LIST) $(SOURCE_LIST)`" ]; then cp $(SOURCE_LIST) $(CONFIG_CACHE_SOURCE_LIST); fi )
 

	
 
all: config.cache
 
	@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
 
	rm -f $(BIN_DIR)/$(TTD)
 
# Make all the binaries into one
 
	$(LIPO) -create -output $(BIN_DIR)/$(TTD) $(TTDS)
 
endif
 

	
 
config.cache: $(CONFIG_CACHE_SOURCE_LIST) $(CONFIGURE_FILES)
 
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) || exit 1
 
	@echo "----------------"
 
	@echo "Reconfig done. Now compiling..."
 
	@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
 
	$(Q)rm -f $(CONFIG_CACHE_SOURCE_LIST) config.cache config.log
 
	$(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!!
 

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

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

	
 
#
 
# Creation of bundles
 
#
 

	
 
# The revision is needed for the bundle name and creating an OSX application bundle.
 
ifdef REVISION
 
REV := $(REVISION)
 
else
 
# Are we a SVN dir?
 
ifeq ($(shell if test -d $(SRC_DIR)/.svn; then echo 1; fi), 1)
 
# Find if the local source if modified
 
REV_MODIFIED := $(shell svnversion $(SRC_DIR) | sed -n 's/.*\(M\).*/\1/p' )
 
# Find the revision like: rXXXX-branch
 
REV := $(shell LC_ALL=C svn info $(SRC_DIR) | awk '/^URL:.*branches/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }')
 
endif
 
endif
 
# Make sure we have something in REV
 
ifeq ($(REV),)
 
REV := norev000
 
endif
 

	
 
ifndef BUNDLE_NAME
 
BUNDLE_NAME = OTTD-$(OS)-custom-$(REV)
 
endif
 

	
 
# An OSX application bundle needs the data files, lang files and openttd executable in a different location.
 
ifdef OSXAPP
 
DATA_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Data
 
LANG_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Lang
 
TTD_DIR  = $(BUNDLE_DIR)/$(OSXAPP)/Contents/MacOS
 
else
 
DATA_DIR = $(BUNDLE_DIR)/data
 
LANG_DIR = $(BUNDLE_DIR)/lang
 
TTD_DIR  = $(BUNDLE_DIR)
 
endif
 

	
 
bundle: all
 
	@echo '[BUNDLE] Constructing bundle'
 
	$(Q)rm -rf   "${BUNDLE_DIR}"
 
	$(Q)mkdir -p "${BUNDLE_DIR}"
 
	$(Q)mkdir -p "$(BUNDLE_DIR)/docs"
 
	$(Q)mkdir -p "$(BUNDLE_DIR)/scenario"
 
	$(Q)mkdir -p "$(BUNDLE_DIR)/scenario/heightmap"
 
	$(Q)mkdir -p "$(BUNDLE_DIR)/media"
 
	$(Q)mkdir -p "$(TTD_DIR)"
 
	$(Q)mkdir -p "$(DATA_DIR)"
 
	$(Q)mkdir -p "$(LANG_DIR)"
 
ifdef OSXAPP
 
	$(Q)mkdir -p "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources"
 
	$(Q)echo "APPL????" >                                          "$(BUNDLE_DIR)/$(OSXAPP)/Contents/PkgInfo"
 
	$(Q)cp    "$(ROOT_DIR)/os/macosx/openttd.icns"                 "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/openttd.icns"
 
	$(Q)$(ROOT_DIR)/os/macosx/plistgen.sh                          "${BUNDLE_DIR}/$(OSXAPP)" "$(REV)"
 
	$(Q)cp    "$(ROOT_DIR)/docs/OSX_install_instructions.txt"      "$(BUNDLE_DIR)/docs/"
 
	$(Q)cp    "$(ROOT_DIR)/docs/OSX_why_multiple_applications.txt" "$(BUNDLE_DIR)/docs/"
 
	$(Q)cp    "$(ROOT_DIR)/os/macosx/splash.png"                   "$(DATA_DIR)"
 
endif
 
	$(Q)cp "$(BIN_DIR)/$(TTD)"                "$(TTD_DIR)/"
 
	$(Q)cp "$(BIN_DIR)/data/"*.grf            "$(DATA_DIR)/"
 
	$(Q)cp "$(BIN_DIR)/data/opntitle.dat"     "$(DATA_DIR)/"
 
	$(Q)cp "$(BIN_DIR)/lang/"*.lng            "$(LANG_DIR)/"
 
	$(Q)cp "$(ROOT_DIR)/readme.txt"           "$(BUNDLE_DIR)/"
 
	$(Q)cp "$(ROOT_DIR)/COPYING"              "$(BUNDLE_DIR)/"
 
	$(Q)cp "$(ROOT_DIR)/known-bugs.txt"       "$(BUNDLE_DIR)/docs/"
 
	$(Q)cp "$(ROOT_DIR)/docs/multiplayer.txt" "$(BUNDLE_DIR)/docs/"
 
	$(Q)cp "$(ROOT_DIR)/changelog.txt"        "$(BUNDLE_DIR)/docs/"
 
	$(Q)cp "$(ROOT_DIR)/media/openttd.64.png" "$(BUNDLE_DIR)/media/"
 
	$(Q)cp "$(ROOT_DIR)/media/openttd.32.xpm" "$(BUNDLE_DIR)/media/"
 
	$(Q)cp "$(ROOT_DIR)/media/openttd.32.bmp" "$(BUNDLE_DIR)/media/"
 
ifeq ($(shell if test -d $(BIN_DIR)/scenario/*.scn; then echo 1; fi), 1)
 
	$(Q)cp "$(BIN_DIR)/scenario/"*.scn        "$(BUNDLE_DIR)/scenario/"
 
endif
 
ifeq ($(shell if test -d $(BIN_DIR)/scenario/heightmaps/*; then echo 1; fi), 1)
 
	$(Q)cp "$(BIN_DIR)/scenario/heightmaps/"* "$(BUNDLE_DIR)/scenario/heightmap/"
 
endif
 

	
 
### Packing the current bundle into several compressed file formats ###
 
#
 
# Zips & dmgs do not contain a root folder, i.e. they have files in the root of the zip/dmg.
 
# gzip, bzip2 and lha archives have a root folder, with the same name as the bundle.
 
#
 
# One can supply a custom name by adding BUNDLE_NAME:=<name> to the make command.
 
#
 
bundle_zip: bundle
 
	@echo '[BUNDLE] Creating $(BUNDLE_NAME).zip'
 
	$(Q)mkdir -p "$(BUNDLES_DIR)"
 
	$(Q)cd "$(BUNDLE_DIR)" && zip -r $(shell if test -z "$(VERBOSE)"; then echo '-q'; fi) "$(BUNDLES_DIR)/$(BUNDLE_NAME).zip" .
 

	
 
bundle_gzip: bundle
 
	@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.gz'
 
	$(Q)mkdir -p "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)"
 
	$(Q)cp -R    "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)/"
 
	$(Q)cd "$(BUNDLES_DIR)/.gzip" && tar -zc$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.gz" "$(BUNDLE_NAME)"
 
	$(Q)rm -rf   "$(BUNDLES_DIR)/.gzip"
 

	
 
bundle_bzip2: bundle
 
	@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.bz2'
 
	$(Q)mkdir -p "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)"
 
	$(Q)cp -R    "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)/"
 
	$(Q)cd "$(BUNDLES_DIR)/.bzip2" && tar -jc$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.bz2" "$(BUNDLE_NAME)"
 
	$(Q)rm -rf   "$(BUNDLES_DIR)/.bzip2"
 

	
 
bundle_lha: bundle
 
	@echo '[BUNDLE] Creating $(BUNDLE_NAME).lha'
 
	$(Q)mkdir -p "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)"
 
	$(Q)cp -R    "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)/"
 
	$(Q)cd "$(BUNDLES_DIR)/.lha" && lha ao6 "$(BUNDLES_DIR)/$(BUNDLE_NAME).lha" "$(BUNDLE_NAME)"
 
	$(Q)rm -rf   "$(BUNDLES_DIR)/.lha"
 

	
 
bundle_dmg: bundle
 
	@echo '[BUNDLE] Creating $(BUNDLE_NAME).dmg'
 
	$(Q)mkdir -p "$(BUNDLES_DIR)"
 
	$(Q)hdiutil create -ov -format UDZO -srcfolder "$(BUNDLE_DIR)" "$(BUNDLES_DIR)/$(BUNDLE_NAME).dmg"
 

	
 
# TODO: ENABLE_INSTALL should be removed when the search path patch has been applied
 
ifeq ($(ENABLE_INSTALL), 0)
 
install:
 
	@echo '[INSTALL] Cannot install. Not compiled with installation paths'
 
else
 
ifdef OSXAPP
 
install:
 
	@echo '[INSTALL] Cannot install the OSX Application Bundle'
 
else
 
install: bundle
 
	@echo '[INSTALL] Installing OpenTTD'
 
	$(Q)install -d "$(INSTALL_BINARY_DIR)"
 
	$(Q)install -d "$(INSTALL_ICON_DIR)"
 
	$(Q)install -d "$(INSTALL_DATA_DIR)/gm"
 
	$(Q)install -d "$(INSTALL_DATA_DIR)/data"
 
	$(Q)install -d "$(INSTALL_DATA_DIR)/lang"
 
	$(Q)install -d "$(INSTALL_DATA_DIR)/docs"
 
	$(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)"
 
	$(Q)install -m 644 "$(BUNDLE_DIR)/lang/"* "$(INSTALL_DATA_DIR)/lang"
 
	$(Q)install -m 644 "$(BUNDLE_DIR)/data/"* "$(INSTALL_DATA_DIR)/data"
 
	$(Q)install -m 644 "$(BUNDLE_DIR)/docs/"* "$(INSTALL_DATA_DIR)/docs"
 
	$(Q)install -m 644 "$(BUNDLE_DIR)/media/"* "$(INSTALL_ICON_DIR)"
 
ifdef INSTALL_PERSONAL_DIR
 
	$(Q)mkdir -p ~/"$(INSTALL_PERSONAL_DIR)"
 
	$(Q)cp -R "$(BUNDLE_DIR)/scenario" ~/"$(INSTALL_PERSONAL_DIR)"
 
else
 
	$(Q)cp -R "$(BUNDLE_DIR)/scenario" "$(INSTALL_DATA_DIR)"
 
endif # INSTALL_PERSONAL_DIR
 
endif # OSXAPP
 
endif # ENABLE_INSTALL
Makefile.lang.in
Show inline comments
 
new file 100644
 
# Auto-generated file -- DO NOT EDIT
 

	
 
STRGEN       = !!STRGEN!!
 
ENDIAN_CHECK = !!ENDIAN_CHECK!!
 
SRC_DIR      = !!SRC_DIR!!
 
LANG_DIR     = !!LANG_DIR!!
 
BIN_DIR      = !!BIN_DIR!!
 
LANGS_SRC    = $(shell ls $(LANG_DIR)/*.txt)
 
LANGS        = $(LANGS_SRC:$(LANG_DIR)/%.txt=%.lng)
 
CC_BUILD     = !!CC_BUILD!!
 
CFLAGS_BUILD = !!CFLAGS_BUILD!!
 
STRGEN_FLAGS = !!STRGEN_FLAGS!!
 
STAGE        = !!STAGE!!
 
LANG_SUPPRESS= !!LANG_SUPPRESS!!
 
LANG_OBJS_DIR= !!LANG_OBJS_DIR!!
 

	
 
ifeq ($(LANG_SUPPRESS), yes)
 
LANG_ERRORS = >/dev/null 2>&1
 
endif
 

	
 
# Make sure endian_host.h is reasable as if it was in the src/ dir
 
CFLAGS_BUILD += -I $(LANG_OBJS_DIR)
 

	
 
ENDIAN_TARGETS := endian_host.h endian_target.h $(ENDIAN_CHECK)
 

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

	
 
RES := $(shell mkdir -p $(BIN_DIR)/lang )
 

	
 
all: table/strings.h $(LANGS)
 

	
 
strgen.o: $(SRC_DIR)/strgen/strgen.c endian_host.h
 
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.c=%.c)'
 
	$(Q)$(CC_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
 

	
 
string.o: $(SRC_DIR)/string.c endian_host.h
 
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.c=%.c)'
 
	$(Q)$(CC_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
 

	
 
lang/english.txt: $(LANG_DIR)/english.txt
 
	$(Q)mkdir -p lang
 
	$(Q)cp $(LANG_DIR)/english.txt lang/english.txt
 

	
 
$(STRGEN): string.o strgen.o
 
	$(E) '$(STAGE) Compiling and Linking $@'
 
	$(Q)$(CC_BUILD) string.o strgen.o -o $@
 

	
 
table/strings.h: lang/english.txt $(STRGEN)
 
	$(E) '$(STAGE) Generating $@'
 
	@mkdir -p table
 
	$(Q)./$(STRGEN) -s $(LANG_DIR) -d table
 

	
 
$(LANGS): %.lng: $(LANG_DIR)/%.txt $(STRGEN) lang/english.txt
 
	$(E) '$(STAGE) Compiling language $(*F)'
 
	$(Q)./$(STRGEN) $(STRGEN_FLAGS) -s $(LANG_DIR) -d $(LANG_OBJS_DIR) $< $(LANG_ERRORS) && cp $@ $(BIN_DIR)/lang
 

	
 
# The targets to compile the endian-code
 

	
 
endian_host.h: $(ENDIAN_CHECK)
 
	$(E) '$(STAGE) Testing endianness for host'
 
	$(Q)./$(ENDIAN_CHECK) > $@
 

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

	
 
depend:
 

	
 
clean:
 
	$(E) '$(STAGE) Cleaning up language files'
 
	$(Q)rm -f strgen.o table/strings.h $(STRGEN) $(LANGS) $(LANGS:%=$(BIN_DIR)/lang/%) lang/english.* $(ENDIAN_TARGETS)
 

	
 
mrproper: clean
 

	
 
%.lng:
 
	@echo '$(STAGE) No such language: $(@:%.lng=%)'
 

	
 
.PHONY: all mrproper depend clean
Makefile.src.in
Show inline comments
 
new file 100644
 
# Auto-generated file -- DO NOT EDIT
 

	
 
CC_HOST      = !!CC_HOST!!
 
CXX_HOST     = !!CXX_HOST!!
 
CC_BUILD     = !!CC_BUILD!!
 
WINDRES      = !!WINDRES!!
 
STRIP        = !!STRIP!!
 
CC_CFLAGS    = !!CC_CFLAGS!!
 
CFLAGS       = !!CFLAGS!!
 
CFLAGS_BUILD = !!CFLAGS_BUILD!!
 
LIBS         = !!LIBS!!
 
LDFLAGS      = !!LDFLAGS!!
 
BIN_DIR      = !!BIN_DIR!!
 
LANG_DIR     = !!LANG_DIR!!
 
SRC_OBJS_DIR = !!SRC_OBJS_DIR!!
 
LANG_OBJS_DIR= !!LANG_OBJS_DIR!!
 
SRC_DIR      = !!SRC_DIR!!
 
MEDIA_DIR    = !!MEDIA_DIR!!
 
TTD          = !!TTD!!
 
STRGEN       = !!STRGEN!!
 
ENDIAN_CHECK = !!ENDIAN_CHECK!!
 
ENDIAN_FORCE = !!ENDIAN_FORCE!!
 
OS           = !!OS!!
 
STAGE        = !!STAGE!!
 
MAKEDEPEND   = !!MAKEDEPEND!!
 
CFLAGS_MAKEDEP= !!CFLAGS_MAKEDEP!!
 
SORT         = !!SORT!!
 
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_M   := !!OBJS_M!!
 
OBJS_RC  := !!OBJS_RC!!
 
OBJS     := $(OBJS_C) $(OBJS_CPP) $(OBJS_M) $(OBJS_RC)
 
SRCS     := !!SRCS!!
 

	
 
# All C-files depend on those 3 files
 
FILE_DEP := $(CONFIG_CACHE_COMPILER) $(LANG_OBJS_DIR)/table/strings.h 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)
 

	
 
ENDIAN_TARGETS := endian_target.h $(ENDIAN_CHECK)
 

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

	
 
# Our default target
 
all: $(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
 

	
 
# Make the revision number
 
ifdef REVISION
 
REV := $(REVISION)
 
else
 
# Are we a SVN dir?
 
ifeq ($(shell if test -d $(SRC_DIR)/.svn; then echo 1; fi), 1)
 
# Find if the local source if modified
 
REV_MODIFIED := $(shell svnversion $(SRC_DIR) | sed -n 's/.*\(M\).*/\1/p' )
 
# Find the revision like: rXXXX-branch
 
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 }')
 
endif
 
endif
 
# Make sure we have something in REV
 
ifeq ($(REV),)
 
REV := norev000
 
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.c
 
RES := $(shell if [ "`cat $(CONFIG_CACHE_VERSION) 2>/dev/null`" != "$(REV)" ]; then echo "$(REV)" > $(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):#' > $@
 

	
 
$(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):#' > $@
 

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

	
 
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
 

	
 
# Make sure that only 'make depend' ALWAYS triggers a recheck
 
ifeq ($(filter depend, $(MAKECMDGOALS)),)
 
Makefile.dep: $(FILE_DEP) $(SRCS:%=$(SRC_DIR)/%) $(CONFIG_CACHE_SOURCE)
 
else
 
Makefile.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
 
	@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, "^$(SRC_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
 

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

	
 
endif
 

	
 
# Avoid problems with deps if a .h file is deleted without the deps
 
#  being updated. Now the Makefile continues, the deps are recreated
 
#  and all will be fine.
 
%.h:
 
	@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)'
 
	$(Q)$(CXX_HOST) $(CFLAGS) -c -o $@ $<
 

	
 
$(OBJS_M): %.o: $(SRC_DIR)/%.m $(DEP_MASK) $(FILE_DEP)
 
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.m=%.m)'
 
	$(Q)$(CC_HOST) $(CC_CFLAGS) $(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) $<
 

	
 
$(TTD): rev.o $(OBJS) $(CONFIG_CACHE_LINKER)
 
	$(E) '$(STAGE) Linking $@'
 
	$(Q)$(CXX_HOST) $(LDFLAGS) rev.o $(OBJS) $(LIBS) -o $@ && cp $@ $(BIN_DIR)/
 
ifdef STRIP
 
	$(Q)$(STRIP) $@
 
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.c
 
	$(E) '$(STAGE) Compiling and Linking $@'
 
	$(Q)$(CC_BUILD) $(CFLAGS_BUILD) $< -o $@
 

	
 
# Revision files
 

	
 
rev.c: $(CONFIG_CACHE_VERSION)
 
# setting the revision number in a place, there the binary can read it
 
	@echo 'const char _openttd_revision[] = "$(REV)";' > rev.c
 
# Some additions for MorphOS versions tag
 
ifeq ($(OS),MORPHOS)
 
	@echo '#ifdef __MORPHOS__' >> rev.c
 
	@echo 'const char morphos_versions_tag[] = "\\0$$VER: OpenTTD $(REV) ('`date +%d.%m.%y`') (C) OpenTTD Team [MorphOS, PowerPC]";' >> rev.c
 
	@echo '#endif' >> rev.c
 
endif
 

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

	
 
FORCE:
 

	
 
depend: $(DEPS)
 

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

	
 
mrproper: clean
 
	$(Q)rm -f rev.c
 

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

	
 
.PHONY: all mrproper depend clean FORCE
ai/ai.c
Show inline comments
 
deleted file
ai/ai.h
Show inline comments
 
deleted file
ai/default/default.c
Show inline comments
 
deleted file
ai/default/default.h
Show inline comments
 
deleted file
ai/trolly/build.c
Show inline comments
 
deleted file
ai/trolly/pathfinder.c
Show inline comments
 
deleted file
ai/trolly/shared.c
Show inline comments
 
deleted file
ai/trolly/trolly.c
Show inline comments
 
deleted file

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)