diff --git a/sc2/build/unix/build.config b/sc2/build/unix/build.config index 9d458fade..39cacdec4 100644 --- a/sc2/build/unix/build.config +++ b/sc2/build/unix/build.config @@ -39,6 +39,12 @@ uqm_requirements() define_have_symbol setenv define_have_symbol strupr define_have_symbol stricmp + + # Add defines for HAVE_ISWGRAPH, HAVE_WCHAR_T, and HAVE_WINT_T + define_have_symbol iswgraph + define_have_type wchar_t + define_have_type wint_t + # Check for getopt.h define_have_header getopt.h diff --git a/sc2/build/unix/config_functions b/sc2/build/unix/config_functions index 884c3ecfa..a271e69e4 100644 --- a/sc2/build/unix/config_functions +++ b/sc2/build/unix/config_functions @@ -292,25 +292,50 @@ use_library() { return 0 } +# Description: check if a symbol is defined +# Arguments: $1 - the name of the symbol +# $2 - the C code that does the actual checking +have_symbol_generic() { + local CODE DETECT EXTRA + + eval eval DETECT="\\\"\$SYMBOL_${1}_DETECT\\\"" + if [ -n "$DETECT" ]; then + $DETECT + return $? + fi + + eval eval EXTRA="\\\"\$SYMBOL_${1}_EXTRA\\\"" + eval eval CODE="\\\"\$SYMBOL_${1}_CODE\\\"" + if [ -z "$CODE" ]; then + CODE=$2 + fi + + try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF > /dev/null 2>&1 +$EXTRA +$CODE +EOF +} + # Description: check if a symbol is defined. # Arguments: $1 - the name of the symbol have_symbol() { - local SYMBOL + local SYMBOL CODE SYMBOL="$1" - # TODO: I'll want the include handling to be done differently - # eventually. - try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF > /dev/null 2>&1 + CODE=`cat << EOF #include #include #include #include #include -int main() { +int main(void) { (void) $SYMBOL; return 0; } EOF +` + + have_symbol_generic "$SYMBOL" "$CODE" if [ $? -gt 0 ]; then build_message "Symbol '$SYMBOL' not found." return 1 @@ -319,6 +344,35 @@ EOF return 0 } +# Description: check if a type is present. +# Arguments: $1 - the name of the symbol +have_type() { + local TYPE + TYPE="$1" + + CODE=`cat << EOF +#include +#include +#include +#include +#include +int main(void) { + $TYPE var; + (void) var; + return 0; +} +EOF +` + + have_symbol_generic "$TYPE" "$CODE" + if [ $? -gt 0 ]; then + build_message "Type '$TYPE' not found." + return 1 + fi + build_message "Type '$TYPE' found." + return 0 +} + # Description: check if a symbol is defined. # set HAVE_ accordingly, where is the capitalized # name of the symbol. @@ -336,6 +390,23 @@ EOF fi } +# Description: check if a type is present. +# set HAVE_ accordingly, where is the capitalized +# name of the symbol. +# Arguments: $1 - the name of the symbol +define_have_type() { + local NAME VALUE + NAME=`$TR "[:lower:]" "[:upper:]" << EOF +$1 +EOF +` + if have_type "$1"; then + add_symbol "HAVE_$NAME" "#define HAVE_$NAME" + else + add_symbol "HAVE_$NAME" "#undef HAVE_$NAME" + fi +} + # Description: check if a header is available. # Arguments: $1 - the name of the header file have_header() { diff --git a/sc2/build/unix/config_proginfo b/sc2/build/unix/config_proginfo index cea93ef18..aeba1e712 100644 --- a/sc2/build/unix/config_proginfo +++ b/sc2/build/unix/config_proginfo @@ -249,3 +249,17 @@ LIB_zlib_DETECT="try_pkgconfig_lib zlib zlib" LIB_zlib_DEPEND_DETECT_BIN="pkgconfig" +############################################################################## +# Describe the symbols (possibly) used: # +############################################################################## + +SYMBOL_wchar_t_EXTRA="#include +" + +SYMBOL_wint_t_EXTRA="#include +" + +SYMBOL_iswgraph_EXTRA="#include +" + + diff --git a/sc2/build/unix/todo b/sc2/build/unix/todo index 46ca7255e..20673f850 100644 --- a/sc2/build/unix/todo +++ b/sc2/build/unix/todo @@ -3,6 +3,8 @@ - Specify files to be removed on clean. - static compilation - generating tags files +- grep is used for the gcc 3.4 compilation patch. It's slower now, + and presence for "grep" isn't even checked. some docs diff --git a/sc2/src/config_unix.h.in b/sc2/src/config_unix.h.in index d37f662f9..1aa9b7ad9 100644 --- a/sc2/src/config_unix.h.in +++ b/sc2/src/config_unix.h.in @@ -38,6 +38,15 @@ /* Defined if your system has getopt.h */ @HAVE_GETOPT_H@ +/* Defined if your system has iswgraph of its own*/ +@HAVE_ISWGRAPH@ + +/* Defined if your system has wchar_t of its own */ +@HAVE_WCHAR_T@ + +/* Defined if your system has wint_t of its own */ +@HAVE_WINT_T@ + #endif /* _CONFIG_UNIX_H */ diff --git a/sc2/src/msvc++/config.h b/sc2/src/msvc++/config.h index 5e43b80d8..200482cac 100644 --- a/sc2/src/msvc++/config.h +++ b/sc2/src/msvc++/config.h @@ -39,5 +39,14 @@ /* Defined if your system has getopt.h */ #undef HAVE_GETOPT_H +/* Defined if your system has iswgraph of its own*/ +#define HAVE_ISWGRAPH + +/* Defined if your system has wchar_t of its own */ +#define HAVE_WCHAR_T + +/* Defined if your system has wint_t of its own */ +#define HAVE_WINT_T + #endif /* _CONFIG_H */ diff --git a/sc2/src/port.h b/sc2/src/port.h index 5f84301d6..b0aa51963 100644 --- a/sc2/src/port.h +++ b/sc2/src/port.h @@ -116,6 +116,25 @@ typedef unsigned short mode_t; int setenv (const char *name, const char *value, int overwrite); #endif +#ifndef HAVE_WCHAR_T +typedef unsigned short wchar_t +#endif + +#ifndef HAVE_WINT_T +typedef unsigned int wint_t +#endif + +#ifdef HAVE_ISWGRAPH +# include +#else +# include +static inline int +iswgraph(wint_t wc) +{ + return wc > 0x7f || isgraph((int) wc); +} +#endif + #endif /* _PORT_H */