comparison configure @ 16150:06b1f9d7dd4a

fix detection of iconv implementations which require libdl
author aurel
date Sat, 30 Jul 2005 01:07:27 +0000
parents 322e569c47bd
children a9f7eff9e437
comparison
equal deleted inserted replaced
16149:5a97461d9ada 16150:06b1f9d7dd4a
2268 else 2268 else
2269 echores "$_i18n (using $_i18n_libs)" 2269 echores "$_i18n (using $_i18n_libs)"
2270 fi 2270 fi
2271 2271
2272 2272
2273 echocheck "langinfo"
2274 if test "$_langinfo" = auto ; then
2275 cat > $TMPC <<EOF
2276 #include <langinfo.h>
2277 int main(void) { nl_langinfo(CODESET); return 0; }
2278 EOF
2279 _langinfo=no
2280 cc_check && _langinfo=yes
2281 fi
2282 if test "$_langinfo" = yes ; then
2283 _def_langinfo='#define USE_LANGINFO 1'
2284 else
2285 _def_langinfo='#undef USE_LANGINFO'
2286 fi
2287 echores "$_langinfo"
2288
2289
2290 echocheck "language"
2291 test -z "$_language" && _language=$LINGUAS
2292 _language=`echo $_language | sed 's/,/ /g'`
2293 echo $_language | grep all > /dev/null || LANGUAGES="$_language en"
2294 for lang in $_language ; do
2295 test "$lang" = all && lang=en
2296 if test -f "help/help_mp-${lang}.h" ; then
2297 _language=$lang
2298 break
2299 else
2300 echo -n "$lang not found, "
2301 _language=`echo $_language | sed "s/$lang *//"`
2302 fi
2303 done
2304 test -z "$_language" && _language=en
2305 _mp_help="help/help_mp-${_language}.h"
2306 test -f $_mp_help || die "$_mp_help not found"
2307 for lang in $LANGUAGES ; do
2308 if test -f "DOCS/man/$lang/mplayer.1" ; then
2309 MAN_LANG="$MAN_LANG $lang"
2310 fi
2311 done
2312 _doc_lang=$_language
2313 test -d DOCS/xml/$_doc_lang || _doc_lang=en
2314 echores "using $_language (man pages: $MAN_LANG)"
2315
2316
2317 echocheck "enable sighandler"
2318 if test "$_sighandler" = yes ; then
2319 _def_sighandler='#define ENABLE_SIGHANDLER 1'
2320 else
2321 _def_sighandler='#undef ENABLE_SIGHANDLER'
2322 fi
2323 echores "$_sighandler"
2324
2325 echocheck "runtime cpudetection"
2326 if test "$_runtime_cpudetection" = yes ; then
2327 _optimizing="Runtime CPU-Detection enabled"
2328 _def_runtime_cpudetection='#define RUNTIME_CPUDETECT 1'
2329 else
2330 _def_runtime_cpudetection='#undef RUNTIME_CPUDETECT'
2331 fi
2332 echores "$_runtime_cpudetection"
2333
2334
2335 echocheck "restrict keyword"
2336 for restrict_keyword in restrict __restrict __restrict__ ; do
2337 echo "void foo(char * $restrict_keyword p); int main(){}" > $TMPC
2338 if cc_check; then
2339 _def_restrict_keyword=$restrict_keyword
2340 break;
2341 fi
2342 done
2343 if [ -n "$_def_restrict_keyword" ]; then
2344 echores "$_def_restrict_keyword"
2345 else
2346 echores "none"
2347 fi
2348 # Avoid infinite recursion loop ("#define restrict restrict")
2349 if [ "$_def_restrict_keyword" != "restrict" ]; then
2350 _def_restrict_keyword="#define restrict $_def_restrict_keyword"
2351 else
2352 _def_restrict_keyword=""
2353 fi
2354
2355
2356 echocheck "__builtin_expect"
2357 # GCC branch prediction hint
2358 cat > $TMPC << EOF
2359 int foo (int a) {
2360 a = __builtin_expect (a, 10);
2361 return a == 10 ? 0 : 1;
2362 }
2363 int main() { return foo(10) && foo(0); }
2364 EOF
2365 _builtin_expect=no
2366 cc_check && _builtin_expect=yes
2367 if test "$_builtin_expect" = yes ; then
2368 _def_builtin_expect='#define HAVE_BUILTIN_EXPECT 1'
2369 else
2370 _def_builtin_expect='#undef HAVE_BUILTIN_EXPECT'
2371 fi
2372 echores "$_builtin_expect"
2373
2374
2375 echocheck "kstat"
2376 cat > $TMPC << EOF
2377 #include <kstat.h>
2378 int main(void) { (void) kstat_open(); (void) kstat_close(0); return 0; }
2379 EOF
2380 _kstat=no
2381 cc_check -lkstat && _kstat=yes
2382 if test "$_kstat" = yes ; then
2383 _ld_arch="-lkstat $_ld_arch"
2384 fi
2385 if test "$_kstat" = yes ; then
2386 _def_kstat="#define HAVE_LIBKSTAT 1"
2387 else
2388 _def_kstat="#undef HAVE_LIBKSTAT"
2389 fi
2390 echores "$_kstat"
2391
2392
2393 echocheck "posix4"
2394 # required for nanosleep on some systems
2395 cat > $TMPC << EOF
2396 #include <time.h>
2397 int main(void) { (void) nanosleep(0, 0); return 0; }
2398 EOF
2399 _posix4=no
2400 cc_check -lposix4 && _posix4=yes
2401 if test "$_posix4" = yes ; then
2402 _ld_arch="-lposix4 $_ld_arch"
2403 fi
2404 echores "$_posix4"
2405
2406 echocheck "-std=gnu99"
2407 cat > $TMPC << EOF
2408 int main(void) { return 0; }
2409 EOF
2410 _gnu99=no
2411 cc_check -std=gnu99 && _gnu99=yes
2412 if test "$_gnu99" = yes ; then
2413 _opt_gnu99="-std=gnu99"
2414 else
2415 _opt_gnu99=""
2416 fi
2417 echores "$_gnu99"
2418
2419 echocheck "lrintf"
2420 cat > $TMPC << EOF
2421 #include <math.h>
2422 int main(void) { long (*foo)(float); foo = lrintf; (void)(*foo)(0.0); return 0; }
2423 EOF
2424 _lrintf=no
2425 cc_check $_opt_gnu99 -D_GNU_SOURCE $_ld_lm && _lrintf=yes
2426 if test "$_lrintf" = yes ; then
2427 _def_lrintf="#define HAVE_LRINTF 1"
2428 else
2429 _def_lrintf="#undef HAVE_LRINTF"
2430 fi
2431 echores "$_lrintf"
2432
2433 echocheck "round"
2434 cat > $TMPC << EOF
2435 #include <math.h>
2436 int main(void) { (void) round(0.0); return 0; }
2437 EOF
2438 _round=no
2439 cc_check $_ld_lm && _round=yes
2440 if test "$_round" = yes ; then
2441 _def_round="#define HAVE_ROUND 1"
2442 else
2443 _def_round="#undef HAVE_ROUND"
2444 fi
2445 echores "$_round"
2446
2447 echocheck "nanosleep"
2448 # also check for nanosleep
2449 cat > $TMPC << EOF
2450 #include <time.h>
2451 int main(void) { (void) nanosleep(0, 0); return 0; }
2452 EOF
2453 _nanosleep=no
2454 cc_check $_ld_arch && _nanosleep=yes
2455 if test "$_nanosleep" = yes ; then
2456 _def_nanosleep='#define HAVE_NANOSLEEP 1'
2457 else
2458 _def_nanosleep='#undef HAVE_NANOSLEEP'
2459 fi
2460 echores "$_nanosleep"
2461
2462
2463 echocheck "socklib"
2464 # for Solaris (socket stuff is in -lsocket, gethostbyname and friends in -lnsl):
2465 # for BeOS (socket stuff is in -lsocket, gethostbyname and friends in -lbind):
2466 cat > $TMPC << EOF
2467 #include <netdb.h>
2468 int main(void) { (void) gethostbyname(0); return 0; }
2469 EOF
2470 cc_check -lsocket && _ld_sock="-lsocket"
2471 cc_check -lnsl && _ld_sock="-lnsl"
2472 cc_check -lsocket -lnsl && _ld_sock="-lsocket -lnsl"
2473 cc_check -lsocket -ldnet && _ld_sock="-lsocket -ldnet"
2474 cc_check -lsocket -lbind && _ld_sock="-lsocket -lbind"
2475 if test $_winsock2 = auto && not cygwin ; then
2476 _winsock2=no
2477 cat > $TMPC << EOF
2478 #include <winsock2.h>
2479 int main(void) { (void) gethostbyname(0); return 0; }
2480 EOF
2481 cc_check -lws2_32 && _ld_sock="-lws2_32" && _winsock2=yes
2482 fi
2483 if test "$_ld_sock" ; then
2484 echores "yes (using $_ld_sock)"
2485 else
2486 echores "no"
2487 fi
2488
2489
2490 if test $_winsock2 = yes ; then
2491 _ld_sock="-lws2_32"
2492 _def_winsock2='#define HAVE_WINSOCK2 1'
2493 else
2494 _def_winsock2='#undef HAVE_WINSOCK2'
2495 fi
2496
2497
2498 _use_aton=no
2499 echocheck "inet_pton()"
2500 cat > $TMPC << EOF
2501 #include <sys/types.h>
2502 #include <sys/socket.h>
2503 #include <arpa/inet.h>
2504 int main(void) { (void) inet_pton(0, 0, 0); return 0; }
2505 EOF
2506 if test "$_winsock2" = yes ; then
2507 echores "not needed (using winsock2 functions)"
2508 elif cc_check $_ld_sock ; then
2509 # NOTE: Linux has libresolv but does not need it
2510 :
2511 echores "yes (using $_ld_sock)"
2512 elif cc_check $_ld_sock -lresolv ; then
2513 # NOTE: needed for SunOS at least
2514 _ld_sock="$_ld_sock -lresolv"
2515 echores "yes (using $_ld_sock)"
2516 else
2517 echores "no (=> i'll try inet_aton next)"
2518
2519 echocheck "inet_aton()"
2520 cat > $TMPC << EOF
2521 #include <sys/types.h>
2522 #include <sys/socket.h>
2523 #include <arpa/inet.h>
2524 int main(void) { (void) inet_aton(0, 0); return 0; }
2525 EOF
2526 _use_aton=yes
2527 if cc_check $_ld_sock ; then
2528 # NOTE: Linux has libresolv but does not need it
2529 :
2530 echores "yes (using $_ld_sock)"
2531 elif cc_check $_ld_sock -lresolv ; then
2532 # NOTE: needed for SunOS at least
2533 _ld_sock="$_ld_sock -lresolv"
2534 echores "yes (using $_ld_sock)"
2535 else
2536 _use_aton=no
2537 _network=no
2538 echores "no (=> network support disabled)"
2539 fi
2540 fi
2541
2542 _def_use_aton='#undef USE_ATON'
2543 if test "$_use_aton" != no; then
2544 _def_use_aton='#define USE_ATON 1'
2545 fi
2546
2547
2548 echocheck "inttypes.h (required)"
2549 cat > $TMPC << EOF
2550 #include <inttypes.h>
2551 int main(void) { return 0; }
2552 EOF
2553 _inttypes=no
2554 cc_check && _inttypes=yes
2555 if test "$_inttypes" = yes ; then
2556 # nothing to do
2557 :
2558 else
2559 echores "no"
2560 echocheck "bitypes.h (inttypes.h predecessor)"
2561 cat > $TMPC << EOF
2562 #include <sys/bitypes.h>
2563 int main(void) { return 0; }
2564 EOF
2565 _inttypes=no
2566 cc_check && _inttypes=yes
2567 if test "$_inttypes" = yes ; then
2568 die "You don't have inttypes.h, but sys/bitypes.h is present. Please copy etc/inttypes.h into the include path, and re-run configure."
2569 else
2570 die "Cannot find header either inttypes.h or bitypes.h (see DOCS/HTML/$_doc_lang/faq.html)."
2571 fi
2572 fi
2573 echores "$_inttypes"
2574
2575
2576 echocheck "int_fastXY_t in inttypes.h"
2577 cat > $TMPC << EOF
2578 #include <inttypes.h>
2579 int main(void) {
2580 volatile int_fast16_t v= 0;
2581 return v; }
2582 EOF
2583 _fast_inttypes=no
2584 cc_check && _fast_inttypes=yes
2585 if test "$_fast_inttypes" = yes ; then
2586 # nothing to do
2587 :
2588 else
2589 _def_fast_inttypes='
2590 typedef signed char int_fast8_t;
2591 typedef signed int int_fast16_t;
2592 typedef signed int int_fast32_t;
2593 typedef unsigned char uint_fast8_t;
2594 typedef unsigned int uint_fast16_t;
2595 typedef unsigned int uint_fast32_t;'
2596 fi
2597 echores "$_fast_inttypes"
2598
2599
2600 echocheck "word size"
2601 _mp_wordsize="#undef MP_WORDSIZE"
2602 cat > $TMPC << EOF
2603 #include <stdio.h>
2604 #include <sys/types.h>
2605 int main(void) { printf("%d\n", sizeof(size_t)*8); return 0; }
2606 EOF
2607 cc_check && _wordsize=`$TMPO` && _mp_wordsize="#define MP_WORDSIZE $_wordsize"
2608 echores "$_wordsize"
2609
2610
2611 echocheck "stddef.h"
2612 cat > $TMPC << EOF
2613 #include <stddef.h>
2614 int main(void) { return 0; }
2615 EOF
2616 _stddef=no
2617 cc_check && _stddef=yes
2618 if test "$_stddef" = yes ; then
2619 _def_stddef='#define HAVE_STDDEF_H 1'
2620 else
2621 _def_stddef='#undef HAVE_STDDEF_H'
2622 fi
2623 echores "$_stddef"
2624
2625
2626 echocheck "malloc.h"
2627 cat > $TMPC << EOF
2628 #include <malloc.h>
2629 int main(void) { (void) malloc(0); return 0; }
2630 EOF
2631 _malloc=no
2632 cc_check && _malloc=yes
2633 if test "$_malloc" = yes ; then
2634 _def_malloc='#define HAVE_MALLOC_H 1'
2635 else
2636 _def_malloc='#undef HAVE_MALLOC_H'
2637 fi
2638 # malloc.h emits a warning in FreeBSD and OpenBSD
2639 (freebsd || openbsd) && _def_malloc='#undef HAVE_MALLOC_H'
2640 echores "$_malloc"
2641
2642
2643 echocheck "memalign()"
2644 # XXX restrict to x86 ? extend to other CPUs/cacheline sizes ?
2645 cat > $TMPC << EOF
2646 #include <malloc.h>
2647 int main (void) { (void) memalign(64, sizeof(char)); return 0; }
2648 EOF
2649 _memalign=no
2650 cc_check && _memalign=yes
2651 if test "$_memalign" = yes ; then
2652 _def_memalign='#define HAVE_MEMALIGN 1'
2653 else
2654 _def_memalign='#undef HAVE_MEMALIGN'
2655 fi
2656 echores "$_memalign"
2657
2658
2659 echocheck "alloca.h"
2660 cat > $TMPC << EOF
2661 #include <alloca.h>
2662 int main(void) { (void) alloca(0); return 0; }
2663 EOF
2664 _alloca=no
2665 cc_check && _alloca=yes
2666 if cc_check ; then
2667 _def_alloca='#define HAVE_ALLOCA_H 1'
2668 else
2669 _def_alloca='#undef HAVE_ALLOCA_H'
2670 fi
2671 echores "$_alloca"
2672
2673
2674 echocheck "mman.h"
2675 cat > $TMPC << EOF
2676 #include <sys/types.h>
2677 #include <sys/mman.h>
2678 int main(void) { (void) mmap(0, 0, 0, 0, 0, 0); return 0; }
2679 EOF
2680 _mman=no
2681 cc_check && _mman=yes
2682 if test "$_mman" = yes ; then
2683 _def_mman='#define HAVE_SYS_MMAN_H 1'
2684 else
2685 _def_mman='#undef HAVE_SYS_MMAN_H'
2686 fi
2687 echores "$_mman"
2688
2689 cat > $TMPC << EOF
2690 #include <sys/types.h>
2691 #include <sys/mman.h>
2692 int main(void) { void *p = MAP_FAILED; return 0; }
2693 EOF
2694 _mman_has_map_failed=no
2695 cc_check && _mman_has_map_failed=yes
2696 if test "$_mman_has_map_failed" = yes ; then
2697 _def_mman_has_map_failed=''
2698 else
2699 _def_mman_has_map_failed='#define MAP_FAILED ((void *) -1)'
2700 fi
2701
2702 echocheck "dynamic loader"
2703 cat > $TMPC << EOF
2704 #include <dlfcn.h>
2705 int main(void) { dlopen(0, 0); dlclose(0); dlsym(0, 0); return 0; }
2706 EOF
2707 _dl=no
2708 if cc_check ; then
2709 _dl=yes
2710 elif cc_check -ldl ; then
2711 _dl=yes
2712 _ld_dl='-ldl'
2713 fi
2714 if test "$_dl" = yes ; then
2715 _def_dl='#define HAVE_LIBDL 1'
2716 else
2717 _def_dl='#undef HAVE_LIBDL'
2718 fi
2719 echores "$_dl"
2720
2721
2722 echocheck "dynamic a/v plugins support"
2723 if test "$_dl" = no ; then
2724 _dynamic_plugins=no
2725 fi
2726 if test "$_dynamic_plugins" = yes ; then
2727 _def_dynamic_plugins='#define DYNAMIC_PLUGINS 1'
2728 else
2729 _def_dynamic_plugins='#undef DYNAMIC_PLUGINS'
2730 fi
2731 echores "$_dynamic_plugins"
2732
2733
2734 #echocheck "dynamic linking"
2735 # FIXME !! make this dynamic detection work and modify at the end (search _ld_dl_dynamic)
2736 # also gcc flags are different, but ld flags aren't (-Bdynamic/-Bstatic/-Bsymbolic)
2737 #cat > $TMPC << EOF
2738 #int main(void) { return 0; }
2739 #EOF
2740 #if cc_check -rdynamic ; then
2741 # _ld_dl_dynamic='-rdynamic'
2742 #elif cc_check -Bdynamic ; then
2743 # _ld_dl_dynamic='-Bdynamic'
2744 #elif cc_check ; then
2745 # _ld_dl_dynamic=''
2746 #fi
2747 #echores "using $_ld_dl_dynamic"
2748
2749 _def_threads='#undef HAVE_THREADS'
2750
2751 echocheck "pthread"
2752 _ld_pthread=''
2753 if test "$_pthreads" != no ; then
2754 cat > $TMPC << EOF
2755 #include <pthread.h>
2756 void* func(void *arg) { return arg; }
2757 int main(void) { pthread_t tid; return pthread_create (&tid, 0, func, 0) == 0 ? 0 : 1; }
2758 EOF
2759 if hpux ; then
2760 _ld_pthread=''
2761 elif ( cc_check -lpthreadGC2 && $TMPO ) ; then # mingw pthreads-win32
2762 _ld_pthread='-lpthreadGC2'
2763 elif ( cc_check && $TMPO ) ; then # QNX
2764 _ld_pthread=' ' # _ld_pthread='' would disable pthreads, but the test worked
2765 elif ( cc_check -lpthread && $TMPO ) ; then
2766 _ld_pthread='-lpthread'
2767 elif ( cc_check -pthread && $TMPO ) ; then
2768 _ld_pthread='-pthread'
2769 else
2770 if test "$_ld_static" ; then
2771 # for crosscompilation, we cannot execute the program, be happy if we can link statically
2772 if ( cc_check -lpthread ) ; then
2773 _ld_pthread='-lpthread'
2774 elif ( cc_check -pthread ) ; then
2775 _ld_pthread='-pthread'
2776 else
2777 _ld_pthread=''
2778 fi
2779 else
2780 _ld_pthread=''
2781 fi
2782 fi
2783 fi
2784 if test "$_ld_pthread" != '' ; then
2785 echores "yes (using $_ld_pthread)"
2786 _pthreads='yes'
2787 _def_pthreads='#define HAVE_PTHREADS 1'
2788 _def_threads='#define HAVE_THREADS 1'
2789 else
2790 echores "no (v4l, vo_gl, ao_alsa, ao_nas, ao_macosx, win32 loader disabled)"
2791 _pthreads=''
2792 _def_pthreads='#undef HAVE_PTHREADS'
2793 _nas=no ; _tv_v4l=no ; _macosx=no
2794 if not mingw32 ; then
2795 _win32=no
2796 fi
2797 fi
2798
2799
2273 echocheck "iconv" 2800 echocheck "iconv"
2274 if test "$_iconv" = auto ; then 2801 if test "$_iconv" = auto ; then
2275 _iconv_tmp='#include <iconv.h>' 2802 _iconv_tmp='#include <iconv.h>'
2276 2803
2277 cat > $TMPC << EOF 2804 cat > $TMPC << EOF
2309 if cc_check $_ld_lm ; then 2836 if cc_check $_ld_lm ; then
2310 _iconv=yes 2837 _iconv=yes
2311 elif cc_check $_ld_lm -liconv ; then 2838 elif cc_check $_ld_lm -liconv ; then
2312 _iconv=yes 2839 _iconv=yes
2313 _ld_iconv='-liconv' 2840 _ld_iconv='-liconv'
2841 elif cc_check $_ld_lm -liconv $_ld_dl ; then
2842 _iconv=yes
2843 _ld_iconv='-liconv $_ld_dl'
2314 fi 2844 fi
2315 fi 2845 fi
2316 if test "$_iconv" = yes ; then 2846 if test "$_iconv" = yes ; then
2317 _def_iconv='#define USE_ICONV 1' 2847 _def_iconv='#define USE_ICONV 1'
2318 else 2848 else
2319 _def_iconv='#undef USE_ICONV' 2849 _def_iconv='#undef USE_ICONV'
2320 fi 2850 fi
2321 echores "$_iconv" 2851 echores "$_iconv"
2322
2323
2324 echocheck "langinfo"
2325 if test "$_langinfo" = auto ; then
2326 cat > $TMPC <<EOF
2327 #include <langinfo.h>
2328 int main(void) { nl_langinfo(CODESET); return 0; }
2329 EOF
2330 _langinfo=no
2331 cc_check && _langinfo=yes
2332 fi
2333 if test "$_langinfo" = yes ; then
2334 _def_langinfo='#define USE_LANGINFO 1'
2335 else
2336 _def_langinfo='#undef USE_LANGINFO'
2337 fi
2338 echores "$_langinfo"
2339
2340
2341 echocheck "language"
2342 test -z "$_language" && _language=$LINGUAS
2343 _language=`echo $_language | sed 's/,/ /g'`
2344 echo $_language | grep all > /dev/null || LANGUAGES="$_language en"
2345 for lang in $_language ; do
2346 test "$lang" = all && lang=en
2347 if test -f "help/help_mp-${lang}.h" ; then
2348 _language=$lang
2349 break
2350 else
2351 echo -n "$lang not found, "
2352 _language=`echo $_language | sed "s/$lang *//"`
2353 fi
2354 done
2355 test -z "$_language" && _language=en
2356 _mp_help="help/help_mp-${_language}.h"
2357 test -f $_mp_help || die "$_mp_help not found"
2358 for lang in $LANGUAGES ; do
2359 if test -f "DOCS/man/$lang/mplayer.1" ; then
2360 MAN_LANG="$MAN_LANG $lang"
2361 fi
2362 done
2363 _doc_lang=$_language
2364 test -d DOCS/xml/$_doc_lang || _doc_lang=en
2365 echores "using $_language (man pages: $MAN_LANG)"
2366
2367
2368 echocheck "enable sighandler"
2369 if test "$_sighandler" = yes ; then
2370 _def_sighandler='#define ENABLE_SIGHANDLER 1'
2371 else
2372 _def_sighandler='#undef ENABLE_SIGHANDLER'
2373 fi
2374 echores "$_sighandler"
2375
2376 echocheck "runtime cpudetection"
2377 if test "$_runtime_cpudetection" = yes ; then
2378 _optimizing="Runtime CPU-Detection enabled"
2379 _def_runtime_cpudetection='#define RUNTIME_CPUDETECT 1'
2380 else
2381 _def_runtime_cpudetection='#undef RUNTIME_CPUDETECT'
2382 fi
2383 echores "$_runtime_cpudetection"
2384
2385
2386 echocheck "restrict keyword"
2387 for restrict_keyword in restrict __restrict __restrict__ ; do
2388 echo "void foo(char * $restrict_keyword p); int main(){}" > $TMPC
2389 if cc_check; then
2390 _def_restrict_keyword=$restrict_keyword
2391 break;
2392 fi
2393 done
2394 if [ -n "$_def_restrict_keyword" ]; then
2395 echores "$_def_restrict_keyword"
2396 else
2397 echores "none"
2398 fi
2399 # Avoid infinite recursion loop ("#define restrict restrict")
2400 if [ "$_def_restrict_keyword" != "restrict" ]; then
2401 _def_restrict_keyword="#define restrict $_def_restrict_keyword"
2402 else
2403 _def_restrict_keyword=""
2404 fi
2405
2406
2407 echocheck "__builtin_expect"
2408 # GCC branch prediction hint
2409 cat > $TMPC << EOF
2410 int foo (int a) {
2411 a = __builtin_expect (a, 10);
2412 return a == 10 ? 0 : 1;
2413 }
2414 int main() { return foo(10) && foo(0); }
2415 EOF
2416 _builtin_expect=no
2417 cc_check && _builtin_expect=yes
2418 if test "$_builtin_expect" = yes ; then
2419 _def_builtin_expect='#define HAVE_BUILTIN_EXPECT 1'
2420 else
2421 _def_builtin_expect='#undef HAVE_BUILTIN_EXPECT'
2422 fi
2423 echores "$_builtin_expect"
2424
2425
2426 echocheck "kstat"
2427 cat > $TMPC << EOF
2428 #include <kstat.h>
2429 int main(void) { (void) kstat_open(); (void) kstat_close(0); return 0; }
2430 EOF
2431 _kstat=no
2432 cc_check -lkstat && _kstat=yes
2433 if test "$_kstat" = yes ; then
2434 _ld_arch="-lkstat $_ld_arch"
2435 fi
2436 if test "$_kstat" = yes ; then
2437 _def_kstat="#define HAVE_LIBKSTAT 1"
2438 else
2439 _def_kstat="#undef HAVE_LIBKSTAT"
2440 fi
2441 echores "$_kstat"
2442
2443
2444 echocheck "posix4"
2445 # required for nanosleep on some systems
2446 cat > $TMPC << EOF
2447 #include <time.h>
2448 int main(void) { (void) nanosleep(0, 0); return 0; }
2449 EOF
2450 _posix4=no
2451 cc_check -lposix4 && _posix4=yes
2452 if test "$_posix4" = yes ; then
2453 _ld_arch="-lposix4 $_ld_arch"
2454 fi
2455 echores "$_posix4"
2456
2457 echocheck "-std=gnu99"
2458 cat > $TMPC << EOF
2459 int main(void) { return 0; }
2460 EOF
2461 _gnu99=no
2462 cc_check -std=gnu99 && _gnu99=yes
2463 if test "$_gnu99" = yes ; then
2464 _opt_gnu99="-std=gnu99"
2465 else
2466 _opt_gnu99=""
2467 fi
2468 echores "$_gnu99"
2469
2470 echocheck "lrintf"
2471 cat > $TMPC << EOF
2472 #include <math.h>
2473 int main(void) { long (*foo)(float); foo = lrintf; (void)(*foo)(0.0); return 0; }
2474 EOF
2475 _lrintf=no
2476 cc_check $_opt_gnu99 -D_GNU_SOURCE $_ld_lm && _lrintf=yes
2477 if test "$_lrintf" = yes ; then
2478 _def_lrintf="#define HAVE_LRINTF 1"
2479 else
2480 _def_lrintf="#undef HAVE_LRINTF"
2481 fi
2482 echores "$_lrintf"
2483
2484 echocheck "round"
2485 cat > $TMPC << EOF
2486 #include <math.h>
2487 int main(void) { (void) round(0.0); return 0; }
2488 EOF
2489 _round=no
2490 cc_check $_ld_lm && _round=yes
2491 if test "$_round" = yes ; then
2492 _def_round="#define HAVE_ROUND 1"
2493 else
2494 _def_round="#undef HAVE_ROUND"
2495 fi
2496 echores "$_round"
2497
2498 echocheck "nanosleep"
2499 # also check for nanosleep
2500 cat > $TMPC << EOF
2501 #include <time.h>
2502 int main(void) { (void) nanosleep(0, 0); return 0; }
2503 EOF
2504 _nanosleep=no
2505 cc_check $_ld_arch && _nanosleep=yes
2506 if test "$_nanosleep" = yes ; then
2507 _def_nanosleep='#define HAVE_NANOSLEEP 1'
2508 else
2509 _def_nanosleep='#undef HAVE_NANOSLEEP'
2510 fi
2511 echores "$_nanosleep"
2512
2513
2514 echocheck "socklib"
2515 # for Solaris (socket stuff is in -lsocket, gethostbyname and friends in -lnsl):
2516 # for BeOS (socket stuff is in -lsocket, gethostbyname and friends in -lbind):
2517 cat > $TMPC << EOF
2518 #include <netdb.h>
2519 int main(void) { (void) gethostbyname(0); return 0; }
2520 EOF
2521 cc_check -lsocket && _ld_sock="-lsocket"
2522 cc_check -lnsl && _ld_sock="-lnsl"
2523 cc_check -lsocket -lnsl && _ld_sock="-lsocket -lnsl"
2524 cc_check -lsocket -ldnet && _ld_sock="-lsocket -ldnet"
2525 cc_check -lsocket -lbind && _ld_sock="-lsocket -lbind"
2526 if test $_winsock2 = auto && not cygwin ; then
2527 _winsock2=no
2528 cat > $TMPC << EOF
2529 #include <winsock2.h>
2530 int main(void) { (void) gethostbyname(0); return 0; }
2531 EOF
2532 cc_check -lws2_32 && _ld_sock="-lws2_32" && _winsock2=yes
2533 fi
2534 if test "$_ld_sock" ; then
2535 echores "yes (using $_ld_sock)"
2536 else
2537 echores "no"
2538 fi
2539
2540
2541 if test $_winsock2 = yes ; then
2542 _ld_sock="-lws2_32"
2543 _def_winsock2='#define HAVE_WINSOCK2 1'
2544 else
2545 _def_winsock2='#undef HAVE_WINSOCK2'
2546 fi
2547
2548
2549 _use_aton=no
2550 echocheck "inet_pton()"
2551 cat > $TMPC << EOF
2552 #include <sys/types.h>
2553 #include <sys/socket.h>
2554 #include <arpa/inet.h>
2555 int main(void) { (void) inet_pton(0, 0, 0); return 0; }
2556 EOF
2557 if test "$_winsock2" = yes ; then
2558 echores "not needed (using winsock2 functions)"
2559 elif cc_check $_ld_sock ; then
2560 # NOTE: Linux has libresolv but does not need it
2561 :
2562 echores "yes (using $_ld_sock)"
2563 elif cc_check $_ld_sock -lresolv ; then
2564 # NOTE: needed for SunOS at least
2565 _ld_sock="$_ld_sock -lresolv"
2566 echores "yes (using $_ld_sock)"
2567 else
2568 echores "no (=> i'll try inet_aton next)"
2569
2570 echocheck "inet_aton()"
2571 cat > $TMPC << EOF
2572 #include <sys/types.h>
2573 #include <sys/socket.h>
2574 #include <arpa/inet.h>
2575 int main(void) { (void) inet_aton(0, 0); return 0; }
2576 EOF
2577 _use_aton=yes
2578 if cc_check $_ld_sock ; then
2579 # NOTE: Linux has libresolv but does not need it
2580 :
2581 echores "yes (using $_ld_sock)"
2582 elif cc_check $_ld_sock -lresolv ; then
2583 # NOTE: needed for SunOS at least
2584 _ld_sock="$_ld_sock -lresolv"
2585 echores "yes (using $_ld_sock)"
2586 else
2587 _use_aton=no
2588 _network=no
2589 echores "no (=> network support disabled)"
2590 fi
2591 fi
2592
2593 _def_use_aton='#undef USE_ATON'
2594 if test "$_use_aton" != no; then
2595 _def_use_aton='#define USE_ATON 1'
2596 fi
2597
2598
2599 echocheck "inttypes.h (required)"
2600 cat > $TMPC << EOF
2601 #include <inttypes.h>
2602 int main(void) { return 0; }
2603 EOF
2604 _inttypes=no
2605 cc_check && _inttypes=yes
2606 if test "$_inttypes" = yes ; then
2607 # nothing to do
2608 :
2609 else
2610 echores "no"
2611 echocheck "bitypes.h (inttypes.h predecessor)"
2612 cat > $TMPC << EOF
2613 #include <sys/bitypes.h>
2614 int main(void) { return 0; }
2615 EOF
2616 _inttypes=no
2617 cc_check && _inttypes=yes
2618 if test "$_inttypes" = yes ; then
2619 die "You don't have inttypes.h, but sys/bitypes.h is present. Please copy etc/inttypes.h into the include path, and re-run configure."
2620 else
2621 die "Cannot find header either inttypes.h or bitypes.h (see DOCS/HTML/$_doc_lang/faq.html)."
2622 fi
2623 fi
2624 echores "$_inttypes"
2625
2626
2627 echocheck "int_fastXY_t in inttypes.h"
2628 cat > $TMPC << EOF
2629 #include <inttypes.h>
2630 int main(void) {
2631 volatile int_fast16_t v= 0;
2632 return v; }
2633 EOF
2634 _fast_inttypes=no
2635 cc_check && _fast_inttypes=yes
2636 if test "$_fast_inttypes" = yes ; then
2637 # nothing to do
2638 :
2639 else
2640 _def_fast_inttypes='
2641 typedef signed char int_fast8_t;
2642 typedef signed int int_fast16_t;
2643 typedef signed int int_fast32_t;
2644 typedef unsigned char uint_fast8_t;
2645 typedef unsigned int uint_fast16_t;
2646 typedef unsigned int uint_fast32_t;'
2647 fi
2648 echores "$_fast_inttypes"
2649
2650
2651 echocheck "word size"
2652 _mp_wordsize="#undef MP_WORDSIZE"
2653 cat > $TMPC << EOF
2654 #include <stdio.h>
2655 #include <sys/types.h>
2656 int main(void) { printf("%d\n", sizeof(size_t)*8); return 0; }
2657 EOF
2658 cc_check && _wordsize=`$TMPO` && _mp_wordsize="#define MP_WORDSIZE $_wordsize"
2659 echores "$_wordsize"
2660
2661
2662 echocheck "stddef.h"
2663 cat > $TMPC << EOF
2664 #include <stddef.h>
2665 int main(void) { return 0; }
2666 EOF
2667 _stddef=no
2668 cc_check && _stddef=yes
2669 if test "$_stddef" = yes ; then
2670 _def_stddef='#define HAVE_STDDEF_H 1'
2671 else
2672 _def_stddef='#undef HAVE_STDDEF_H'
2673 fi
2674 echores "$_stddef"
2675
2676
2677 echocheck "malloc.h"
2678 cat > $TMPC << EOF
2679 #include <malloc.h>
2680 int main(void) { (void) malloc(0); return 0; }
2681 EOF
2682 _malloc=no
2683 cc_check && _malloc=yes
2684 if test "$_malloc" = yes ; then
2685 _def_malloc='#define HAVE_MALLOC_H 1'
2686 else
2687 _def_malloc='#undef HAVE_MALLOC_H'
2688 fi
2689 # malloc.h emits a warning in FreeBSD and OpenBSD
2690 (freebsd || openbsd) && _def_malloc='#undef HAVE_MALLOC_H'
2691 echores "$_malloc"
2692
2693
2694 echocheck "memalign()"
2695 # XXX restrict to x86 ? extend to other CPUs/cacheline sizes ?
2696 cat > $TMPC << EOF
2697 #include <malloc.h>
2698 int main (void) { (void) memalign(64, sizeof(char)); return 0; }
2699 EOF
2700 _memalign=no
2701 cc_check && _memalign=yes
2702 if test "$_memalign" = yes ; then
2703 _def_memalign='#define HAVE_MEMALIGN 1'
2704 else
2705 _def_memalign='#undef HAVE_MEMALIGN'
2706 fi
2707 echores "$_memalign"
2708
2709
2710 echocheck "alloca.h"
2711 cat > $TMPC << EOF
2712 #include <alloca.h>
2713 int main(void) { (void) alloca(0); return 0; }
2714 EOF
2715 _alloca=no
2716 cc_check && _alloca=yes
2717 if cc_check ; then
2718 _def_alloca='#define HAVE_ALLOCA_H 1'
2719 else
2720 _def_alloca='#undef HAVE_ALLOCA_H'
2721 fi
2722 echores "$_alloca"
2723
2724
2725 echocheck "mman.h"
2726 cat > $TMPC << EOF
2727 #include <sys/types.h>
2728 #include <sys/mman.h>
2729 int main(void) { (void) mmap(0, 0, 0, 0, 0, 0); return 0; }
2730 EOF
2731 _mman=no
2732 cc_check && _mman=yes
2733 if test "$_mman" = yes ; then
2734 _def_mman='#define HAVE_SYS_MMAN_H 1'
2735 else
2736 _def_mman='#undef HAVE_SYS_MMAN_H'
2737 fi
2738 echores "$_mman"
2739
2740 cat > $TMPC << EOF
2741 #include <sys/types.h>
2742 #include <sys/mman.h>
2743 int main(void) { void *p = MAP_FAILED; return 0; }
2744 EOF
2745 _mman_has_map_failed=no
2746 cc_check && _mman_has_map_failed=yes
2747 if test "$_mman_has_map_failed" = yes ; then
2748 _def_mman_has_map_failed=''
2749 else
2750 _def_mman_has_map_failed='#define MAP_FAILED ((void *) -1)'
2751 fi
2752
2753 echocheck "dynamic loader"
2754 cat > $TMPC << EOF
2755 #include <dlfcn.h>
2756 int main(void) { dlopen(0, 0); dlclose(0); dlsym(0, 0); return 0; }
2757 EOF
2758 _dl=no
2759 if cc_check ; then
2760 _dl=yes
2761 elif cc_check -ldl ; then
2762 _dl=yes
2763 _ld_dl='-ldl'
2764 fi
2765 if test "$_dl" = yes ; then
2766 _def_dl='#define HAVE_LIBDL 1'
2767 else
2768 _def_dl='#undef HAVE_LIBDL'
2769 fi
2770 echores "$_dl"
2771
2772
2773 echocheck "dynamic a/v plugins support"
2774 if test "$_dl" = no ; then
2775 _dynamic_plugins=no
2776 fi
2777 if test "$_dynamic_plugins" = yes ; then
2778 _def_dynamic_plugins='#define DYNAMIC_PLUGINS 1'
2779 else
2780 _def_dynamic_plugins='#undef DYNAMIC_PLUGINS'
2781 fi
2782 echores "$_dynamic_plugins"
2783
2784
2785 #echocheck "dynamic linking"
2786 # FIXME !! make this dynamic detection work and modify at the end (search _ld_dl_dynamic)
2787 # also gcc flags are different, but ld flags aren't (-Bdynamic/-Bstatic/-Bsymbolic)
2788 #cat > $TMPC << EOF
2789 #int main(void) { return 0; }
2790 #EOF
2791 #if cc_check -rdynamic ; then
2792 # _ld_dl_dynamic='-rdynamic'
2793 #elif cc_check -Bdynamic ; then
2794 # _ld_dl_dynamic='-Bdynamic'
2795 #elif cc_check ; then
2796 # _ld_dl_dynamic=''
2797 #fi
2798 #echores "using $_ld_dl_dynamic"
2799
2800 _def_threads='#undef HAVE_THREADS'
2801
2802 echocheck "pthread"
2803 _ld_pthread=''
2804 if test "$_pthreads" != no ; then
2805 cat > $TMPC << EOF
2806 #include <pthread.h>
2807 void* func(void *arg) { return arg; }
2808 int main(void) { pthread_t tid; return pthread_create (&tid, 0, func, 0) == 0 ? 0 : 1; }
2809 EOF
2810 if hpux ; then
2811 _ld_pthread=''
2812 elif ( cc_check -lpthreadGC2 && $TMPO ) ; then # mingw pthreads-win32
2813 _ld_pthread='-lpthreadGC2'
2814 elif ( cc_check && $TMPO ) ; then # QNX
2815 _ld_pthread=' ' # _ld_pthread='' would disable pthreads, but the test worked
2816 elif ( cc_check -lpthread && $TMPO ) ; then
2817 _ld_pthread='-lpthread'
2818 elif ( cc_check -pthread && $TMPO ) ; then
2819 _ld_pthread='-pthread'
2820 else
2821 if test "$_ld_static" ; then
2822 # for crosscompilation, we cannot execute the program, be happy if we can link statically
2823 if ( cc_check -lpthread ) ; then
2824 _ld_pthread='-lpthread'
2825 elif ( cc_check -pthread ) ; then
2826 _ld_pthread='-pthread'
2827 else
2828 _ld_pthread=''
2829 fi
2830 else
2831 _ld_pthread=''
2832 fi
2833 fi
2834 fi
2835 if test "$_ld_pthread" != '' ; then
2836 echores "yes (using $_ld_pthread)"
2837 _pthreads='yes'
2838 _def_pthreads='#define HAVE_PTHREADS 1'
2839 _def_threads='#define HAVE_THREADS 1'
2840 else
2841 echores "no (v4l, vo_gl, ao_alsa, ao_nas, ao_macosx, win32 loader disabled)"
2842 _pthreads=''
2843 _def_pthreads='#undef HAVE_PTHREADS'
2844 _nas=no ; _tv_v4l=no ; _macosx=no
2845 if not mingw32 ; then
2846 _win32=no
2847 fi
2848 fi
2849 2852
2850 2853
2851 echocheck "sys/soundcard.h" 2854 echocheck "sys/soundcard.h"
2852 cat > $TMPC << EOF 2855 cat > $TMPC << EOF
2853 #include <sys/soundcard.h> 2856 #include <sys/soundcard.h>