Browse code

feature tests for functions requiring one or more headers

Originally committed as revision 8032 to svn://svn.ffmpeg.org/ffmpeg/trunk

Måns Rullgård authored on 2007/02/20 08:00:18
Showing 1 changed files
... ...
@@ -438,6 +438,26 @@ int main(){
438 438
 EOF
439 439
 }
440 440
 
441
+check_func2(){
442
+    log check_func2 "$@"
443
+    headers=$1
444
+    func=$2
445
+    shift 2
446
+    disable $func
447
+    incs=""
448
+    for hdr in $headers; do
449
+        incs="$incs
450
+#include <$hdr>"
451
+    done
452
+    check_ld "$@" <<EOF && enable $func
453
+$incs
454
+int main(){
455
+    (void) $func;
456
+    return 0;
457
+}
458
+EOF
459
+}
460
+
441 461
 check_lib(){
442 462
     log check_lib "$@"
443 463
     header="$1"
... ...
@@ -450,6 +470,18 @@ check_lib(){
450 450
     return $err
451 451
 }
452 452
 
453
+check_lib2(){
454
+    log check_lib2 "$@"
455
+    headers="$1"
456
+    func="$2"
457
+    shift 2
458
+    temp_extralibs "$@"
459
+    check_func2 "$headers" $func && add_extralibs "$@"
460
+    err=$?
461
+    restore_flags
462
+    return $err
463
+}
464
+
453 465
 check_exec(){
454 466
     check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
455 467
 }
... ...
@@ -462,6 +494,14 @@ require(){
462 462
     check_lib $header $func "$@" || die "ERROR: $name not found"
463 463
 }
464 464
 
465
+require2(){
466
+    name="$1"
467
+    headers="$2"
468
+    func="$3"
469
+    shift 3
470
+    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
471
+}
472
+
465 473
 apply(){
466 474
     file=$1
467 475
     shift
... ...
@@ -1486,54 +1526,9 @@ enabled xvid       && require XviD xvid.h xvid_global -lxvidcore
1486 1486
 enabled x264       && require x264 x264.h x264_encoder_open -lx264
1487 1487
 enabled dc1394     && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
1488 1488
 enabled mlib       && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1489
-
1490
-# Ugh, libfaac uses stdcall calling convention on win32 so we can't use
1491
-# the generic test functions
1492
-if enabled libfaac; then
1493
-    save_flags
1494
-    temp_extralibs -lfaac
1495
-    check_ld <<EOF && add_extralibs -lfaac || die "ERROR: libfaac not found"
1496
-#include <stdint.h>
1497
-#include <faac.h>
1498
-int main(){
1499
-    char *id, *cpr;
1500
-    faacEncGetVersion(&id, &cpr);
1501
-    return 0;
1502
-}
1503
-EOF
1504
-    restore_flags
1505
-fi
1506
-
1507
-# Ugh, recent faad2 versions have renamed all functions and #define the
1508
-# old names in faad.h.  Generic tests won't work.
1509
-if enabled libfaad; then
1510
-    save_flags
1511
-    temp_extralibs -lfaad
1512
-    check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
1513
-#include <faad.h>
1514
-int main(){
1515
-    faacDecOpen();
1516
-    return 0;
1517
-}
1518
-EOF
1519
-    restore_flags
1520
-fi
1521
-
1522
-# Ugh, avisynth uses WINAPI calls. Generic tests won't work.
1523
-if enabled avisynth; then
1524
-    save_flags
1525
-    temp_extralibs -lvfw32
1526
-    check_ld <<EOF && add_extralibs -lvfw32 || die "ERROR: vfw32 not found"
1527
-#include <windows.h>
1528
-#include <vfw.h>
1529
-int main(){
1530
-    AVIFileInit();
1531
-    return 0;
1532
-}
1533
-EOF
1534
-    restore_flags
1535
-fi
1536
-
1489
+enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1490
+enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
1491
+enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
1537 1492
 
1538 1493
 # test for lrintf in math.h
1539 1494
 check_exec <<EOF && lrintf=yes || lrintf=no