Files @ r23483:3733e6b8ff17
Branch filter:

Location: cpp/openttd-patchpack/source/Makefile.lang.in

Patric Stout
Remove: ENABLE_NETWORK switch

This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.

A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.

With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
# $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/>.

STRGEN        = !!STRGEN!!
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!!
CXXFLAGS_BUILD= !!CXXFLAGS_BUILD!!
LDFLAGS_BUILD = !!LDFLAGS_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

# 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_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
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<

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
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<

string.o: $(SRC_DIR)/string.cpp $(SRC_DIR)/safeguards.h
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<

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

getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/safeguards.h
	$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_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): alloc_func.o string.o strgen_base.o strgen.o getoptdata.o
	$(E) '$(STAGE) Compiling and Linking $@'
	$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $^ -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 || true # Do not fail all languages when one fails

depend:

clean:
	$(E) '$(STAGE) Cleaning up language files'
	$(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.*

mrproper: clean
	$(Q)rm -rf $(BIN_DIR)/lang

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

.PHONY: all mrproper depend clean