configure: add functions for testing code fragments
This simplifies testing arbitrary code fragments within a function body. Signed-off-by: Mans Rullgard <mans@mansr.com> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
b7558ac293
commit
5adc829eb0
39
configure
vendored
39
configure
vendored
@ -660,6 +660,20 @@ check_ld(){
|
|||||||
check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $libs $extralibs
|
check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $libs $extralibs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_code(){
|
||||||
|
log check_code "$@"
|
||||||
|
check=$1
|
||||||
|
headers=$2
|
||||||
|
code=$3
|
||||||
|
shift 3
|
||||||
|
{
|
||||||
|
for hdr in $headers; do
|
||||||
|
echo "#include <$hdr>"
|
||||||
|
done
|
||||||
|
echo "int main(void) { $code; return 0; }"
|
||||||
|
} | check_$check "$@"
|
||||||
|
}
|
||||||
|
|
||||||
check_cppflags(){
|
check_cppflags(){
|
||||||
log check_cppflags "$@"
|
log check_cppflags "$@"
|
||||||
set -- $($filter_cppflags "$@")
|
set -- $($filter_cppflags "$@")
|
||||||
@ -817,15 +831,7 @@ check_type(){
|
|||||||
type=$2
|
type=$2
|
||||||
shift 2
|
shift 2
|
||||||
disable_safe "$type"
|
disable_safe "$type"
|
||||||
incs=""
|
check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
|
||||||
for hdr in $headers; do
|
|
||||||
incs="$incs
|
|
||||||
#include <$hdr>"
|
|
||||||
done
|
|
||||||
check_cc "$@" <<EOF && enable_safe "$type"
|
|
||||||
$incs
|
|
||||||
$type v;
|
|
||||||
EOF
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_struct(){
|
check_struct(){
|
||||||
@ -835,15 +841,8 @@ check_struct(){
|
|||||||
member=$3
|
member=$3
|
||||||
shift 3
|
shift 3
|
||||||
disable_safe "${struct}_${member}"
|
disable_safe "${struct}_${member}"
|
||||||
incs=""
|
check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
|
||||||
for hdr in $headers; do
|
enable_safe "${struct}_${member}"
|
||||||
incs="$incs
|
|
||||||
#include <$hdr>"
|
|
||||||
done
|
|
||||||
check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
|
|
||||||
$incs
|
|
||||||
const void *p = &(($struct *)0)->$member;
|
|
||||||
EOF
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require(){
|
require(){
|
||||||
@ -2399,9 +2398,7 @@ case "$arch" in
|
|||||||
;;
|
;;
|
||||||
x86)
|
x86)
|
||||||
subarch="x86_32"
|
subarch="x86_32"
|
||||||
check_cc <<EOF && subarch="x86_64"
|
check_code cc "" "int test[(int)sizeof(char*) - 7]" && subarch="x86_64"
|
||||||
int test[(int)sizeof(char*) - 7];
|
|
||||||
EOF
|
|
||||||
if test "$subarch" = "x86_64"; then
|
if test "$subarch" = "x86_64"; then
|
||||||
spic=$shared
|
spic=$shared
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user