diff --git a/Makefile.src.in b/Makefile.src.in index 897f8ba784..86d64aa04a 100644 --- a/Makefile.src.in +++ b/Makefile.src.in @@ -4,7 +4,6 @@ CC_BUILD = !!CC_BUILD!! CXX_BUILD = !!CXX_BUILD!! WINDRES = !!WINDRES!! STRIP = !!STRIP!! -CC_CFLAGS = !!CC_CFLAGS!! CFLAGS = !!CFLAGS!! CFLAGS_BUILD = !!CFLAGS_BUILD!! LIBS = !!LIBS!! @@ -28,7 +27,6 @@ CFLAGS_MAKEDEP= !!CFLAGS_MAKEDEP!! SORT = !!SORT!! REVISION = !!REVISION!! AWK = !!AWK!! -GCC295 = !!GCC295!! 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!! @@ -53,20 +51,6 @@ CFLAGS_MAKEDEP += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SCRIPT_SRC_DIR) ENDIAN_TARGETS := endian_target.h $(ENDIAN_CHECK) -# This 'sed' basicly just removes 'const' from the line if it is a 2+D array -# For more information, please check: -# http://maillist.openttd.org/pipermail/devs/2007-April/000284.html -# http://maillist.openttd.org/pipermail/devs/2007-February/000248.html -GCC295_FIX=sed -r 's@^(\t*)(.*)( const )([A-Za-z0-9_ ]+(\[.*\]){2,})(( = \{)|(;))(.*)$$@\1\2 \4\6\8\9@g' -# This 'sed' removes the 3rd '4' in the # lines of the -E output of -# gcc 2.95.3 and lower, as it should indicate that it is a C-linkage, but the -# compiler can't handle that information (just don't ask). So we remove it -# and then it compiles happily and without bitching :) -# Furthermore gcc 2.95 has some trouble with protected and private when -# accessing the protected/private stuff of the enclosing class (or the -# super class of the enclosing class). -GCC295_FIX_2=sed -e 's@\(^\# [0-9][0-9]* "[^"]*"[ 0-9]*\) 4$$@\1@g;s@private:@public:@g;s@protected:@public:@g' - # Check if we want to show what we are doing ifdef VERBOSE Q = @@ -114,7 +98,7 @@ REV_NR := 0 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_COMPILER) 2>/dev/null`" != "$(CFLAGS)" ]; then echo "$(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 ) @@ -182,7 +166,7 @@ endif # 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 + @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 @@ -192,7 +176,7 @@ endif @$(AWK) ' \ /^# DO NOT/ { print $$0 ; next} \ /^#/ {next} \ - /:/ { \ + /: / { \ left = NF - 1; \ for (n = 2; n <= NF; n++) { \ if (match($$n, "^$(ROOT_DIR)") == 0) { \ @@ -226,17 +210,9 @@ endif # 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)' -ifeq ($(GCC295), 1) - $(Q)$(CXX_HOST) -E $(CFLAGS) $< | $(GCC295_FIX) | $(GCC295_FIX_2) | $(CXX_HOST) $(CFLAGS) -c -o $@ -x c++ - -else $(Q)$(CXX_HOST) $(CFLAGS) -c -o $@ $< -endif $(OBJS_MM): %.o: $(SRC_DIR)/%.mm $(DEP_MASK) $(FILE_DEP) $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.mm=%.mm)' diff --git a/config.lib b/config.lib index 301039d3db..3e0ab706f2 100644 --- a/config.lib +++ b/config.lib @@ -1009,13 +1009,74 @@ check_params() { fi } +make_compiler_cflags() { + # Params: + # $1 - compiler + # $2 - the current cflags + # $3 - variable to finally write to + + flags="$2" + + if [ `echo $1 | cut -c 1-3` = "icc" ]; then + # Enable some things only for certain ICC versions + cc_version=`$1 -dumpversion | cut -c 1-4` + + + if [ "$cc_version" = "10.1" ]; then + flags="$flags -Wno-multichar" + fi + + if [ "$cc_version" = "11.0" ]; then + # warning 1899: multicharacter character literal (potential portability problem) (e.g. 'FOOD') + # vec report defaults to telling where it did loop vectorisation, which is not very important + flags="$flags -vec-report=0 -wd1899" + fi + else + # Enable some things only for certain GCC versions + cc_version=`$1 -dumpversion | cut -c 1,3` + + if [ $cc_version -lt 30 ]; then + log 1 "configure: error: gcc older than 3.0 can't compile OpenTTD because of its poor template support" + exit 1 + fi + + flags="$flags -Wall -Wno-multichar -Wsign-compare -Wundef" + flags="$flags -Wwrite-strings -Wpointer-arith" + flags="$flags -Wno-uninitialized" + + flags="$flags -W -Wno-unused-parameter -Wformat=2" + flags="$flags -Wredundant-decls" + + if [ $enable_assert -eq 0 ]; then + # Do not warn about unused variables when building without asserts + flags="$flags -Wno-unused-variable" + fi + + if [ $cc_version -ge 40 ]; then + # GCC 4.0+ complains about that we break strict-aliasing. + # On most places we don't see how to fix it, and it doesn't + # break anything. So disable strict-aliasing to make the + # compiler all happy. + flags="$flags -fno-strict-aliasing" + fi + + if [ $cc_version -ge 42 ]; then + # GCC 4.2+ automatically assumes that signed overflows do + # not occur in signed arithmetics, whereas we are not + # sure that they will not happen. It furthermore complains + # about it's own optimized code in some places. + flags="$flags -fno-strict-overflow" + fi + fi + + eval "$3=\"$flags\"" +} + make_cflags_and_ldflags() { # General CFlags for BUILD CFLAGS_BUILD="" # General CFlags for HOST CFLAGS="$CFLAGS -D$os" - # CFlags for HOST and C-Compiler - CC_FLAGS="" # Libs to compile. In fact this is just LDFLAGS LIBS="-lstdc++" # LDFLAGS used for HOST @@ -1064,58 +1125,16 @@ make_cflags_and_ldflags() { CFLAGS="$CFLAGS -DNO_THREADS" fi - if [ `echo $cc_host | cut -c 1-3` = "icc" ]; then - # Enable some things only for certain ICC versions - cc_version=`$cc_host -dumpversion | cut -c 1-4` - - - if [ "$cc_version" = "10.1" ]; then - CFLAGS="$CFLAGS -Wno-multichar" - fi - else - # Enable some things only for certain GCC versions - cc_version=`$cc_host -dumpversion | cut -c 1,3` - - if [ $cc_version -ge 29 ]; then - CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef" - CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith" - CFLAGS="$CFLAGS -Wno-uninitialized" - - CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes" - fi - - gcc295="" - if [ "$cc_version" = 29 ]; then - # Make sure we mark GCC 2.95 flag for Makefile.src.in, as we - # need a lovely hack there to make it compile correctly. - gcc295="1" - - # Disable warnings about unused variables when - # compiling with asserts disabled - if [ $enable_assert -eq 0 ]; then - CFLAGS="$CFLAGS -Wno-unused" - fi - fi - - if [ $cc_version -ge 30 ]; then - CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wformat=2" - CFLAGS="$CFLAGS -Wredundant-decls" - # Do not warn about unused variables when building without asserts - if [ $enable_assert -eq 0 ]; then - CFLAGS="$CFLAGS -Wno-unused-variable" - fi - fi - - if [ $cc_version -ge 34 ]; then - CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition" - fi + make_compiler_cflags "$cc_build" "$CFLAGS_BUILD" "CFLAGS_BUILD" + make_compiler_cflags "$cc_host" "$CFLAGS" "CFLAGS" + if [ "`echo $1 | cut -c 1-3`" != "icc" ]; then if [ "$os" = "CYGWIN" ]; then - CFLAGS="$CFLAGS -mwin32" + flags="$flags -mwin32" LDFLAGS="$LDFLAGS -mwin32" fi if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then - CFLAGS="$CFLAGS -mno-cygwin" + flags="$flags -mno-cygwin" LDFLAGS="$LDFLAGS -mno-cygwin" fi @@ -1123,22 +1142,6 @@ make_cflags_and_ldflags() { LDFLAGS="$LDFLAGS -Wl,--subsystem,windows" LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32" fi - - # GCC 4.0+ complains about that we break strict-aliasing. - # On most places we don't see how to fix it, and it doesn't - # break anything. So disable strict-aliasing to make the - # compiler all happy. - if [ $cc_version -ge 40 ]; then - CFLAGS="$CFLAGS -fno-strict-aliasing" - fi - - # GCC 4.2+ automatically assumes that signed overflows do - # not occur in signed arithmetics, whereas we are not - # sure that they will not happen. It furthermore complains - # about it's own optimized code in some places. - if [ $cc_version -ge 42 ]; then - CFLAGS="$CFLAGS -fno-strict-overflow" - fi fi if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then @@ -1379,7 +1382,7 @@ make_cflags_and_ldflags() { fi if [ "$enable_osx_g5" != "0" ]; then - CFLAGS="$CFLAGS -mtune=970 -mcpu=970 -mpowerpc-gpopt" + CFLAGS="$CFLAGS -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt" fi if [ -n "$personal_dir" ]; then @@ -1392,7 +1395,7 @@ make_cflags_and_ldflags() { CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\"" - log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS" + log 1 "using CFLAGS... $CFLAGS" log 1 "using LDFLAGS... $LIBS $LDFLAGS" # Makedepend doesn't like something like: -isysroot /OSX/blabla @@ -1583,7 +1586,7 @@ check_strip() { elif [ "$os" = "OSX" ]; then # Most targets have -V in strip, to see if they exists... OSX doesn't.. so execute something echo "int main(int argc, char *argv[]) { }" > strip.test.c - $cc_host strip.test.c -o strip.test + $cxx_host strip.test.c -o strip.test check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "strip.test" rm -f strip.test.c strip.test else @@ -1594,7 +1597,7 @@ check_strip() { check_lipo() { if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then echo "int main(int argc, char *argv[]) { }" > lipo.test.c - $cc_host lipo.test.c -o lipo.test + $cxx_host lipo.test.c -o lipo.test check_compiler "host lipo" "lipo" "$host" "$lipo" "$LIPO" "lipo" "lipo" "4" "-info lipo.test" rm -f lipo.test.c lipo.test fi @@ -1621,24 +1624,22 @@ set_universal_binary_flags() { } check_osx_sdk() { -cat > tmp.osx.cpp << EOF -#include -#if !defined(MAC_OS_X_VERSION_10_5) -# error "Need newer SDK" -#endif +cat > tmp.osx.mm << EOF +#include int main() { + kCGBitmapByteOrder32Host; return 0; } EOF - execute="$cxx_host $CFLAGS -E tmp.osx.cpp -o - 2>&1" + execute="$cxx_host $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1" eval $execute > /dev/null ret=$? log 2 "executing $execute" log 2 " exit code $ret" - rm -f tmp.osx.cpp + rm -f tmp.osx.mm tmp.osx if [ "$ret" != "0" ]; then - log 1 "I couldn't detect any XCode >= 2.5 on your system" - log 1 "please install/upgrade your XCode" + log 1 "Your system SDK is probably too old" + log 1 "Please install/upgrade your Xcode to >= 2.5" exit 1 fi @@ -2528,7 +2529,8 @@ detect_cputype() { log 1 "forcing cpu-type... $cpu_type bits" return; fi - echo "#include \"src/stdafx.h\"" > tmp.64bit.cpp + echo "#define _SQ64 1" > tmp.64bit.cpp + echo "#include \"src/stdafx.h\"" >> tmp.64bit.cpp echo "assert_compile(sizeof(size_t) == 8);" >> tmp.64bit.cpp echo "int main() { return 0; }" >> tmp.64bit.cpp execute="$cxx_host $CFLAGS tmp.64bit.cpp -o tmp.64bit -DTESTING 2>&1" @@ -2546,17 +2548,6 @@ make_sed() { T_CFLAGS="$CFLAGS" T_LDFLAGS="$LDFLAGS" - # We check here if we are PPC, because then we need to enable FOUR_BYTE_BOOL - # We do this here, and not sooner, so universal builds also have this - # automatically correct - # FOUR_BYTE_BOOL is needed, because C++ uses 4byte for a bool on PPC, where - # we use 1 byte per bool normally in C part. So convert that last one to 4 - # bytes too, but only for PPC. - ppc=`$cc_host -dumpmachine | egrep "powerpc|ppc"` - if [ -n "$ppc" ]; then - T_CFLAGS="$T_CFLAGS -DFOUR_BYTE_BOOL" - fi - SRC_OBJS_DIR="$BASE_SRC_OBJS_DIR/$OBJS_SUBDIR" # All the data needed to compile a single target @@ -2571,7 +2562,6 @@ make_sed() { s@!!WINDRES!!@$windres@g; s@!!STRIP!!@$strip $strip_arg@g; s@!!LIPO!!@$lipo@g; - s@!!CC_CFLAGS!!@$CC_CFLAGS@g; s@!!CFLAGS!!@$T_CFLAGS@g; s@!!CFLAGS_BUILD!!@$CFLAGS_BUILD@g; s@!!STRGEN_FLAGS!!@$strgen_flags@g; @@ -2622,7 +2612,6 @@ make_sed() { s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g; s@!!REVISION!!@$revision@g; s@!!AWK!!@$awk@g; - s@!!GCC295!!@$gcc295@g; s@!!DISTCC!!@$distcc@g; " diff --git a/configure b/configure index b34d85e589..710c02163d 100755 --- a/configure +++ b/configure @@ -1,5 +1,13 @@ #!/bin/sh +check_path_characters() { + if [ -n "`echo $ROOT_DIR | grep '[^-_A-Za-z0-9\/\\\.:]'`" ]; then + echo "WARNING: The path contains a non-alphanumeric character that might cause" + echo " failures in subsequent build stages. Any failures with the build" + echo " will most likely be caused by this." + fi +} + CONFIGURE_EXECUTABLE="$_" # On *nix systems those two are equal when ./configure is done if [ "$0" != "$CONFIGURE_EXECUTABLE" ]; then @@ -14,9 +22,16 @@ if [ "$0" != "$CONFIGURE_EXECUTABLE" ]; then fi # Find out where configure is (in what dir) ROOT_DIR="`dirname $0`" -ROOT_DIR="`cd $ROOT_DIR && pwd`" +# For MSYS/MinGW we want to know the FULL path. This as that path is generated +# once you call an outside binary. Having the same path for the rest is needed +# for dependency checking. +# pwd -W returns said FULL path, but doesn't exist on others so fall back. +ROOT_DIR="`cd $ROOT_DIR && (pwd -W 2>/dev/null || pwd 2>/dev/null)`" -PWD="`pwd`" +check_path_characters + +# Same here as for the ROOT_DIR above +PWD="`pwd -W 2>/dev/null || pwd 2>/dev/null`" PREFIX="$PWD/bin" . $ROOT_DIR/config.lib @@ -135,3 +150,5 @@ CONFIGURE_FILES="$ROOT_DIR/configure $ROOT_DIR/config.lib $ROOT_DIR/Makefile.in generate_main generate_lang generate_src + +check_path_characters diff --git a/src/company_gui.cpp b/src/company_gui.cpp index cc1af0e536..2eeee464f8 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -462,7 +462,7 @@ public: this->livery_class = LC_OTHER; this->sel = 1; this->LowerWidget(SCLW_WIDGET_CLASS_GENERAL); - this->OnInvalidateData(_loaded_newgrf_features.has_2CC); + this->OnInvalidateData(); this->FindWindowPlacementAndResize(desc); } @@ -595,14 +595,8 @@ public: virtual void OnInvalidateData(int data = 0) { - static bool has2cc = true; - - if (has2cc == !!data) return; - - has2cc = !!data; - - int r = this->widget[has2cc ? SCLW_WIDGET_SEC_COL_DROPDOWN : SCLW_WIDGET_PRI_COL_DROPDOWN].right; - this->SetWidgetHiddenState(SCLW_WIDGET_SEC_COL_DROPDOWN, !has2cc); + int r = this->widget[_loaded_newgrf_features.has_2CC ? SCLW_WIDGET_SEC_COL_DROPDOWN : SCLW_WIDGET_PRI_COL_DROPDOWN].right; + this->SetWidgetHiddenState(SCLW_WIDGET_SEC_COL_DROPDOWN, !_loaded_newgrf_features.has_2CC); this->widget[SCLW_WIDGET_CAPTION].right = r; this->widget[SCLW_WIDGET_SPACER_CLASS].right = r; this->widget[SCLW_WIDGET_MATRIX].right = r; diff --git a/src/lang/korean.txt b/src/lang/korean.txt index e26ea366c4..56ec7a6f2d 100644 --- a/src/lang/korean.txt +++ b/src/lang/korean.txt @@ -3,7 +3,7 @@ ##isocode ko_KR ##winlangid 0x0412 ##grflangid 0x3a -##plural 1 +##plural 11 ##gender m f # diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index e06b3eaeff..e72dc5ea17 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1951,7 +1951,7 @@ void ReloadNewGRFData() /* Check and update house and town values */ UpdateHousesAndTowns(); /* Update livery selection windows */ - for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i, _loaded_newgrf_features.has_2CC); + for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i); /* redraw the whole screen */ MarkWholeScreenDirty(); CheckTrainsLengths(); diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 11373edd80..02782c7594 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -99,7 +99,7 @@ static char _cases[MAX_NUM_CASES][16]; static uint _numcases; /* for each plural value, this is the number of plural forms. */ -static const byte _plural_form_counts[] = { 2, 1, 2, 3, 3, 3, 3, 3, 4, 2, 3 }; +static const byte _plural_form_counts[] = { 2, 1, 2, 3, 3, 3, 3, 3, 4, 2, 3, 2 }; static const char *_cur_ident; @@ -832,7 +832,7 @@ static void HandleString(char *str, bool master) /* Trim spaces. * After this str points to the command name, and s points to the command contents */ - for (t = s; t > str && (t[-1] == ' ' || t[-1] == '\t'); t--); + for (t = s; t > str && (t[-1] == ' ' || t[-1] == '\t'); t--) {} *t = 0; s++; diff --git a/src/strings.cpp b/src/strings.cpp index 7da8bdf807..174a2daba2 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -466,6 +466,32 @@ static int DeterminePluralForm(int64 count) * Czech */ case 10: return n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2; + + /* Two forms, special 'hack' for Korean; singular for numbers ending + * in a consonant and plural for numbers ending in a vowel. + * Korean doesn't have the concept of plural, but depending on how a + * number is pronounced it needs another version of a particle. + * As such the plural system is misused to give this distinction. + */ + case 11: + switch (n % 10) { + case 0: // yeong + case 1: // il + case 3: // sam + case 6: // yuk + case 7: // chil + case 8: // pal + return 0; + + case 2: // i + case 4: // sa + case 5: // o + case 9: // gu + return 1; + + default: + NOT_REACHED(); + } } }