From cf45945aa8c1613531e7a53fb5acf810378c7b73 Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 24 Nov 2017 08:09:14 -0800 Subject: [PATCH] qb: Combine the check_switch_c and check_switch_cxx functions. --- qb/config.libs.sh | 7 +++---- qb/qb.libs.sh | 27 +++++++++------------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 82698ce890..18842f2877 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -1,8 +1,7 @@ -check_switch_c C99 -std=gnu99 "Cannot find C99 compatible compiler." - -check_switch_c NOUNUSED -Wno-unused-result +check_switch '' C99 -std=gnu99 "Cannot find C99 compatible compiler." +check_switch '' NOUNUSED -Wno-unused-result add_define MAKEFILE NOUNUSED "$HAVE_NOUNUSED" -check_switch_c NOUNUSED_VARIABLE -Wno-unused-variable +check_switch '' NOUNUSED_VARIABLE -Wno-unused-variable add_define MAKEFILE NOUNUSED_VARIABLE "$HAVE_NOUNUSED_VARIABLE" # There are still broken 64-bit Linux distros out there. :) diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 831b9491a4..79278a1595 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -137,27 +137,18 @@ EOF die 1 "Build assumed that $2 is defined, but it's not. Exiting ..." } -check_switch_c() #$1 = HAVE_$1 $2 = switch $3 = critical error message [checked only if non-empty] -{ ECHOBUF="Checking for availability of switch $2 in $CC" - echo "int main(void) { return 0; }" > $TEMP_C - answer='no' - "$CC" -o "$TEMP_EXE" "$TEMP_C" $2 >>config.log 2>&1 && answer='yes' - eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" - rm -f -- "$TEMP_C" "$TEMP_EXE" - [ "$answer" = 'no' ] && { - [ "$3" ] && die 1 "$3" - } -} +check_switch() # $1 = language $2 = HAVE_$2 $3 = switch $4 = critical error message [checked only if non-empty] +{ check_compiler "$1" '' -check_switch_cxx() #$1 = HAVE_$1 $2 = switch $3 = critical error message [checked only if non-empty] -{ ECHOBUF="Checking for availability of switch $2 in $CXX" - echo "int main() { return 0; }" > $TEMP_CXX + ECHOBUF="Checking for availability of switch $3 in $COMPILER" + printf %s\\n 'int main(void) { return 0; }' > "$TEMP_CODE" answer='no' - "$CXX" -o "$TEMP_EXE" "$TEMP_CXX" "$2" >>config.log 2>&1 && answer='yes' - eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" - rm -f -- "$TEMP_CXX" "$TEMP_EXE" + "$COMPILER" -o "$TEMP_EXE" "$TEMP_CODE" "$3" >>config.log 2>&1 && answer='yes' + eval "HAVE_$2=\"$answer\"" + printf %s\\n "$ECHOBUF ... $answer" + rm -f -- "$TEMP_CODE" "$TEMP_EXE" [ "$answer" = 'no' ] && { - [ "$3" ] && die 1 "$3" + [ "$4" ] && die 1 "$4" } }