diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 4f3a48efd..5c7dd3996 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,7 @@ Changes towards version 0.7: +- Added support to the unix build system for explicitely specifying the name + of the define to set to show when a symbol is found. + Also a fix for when 'strcasecmp' is #define'd by the system. - SvdB - Rewrote mapres.c to use uio's hashtables instead of its own association lists - Michael - Added a Remix option to the setup menu - Michael @@ -46,7 +49,7 @@ Changes towards version 0.7: - Fixed some Melnorme history info timestamps - Alex - Fixed Ur-Quan story timestamps, from Vlad-Ceru Opran - Removed the 256-frame limit on .ani files - Michael -- Renamed PlaySpeeh/StopSpeech to work around name collisions +- Renamed PlaySpeech/StopSpeech to work around name collisions on OSX - Alex - Ending the battle with a simultaneous death no longer triggers an assertion - SvdB diff --git a/sc2/build/unix/build.config b/sc2/build/unix/build.config index 0f5c87159..0e2697865 100644 --- a/sc2/build/unix/build.config +++ b/sc2/build/unix/build.config @@ -32,11 +32,18 @@ uqm_requirements() # Add defines for HAVE_READDIR_R, HAVE_SETENV, HAVE_STRUPR, - # and HAVE_STRICMP + # HAVE_STRCASECMP, and HAVE_STRICMP define_have_symbol readdir_r define_have_symbol setenv define_have_symbol strupr + define_have_symbol strcasecmp define_have_symbol stricmp + + # Require either strcasecmp or stricmp. + if not have_symbol strcasecmp && not have_symbol stricmp; then + echo "Fatal: Your system defines neither strcasecmp() nor stricmp()." + exit 1 + fi # Add defines for HAVE_ISWGRAPH, HAVE_WCHAR_T, and HAVE_WINT_T define_have_symbol iswgraph @@ -191,13 +198,13 @@ uqm_prepare_config() OGGVORBIS=tremor use_library tremor } - CHOICE_ovcodec_DEFAULT=standard CHOICE_ovcodec_OPTION_none_TITLE="No Ogg Vorbis support" CHOICE_ovcodec_OPTION_none_ACTION=ovcodec_none_action ovcodec_none_action() { CFLAGS="$CFLAGS -DOVCODEC_NONE" OGGVORBIS=none } + CHOICE_ovcodec_DEFAULT=standard CHOICE_mikmod_OPTIONS="internal external" CHOICE_mikmod_TITLE="Tracker music support" diff --git a/sc2/build/unix/config_functions b/sc2/build/unix/config_functions index cee17ac87..a34aa623c 100644 --- a/sc2/build/unix/config_functions +++ b/sc2/build/unix/config_functions @@ -586,9 +586,14 @@ EOF # Description: check if a symbol is defined. # Arguments: $1 - the name of the symbol have_symbol() { - local SYMBOL CODE + local SYMBOL TEMP_PRESENT CODE SYMBOL="$1" + TEMP_PRESENT=`getVar SYMBOL_${SYMBOL}_PRESENT` + if [ -n "$TEMP_PRESENT" ]; then + return "$TEMP_PRESENT" + fi + CODE=`cat << EOF int main(void) { (void) $SYMBOL; @@ -600,17 +605,24 @@ EOF have_symbol_generic "$SYMBOL" "$CODE" if [ $? -gt 0 ]; then build_message "Symbol '$SYMBOL' not found." + eval "SYMBOL_${SYMBOL}_PRESENT"=1 return 1 fi build_message "Symbol '$SYMBOL' found." + eval "SYMBOL_${SYMBOL}_PRESENT"=0 return 0 } # Description: check if a type is present. # Arguments: $1 - the name of the symbol have_type() { - local TYPE + local TYPE TEMP_PRESENT CODE TYPE="$1" + + TEMP_PRESENT=`getVar TYPE_${TYPE}_PRESENT` + if [ -n "$TEMP_PRESENT" ]; then + return "$TEMP_PRESENT" + fi CODE=`cat << EOF int main(void) { @@ -619,14 +631,16 @@ int main(void) { return 0; } EOF -` + ` have_symbol_generic "$TYPE" "$CODE" if [ $? -gt 0 ]; then build_message "Type '$TYPE' not found." + eval "TYPE_${TYPE}_PRESENT"=1 return 1 fi build_message "Type '$TYPE' found." + eval "TYPE_${TYPE}_PRESENT"=0 return 0 } @@ -635,20 +649,26 @@ EOF # name of the symbol. # Arguments: $1 - the name of the symbol define_have_symbol() { - local NAME VALUE + local NAME VALUE DEFNAME - # Why not "tr [:lower:] [:upper:]"? Because the capital "i" is not - # "I" in Turkish... An alternative would be setting LC_CTYPE to POSIX. - NAME=`$TR "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" << EOF + DEFNAME=`getVar SYMBOL_${1}_DEFNAME` + if [ -z "$DEFNAME" ]; then + # Why not "tr [:lower:] [:upper:]"? Because the capital "i" is not + # "I" in Turkish... An alternative would be setting LC_CTYPE to POSIX. + NAME=`$TR "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ + << EOF $1 EOF -` + ` + DEFNAME="HAVE_$NAME" + fi + if have_symbol "$1"; then - add_symbol "HAVE_$NAME" "#define HAVE_$NAME" - add_symbol "HAVE_${NAME}_FLAG" 1 + add_symbol "$DEFNAME" "#define $DEFNAME" + add_symbol "${DEFNAME}_FLAG" 1 else - add_symbol "HAVE_$NAME" "#undef HAVE_$NAME" - add_symbol "HAVE_${NAME}_FLAG" 0 + add_symbol "$DEFNAME" "#undef $DEFNAME" + add_symbol "${DEFNAME}_FLAG" 0 fi } @@ -657,20 +677,26 @@ EOF # name of the symbol. # Arguments: $1 - the name of the symbol define_have_type() { - local NAME VALUE + local NAME VALUE DEFNAME - # Why not "tr [:lower:] [:upper:]"? Because the capital "i" is not - # "I" in Turkish... An alternative would be setting LC_CTYPE to POSIX. - NAME=`$TR "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" << EOF + DEFNAME=`getVar TYPE_${1}_DEFNAME` + if [ -z "$DEFNAME" ]; then + # Why not "tr [:lower:] [:upper:]"? Because the capital "i" is not + # "I" in Turkish... An alternative would be setting LC_CTYPE to POSIX. + NAME=`$TR "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ + << EOF $1 EOF -` + ` + DEFNAME="HAVE_$NAME" + fi + if have_type "$1"; then - add_symbol "HAVE_$NAME" "#define HAVE_$NAME" - add_symbol "HAVE_${NAME}_FLAG" 1 + add_symbol "$DEFNAME" "#define $DEFNAME" + add_symbol "${DEFNAME}_FLAG" 1 else - add_symbol "HAVE_$NAME" "#undef HAVE_$NAME" - add_symbol "HAVE_${NAME}_FLAG" 0 + add_symbol "$DEFNAME" "#undef $DEFNAME" + add_symbol "${DEFNAME}_FLAG" 0 fi } @@ -703,20 +729,26 @@ EOF # name of the header file. "sys/time.h" becomes "SYS_TIME_H". # Arguments: $1 - the name of the header file define_have_header() { - local NAME VALUE + local NAME VALUE DEFNAME - # Why not "tr [:lower:] [:upper:]"? Because the capital "i" is not - # "I" in Turkish... An alternative would be setting LC_CTYPE to POSIX. - NAME=`$TR "/.abcdefghijklmnopqrstuvwxyz" "__ABCDEFGHIJKLMNOPQRSTUVWXYZ" << EOF + DEFNAME=`getVar HEADER_${1%.h}_DEFNAME` + if [ -z "$DEFNAME" ]; then + # Why not "tr [:lower:] [:upper:]"? Because the capital "i" is not + # "I" in Turkish... An alternative would be setting LC_CTYPE to POSIX. + NAME=`$TR "/.abcdefghijklmnopqrstuvwxyz" \ + "__ABCDEFGHIJKLMNOPQRSTUVWXYZ" << EOF $1 EOF -` + ` + DEFNAME="HAVE_$NAME" + fi + if have_header "$1"; then - add_symbol "HAVE_$NAME" "#define HAVE_$NAME" - add_symbol "HAVE_${NAME}_FLAG" 1 + add_symbol "$DEFNAME" "#define $DEFNAME" + add_symbol "${DEFNAME}_FLAG" 1 else - add_symbol "HAVE_$NAME" "#undef HAVE_$NAME" - add_symbol "HAVE_${NAME}_FLAG" 0 + add_symbol "$DEFNAME" "#undef $DEFNAME" + add_symbol "${DEFNAME}_FLAG" 0 fi } diff --git a/sc2/build/unix/config_proginfo_host b/sc2/build/unix/config_proginfo_host index 2613c656a..d47d7e2b1 100644 --- a/sc2/build/unix/config_proginfo_host +++ b/sc2/build/unix/config_proginfo_host @@ -243,6 +243,10 @@ SYMBOL_readdir_r_EXTRA="#include " SYMBOL_setenv_EXTRA="#include " +SYMBOL_strcasecmp_EXTRA="#include " +SYMBOL_strcasecmp_DEFNAME="HAVE_STRCASECMP_UQM" + # HAVE_STRCASECMP would conflict with SDL (SDL_config.h). + SYMBOL_stricmp_EXTRA="#include " SYMBOL_strupr_EXTRA="#include " diff --git a/sc2/src/config_unix.h.in b/sc2/src/config_unix.h.in index c8f0480f6..b82dff256 100644 --- a/sc2/src/config_unix.h.in +++ b/sc2/src/config_unix.h.in @@ -37,6 +37,10 @@ /* Defined if your system has strupr of its own */ @HAVE_STRUPR@ +/* Defined if your system has strcasecmp of its own */ +@HAVE_STRCASECMP_UQM@ + // Not using "HAVE_STRCASECMP" as that conflicts with SDL. + /* Defined if your system has stricmp of its own */ @HAVE_STRICMP@ diff --git a/sc2/src/config_win.h.in b/sc2/src/config_win.h.in index 31d154a9b..1e7694939 100644 --- a/sc2/src/config_win.h.in +++ b/sc2/src/config_win.h.in @@ -38,6 +38,10 @@ /* Defined if your system has strupr of its own */ @HAVE_STRUPR@ +/* Defined if your system has strcasecmp of its own */ +@HAVE_STRCASECMP_UQM@ + // Not using "HAVE_STRCASECMP" as that conflicts with SDL. + /* Defined if your system has stricmp of its own */ @HAVE_STRICMP@ diff --git a/sc2/src/msvc++/config.h b/sc2/src/msvc++/config.h index 177e12b54..660b8bc58 100644 --- a/sc2/src/msvc++/config.h +++ b/sc2/src/msvc++/config.h @@ -38,6 +38,10 @@ /* Defined if your system has strupr of its own */ #define HAVE_STRUPR +/* Defined if your system has strcasecmp of its own */ +#undef HAVE_STRCASECMP_UQM + // Not using "HAVE_STRCASECMP" as that conflicts with SDL. + /* Defined if your system has stricmp of its own */ #define HAVE_STRICMP diff --git a/sc2/src/port.h b/sc2/src/port.h index 5fbe75bbf..cbb50f87a 100644 --- a/sc2/src/port.h +++ b/sc2/src/port.h @@ -45,12 +45,20 @@ # include #endif -#ifndef HAVE_STRICMP +// Using "HAVE_STRCASECMP_UQM" instead of "HAVE_STRCASECMP" as the latter +// conflicts with SDL. +#if !defined(HAVE_STRICMP) && !defined(HAVE_STRCASECMP_UQM) +# error Neither stricmp() nor strcasecmp() is available. +#elif defined(HAVE_STRCASECMP_UQM) # define stricmp strcasecmp -#else +#elif defined(HAVE_STRICMP) # define strcasecmp stricmp +#else + // We should take care not to define anything if both strcasecmp() and + // stricmp() are defined, as one might exist as a macro to the other. #endif + #ifndef HAVE_STRUPR char *strupr (char *str); #endif