Changeset - r17414:35690285ddcd
[Not reviewed]
master
0 2 1
alberth - 13 years ago 2011-03-03 21:08:20
alberth@openttd.org
(svn r22174) -Add: Generate the settings as part of the unix build process without using it (Rubidium)
3 files changed with 93 insertions and 1 deletions:
0 comments (0 inline, 0 general)
Makefile.setting.in
Show inline comments
 
new file 100644
 
# $Id$
 

	
 
# This file is part of OpenTTD.
 
# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 

	
 
SETTINGSGEN      = !!SETTINGSGEN!!
 
ENDIAN_CHECK     = !!ENDIAN_CHECK!!
 
SRC_DIR          = !!SRC_DIR!!
 
CXX_BUILD        = !!CXX_BUILD!!
 
CFLAGS_BUILD     = !!CFLAGS_BUILD!!
 
LDFLAGS_BUILD    = !!LDFLAGS_BUILD!!
 
STAGE            = !!STAGE!!
 
SETTING_OBJS_DIR = !!SETTING_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
 

	
 
all: table/settings.h
 

	
 
settingsgen.o: $(SRC_DIR)/settingsgen/settingsgen.cpp $(SRC_DIR)/string_func.h $(SRC_DIR)/strings_type.h $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/ini_type.h $(SRC_DIR)/core/smallvec_type.hpp
 
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
 
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
 

	
 
alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h
 
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
 
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
 

	
 
getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h
 
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
 
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
 

	
 
ini_load.o: $(SRC_DIR)/ini_load.cpp $(SRC_DIR)/core/alloc_func.hpp $(SRC_DIR)/core/mem_func.hpp $(SRC_DIR)/ini_type.h $(SRC_DIR)/string_func.h
 
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
 
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
 

	
 
$(SETTINGSGEN): alloc_func.o ini_load.o settingsgen.o getoptdata.o
 
	$(E) '$(STAGE) Compiling and Linking $@'
 
	$(Q)$(CXX_BUILD) $(LDFLAGS_BUILD) $^ -o $@
 

	
 
table/settings.h: $(SETTINGSGEN) $(SRC_DIR)/table/settings.h.preamble $(SRC_DIR)/table/settings.h.postamble $(SRC_DIR)/table/*.ini
 
	$(E) '$(STAGE) Generating $@'
 
	@mkdir -p table
 
	$(Q)./$(SETTINGSGEN) -o table/settings.h -b $(SRC_DIR)/table/settings.h.preamble -a $(SRC_DIR)/table/settings.h.postamble $(SRC_DIR)/table/*.ini
 

	
 
# 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.cpp
 
	$(E) '$(STAGE) Compiling and Linking $@'
 
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $< -o $@
 

	
 
depend:
 

	
 
clean:
 
	$(E) '$(STAGE) Cleaning up settings files'
 
	$(Q)rm -f settingsgen.o alloc_func.o getoptdata.o ini_load.o $(SETTINGSGEN) $(ENDIAN_TARGETS) table/settings.h
 

	
 
mrproper: clean
 

	
 
.PHONY: all mrproper depend clean
config.lib
Show inline comments
 
@@ -3099,6 +3099,7 @@ make_sed() {
 
		s@!!SRC_OBJS_DIR!!@$SRC_OBJS_DIR@g;
 
		s@!!LANG_OBJS_DIR!!@$LANG_OBJS_DIR@g;
 
		s@!!GRF_OBJS_DIR!!@$GRF_OBJS_DIR@g;
 
		s@!!SETTING_OBJS_DIR!!@$SETTING_OBJS_DIR@g;
 
		s@!!SRC_DIR!!@$SRC_DIR@g;
 
		s@!!SCRIPT_SRC_DIR!!@$SCRIPT_SRC_DIR@g;
 
		s@!!OSXAPP!!@$OSXAPP@g;
 
@@ -3117,6 +3118,7 @@ make_sed() {
 
		s@!!STRGEN!!@$STRGEN@g;
 
		s@!!ENDIAN_CHECK!!@$ENDIAN_CHECK@g;
 
		s@!!DEPEND!!@$DEPEND@g;
 
		s@!!SETTINGSGEN!!@$SETTINGSGEN@g;
 
		s@!!ENDIAN_FORCE!!@$endian@g;
 
		s@!!STAGE!!@$STAGE@g;
 
		s@!!MAKEDEPEND!!@$makedepend@g;
 
@@ -3224,6 +3226,20 @@ generate_lang() {
 
	echo "LANG_DIRS += $LANG_OBJS_DIR" >> Makefile.am
 
}
 

	
 
generate_settings() {
 
	STAGE="[SETTING]"
 

	
 
	make_sed
 

	
 
	# Create the language file
 
	mkdir -p $SETTING_OBJS_DIR
 

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

	
 
generate_grf() {
 
	STAGE="[GRF]"
 

	
configure
Show inline comments
 
@@ -48,6 +48,7 @@ OBJS_DIR="$PWD/objs"
 
BASE_SRC_OBJS_DIR="$OBJS_DIR"
 
LANG_OBJS_DIR="$OBJS_DIR/lang"
 
GRF_OBJS_DIR="$OBJS_DIR/extra_grf"
 
SETTING_OBJS_DIR="$OBJS_DIR/setting"
 
BIN_DIR="$PREFIX"
 
SRC_DIR="$ROOT_DIR/src"
 
LANG_DIR="$SRC_DIR/lang"
 
@@ -82,6 +83,7 @@ TTD="openttd$EXE"
 
STRGEN="strgen$EXE"
 
ENDIAN_CHECK="endian_check$EXE"
 
DEPEND="depend$EXE"
 
SETTINGSGEN="settings_gen$EXE"
 

	
 
if [ -z "$sort" ]; then
 
	PIPE_SORT="sed s@a@a@"
 
@@ -161,10 +163,11 @@ else
 
	sort="$sort -u"
 
fi
 

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

	
 
generate_main
 
generate_lang
 
generate_settings
 
generate_grf
 
generate_src
 

	
0 comments (0 inline, 0 general)