3 # This file is part of OpenTTD.
4 # 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.
5 # 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.
6 # 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/>.
10 LANG_DIR = !!LANG_DIR!!
12 LANGS_SRC = $(shell ls $(LANG_DIR)/*.txt)
13 LANGS = $(LANGS_SRC:$(LANG_DIR)/%.txt=%.lng)
14 CXX_BUILD = !!CXX_BUILD!!
15 CFLAGS_BUILD = !!CFLAGS_BUILD!!
16 CXXFLAGS_BUILD= !!CXXFLAGS_BUILD!!
17 LDFLAGS_BUILD = !!LDFLAGS_BUILD!!
18 STRGEN_FLAGS = !!STRGEN_FLAGS!!
20 LANG_SUPPRESS = !!LANG_SUPPRESS!!
21 LANG_OBJS_DIR = !!LANG_OBJS_DIR!!
23 ifeq ($(LANG_SUPPRESS), yes)
24 LANG_ERRORS = >/dev/null 2>&1
27 # Check if we want to show what we are doing
36 RES := $(shell mkdir -p $(BIN_DIR)/lang )
38 all: table/strings.h $(LANGS)
40 strgen_base.o: $(SRC_DIR)/strgen/strgen_base.cpp $(SRC_DIR)/strgen/strgen.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h
41 $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
42 $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
44 strgen.o: $(SRC_DIR)/strgen/strgen.cpp $(SRC_DIR)/strgen/strgen.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h
45 $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
46 $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
48 string.o: $(SRC_DIR)/string.cpp $(SRC_DIR)/safeguards.h
49 $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
50 $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
52 alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp $(SRC_DIR)/safeguards.h
53 $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
54 $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
56 getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/safeguards.h
57 $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
58 $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
60 lang/english.txt: $(LANG_DIR)/english.txt
62 $(Q)cp $(LANG_DIR)/english.txt lang/english.txt
64 $(STRGEN): alloc_func.o string.o strgen_base.o strgen.o getoptdata.o
65 $(E) '$(STAGE) Compiling and Linking $@'
66 $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $^ -o $@
68 table/strings.h: lang/english.txt $(STRGEN)
69 $(E) '$(STAGE) Generating $@'
71 $(Q)./$(STRGEN) -s $(LANG_DIR) -d table
73 $(LANGS): %.lng: $(LANG_DIR)/%.txt $(STRGEN) lang/english.txt
74 $(E) '$(STAGE) Compiling language $(*F)'
75 $(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
80 $(E) '$(STAGE) Cleaning up language files'
81 $(Q)rm -f strgen_base.o strgen.o string.o alloc_func.o getoptdata.o table/strings.h $(STRGEN) $(LANGS) $(LANGS:%=$(BIN_DIR)/lang/%) lang/english.*
84 $(Q)rm -rf $(BIN_DIR)/lang
87 @echo '$(STAGE) No such language: $(@:%.lng=%)'
89 .PHONY: all mrproper depend clean