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.



git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2881 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2007-12-23 04:41:19 +00:00
parent 27bc2ea336
commit 23c74b2b63
8 changed files with 101 additions and 35 deletions
+9 -2
View File
@@ -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"
+62 -30
View File
@@ -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
}
+4
View File
@@ -243,6 +243,10 @@ SYMBOL_readdir_r_EXTRA="#include <dirent.h>"
SYMBOL_setenv_EXTRA="#include <stdlib.h>"
SYMBOL_strcasecmp_EXTRA="#include <string.h>"
SYMBOL_strcasecmp_DEFNAME="HAVE_STRCASECMP_UQM"
# HAVE_STRCASECMP would conflict with SDL (SDL_config.h).
SYMBOL_stricmp_EXTRA="#include <string.h>"
SYMBOL_strupr_EXTRA="#include <string.h>"