2009-08-21 20:21:05 +00:00
# $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/>.
2009-09-07 13:33:45 +00:00
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)
CXX_BUILD = !!CXX_BUILD!!
CFLAGS_BUILD = !!CFLAGS_BUILD!!
LDFLAGS_BUILD = !!LDFLAGS_BUILD!!
STRGEN_FLAGS = !!STRGEN_FLAGS!!
STAGE = !!STAGE!!
LANG_SUPPRESS = !!LANG_SUPPRESS!!
LANG_OBJS_DIR = !!LANG_OBJS_DIR!!
2007-01-02 19:19:48 +00:00
i f e q ( $( LANG_SUPPRESS ) , y e s )
LANG_ERRORS = >/dev/null 2>& 1
e n d i f
2009-11-15 14:45:48 +00:00
# Make sure endian_host.h is reachable as if it was in the src/ dir
2007-01-02 19:19:48 +00:00
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
i f d e f V E R B O S E
Q =
E = @true
e l s e
Q = @
E = @echo
e n d i f
RES := $( shell mkdir -p $( BIN_DIR) /lang )
all : table /strings .h $( LANGS )
2011-12-17 18:34:03 +00:00
strgen_base.o : $( SRC_DIR ) /strgen /strgen_base .cpp $( SRC_DIR ) /strgen /strgen .h endian_host .h $( SRC_DIR ) /table /control_codes .h $( SRC_DIR ) /table /strgen_tables .h
$( E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$( Q) $( CXX_BUILD) $( CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
2011-12-17 17:25:50 +00:00
strgen.o : $( SRC_DIR ) /strgen /strgen .cpp $( SRC_DIR ) /strgen /strgen .h endian_host .h $( SRC_DIR ) /table /control_codes .h $( SRC_DIR ) /table /strgen_tables .h
2007-01-10 18:56:51 +00:00
$( E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$( Q) $( CXX_BUILD) $( CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
2007-01-02 19:19:48 +00:00
2007-01-10 18:56:51 +00:00
string.o : $( SRC_DIR ) /string .cpp endian_host .h
$( E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$( Q) $( CXX_BUILD) $( CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
2007-01-02 19:19:48 +00:00
2008-02-12 02:39:22 +00:00
alloc_func.o : $( SRC_DIR ) /core /alloc_func .cpp endian_host .h
$( E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$( Q) $( CXX_BUILD) $( CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
2011-02-18 20:52:42 +00:00
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) -DSTRGEN -c -o $@ $<
2007-01-02 19:19:48 +00:00
lang/english.txt : $( LANG_DIR ) /english .txt
$( Q) mkdir -p lang
2007-01-10 23:58:52 +00:00
$( Q) cp $( LANG_DIR) /english.txt lang/english.txt
2007-01-02 19:19:48 +00:00
2011-12-17 18:34:03 +00:00
$(STRGEN) : alloc_func .o string .o strgen_base .o strgen .o getoptdata .o
2007-01-02 19:19:48 +00:00
$( E) '$(STAGE) Compiling and Linking $@'
2009-08-21 21:21:09 +00:00
$( Q) $( CXX_BUILD) $( LDFLAGS_BUILD) $^ -o $@
2007-01-02 19:19:48 +00:00
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)'
2007-01-03 08:20:25 +00:00
$( Q) ./$( STRGEN) $( STRGEN_FLAGS) -s $( LANG_DIR) -d $( LANG_OBJS_DIR) $< $( LANG_ERRORS) && cp $@ $( BIN_DIR) /lang || true # Do not fail all languages when one fails
2007-01-02 19:19:48 +00:00
# The targets to compile the endian-code
endian_host.h : $( ENDIAN_CHECK )
$( E) '$(STAGE) Testing endianness for host'
$( Q) ./$( ENDIAN_CHECK) > $@
2007-01-10 18:56:51 +00:00
$(ENDIAN_CHECK) : $( SRC_DIR ) /endian_check .cpp
2007-01-02 19:19:48 +00:00
$( E) '$(STAGE) Compiling and Linking $@'
2007-01-10 18:56:51 +00:00
$( Q) $( CXX_BUILD) $( CFLAGS_BUILD) $< -o $@
2007-01-02 19:19:48 +00:00
depend :
clean :
$( E) '$(STAGE) Cleaning up language files'
2011-02-26 17:59:36 +00:00
$( Q) rm -f strgen.o string.o alloc_func.o getoptdata.o table/strings.h $( STRGEN) $( LANGS) $( LANGS:%= $( BIN_DIR) /lang/%) lang/english.* $( ENDIAN_TARGETS)
2007-01-02 19:19:48 +00:00
mrproper : clean
2010-02-05 16:20:04 +00:00
$( Q) rm -rf $( BIN_DIR) /lang
2007-01-02 19:19:48 +00:00
%.lng :
@echo '$(STAGE) No such language: $(@:%.lng=%)'
.PHONY : all mrproper depend clean