~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to erts/aclocal.m4

  • Committer: Bazaar Package Importer
  • Author(s): Erlang Packagers, Sergei Golovan
  • Date: 2006-12-03 17:07:44 UTC
  • mfrom: (2.1.11 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203170744-rghjwupacqlzs6kv
Tags: 1:11.b.2-4
[ Sergei Golovan ]
Fixed erlang-base and erlang-base-hipe prerm scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
      * )
202
202
        AC_CACHE_CHECK([for INADDR_LOOPBACK in winsock2.h],
203
203
                   ac_cv_decl_inaddr_loopback_winsock2,
204
 
                   AC_TRY_COMPILE([#include <winsock2.h>],
 
204
                   AC_TRY_COMPILE([#define WIN32_LEAN_AND_MEAN
 
205
                                   #include <winsock2.h>],
205
206
                                   [int i = INADDR_LOOPBACK;],
206
207
                                   ac_cv_decl_inaddr_loopback_winsock2=yes,
207
208
                                   ac_cv_decl_inaddr_loopback_winsock2=no))
389
390
 
390
391
dnl ----------------------------------------------------------------------
391
392
dnl
 
393
dnl LM_FIND_ETHR_LIB
 
394
dnl
 
395
dnl Find a thread library to use. Sets ETHR_LIBS to libraries to link
 
396
dnl with, ETHR_X_LIBS to extra libraries to link with (same as ETHR_LIBS
 
397
dnl except that the ethread lib itself is not included), ETHR_DEFS to
 
398
dnl defines to compile with, ETHR_THR_LIB_BASE to the name of the
 
399
dnl thread library which the ethread library is based on, and ETHR_LIB_NAME
 
400
dnl to the name of the library where the ethread implementation is located.
 
401
dnl  LM_FIND_ETHR_LIB currently searches for 'pthreads', and
 
402
dnl 'win32_threads'. If no thread library was found ETHR_LIBS, ETHR_X_LIBS,
 
403
dnl ETHR_DEFS, ETHR_THR_LIB_BASE, and ETHR_LIB_NAME are all set to the
 
404
dnl empty string.
 
405
dnl
 
406
 
 
407
AC_DEFUN(LM_FIND_ETHR_LIB,
 
408
[
 
409
 
 
410
dnl Name of lib where ethread implementation is located
 
411
ethr_lib_name=ethread
 
412
 
 
413
ETHR_THR_LIB_BASE=
 
414
ETHR_THR_LIB_BASE_NAME=
 
415
ETHR_X_LIBS=
 
416
ETHR_LIBS=
 
417
ETHR_LIB_NAME=
 
418
ETHR_DEFS=
 
419
 
 
420
dnl if test "x$host_os" = "x"; then
 
421
dnl    AC_CANONICAL_HOST
 
422
dnl fi
 
423
 
 
424
dnl win32?
 
425
AC_MSG_CHECKING([for native win32 threads])
 
426
if test "X$host_os" = "Xwin32"; then
 
427
    AC_MSG_RESULT(yes)
 
428
    ETHR_X_LIBS=
 
429
    ETHR_DEFS=
 
430
    ETHR_THR_LIB_BASE=win32_threads
 
431
    AC_DEFINE(ETHR_WIN32_THREADS, 1, [Define if you have win32 threads])
 
432
 
 
433
    AC_CACHE_CHECK([for InitializeCriticalSectionAndSpinCount],
 
434
                ethr_cv_func_initializecriticalsectionandspincount,
 
435
                AC_TRY_LINK([#include <windows.h>],
 
436
                        [CRITICAL_SECTION cs;
 
437
                        InitializeCriticalSectionAndSpinCount(&cs, 1000);],
 
438
                        ethr_cv_func_initializecriticalsectionandspincount=yes,
 
439
                        ethr_cv_func_initializecriticalsectionandspincount=no))
 
440
    if test $ethr_cv_func_initializecriticalsectionandspincount = yes; then
 
441
        AC_DEFINE(ETHR_HAVE_INITIALIZECRITICALSECTIONANDSPINCOUNT, 1, \
 
442
[Define if you have the InitializeCriticalSectionAndSpinCount function])
 
443
    fi
 
444
 
 
445
    AC_CACHE_CHECK([for TryEnterCriticalSection],
 
446
                ethr_cv_func_tryentercriticalsection,
 
447
                AC_TRY_LINK([#include <windows.h>],
 
448
                        [CRITICAL_SECTION cs;
 
449
                        TryEnterCriticalSection(&cs);],
 
450
                        ethr_cv_func_tryentercriticalsection=yes,
 
451
                        ethr_cv_func_tryentercriticalsection=no))
 
452
    if test $ethr_cv_func_tryentercriticalsection = yes; then
 
453
        AC_DEFINE(ETHR_HAVE_TRYENTERCRITICALSECTION, 1, \
 
454
[Define if you have the TryEnterCriticalSection function])
 
455
    fi
 
456
else
 
457
    AC_MSG_RESULT(no)
 
458
 
 
459
dnl Try to find POSIX threads
 
460
 
 
461
dnl The usual pthread lib...
 
462
    AC_CHECK_LIB(pthread, pthread_create, ETHR_X_LIBS="-lpthread")
 
463
 
 
464
dnl FreeBSD has pthreads in special c library, c_r...
 
465
    if test "x$ETHR_X_LIBS" = "x"; then
 
466
        AC_CHECK_LIB(c_r, pthread_create, ETHR_X_LIBS="-lc_r")
 
467
    fi
 
468
 
 
469
dnl On ofs1 the '-pthread' switch should be used
 
470
    if test "x$ETHR_X_LIBS" = "x"; then
 
471
        AC_MSG_CHECKING([if the '-pthread' switch can be used])
 
472
        saved_cflags=$CFLAGS
 
473
        CFLAGS="$CFLAGS -pthread"
 
474
        AC_TRY_LINK([#include <pthread.h>],
 
475
                    pthread_create((void*)0,(void*)0,(void*)0,(void*)0);,
 
476
                    [ETHR_DEFS="-pthread"
 
477
                     ETHR_X_LIBS="-pthread"])
 
478
        CFLAGS=$saved_cflags
 
479
        if test "x$ETHR_X_LIBS" != "x"; then
 
480
            AC_MSG_RESULT(yes)
 
481
        else
 
482
            AC_MSG_RESULT(no)
 
483
        fi
 
484
    fi
 
485
 
 
486
    if test "x$ETHR_X_LIBS" != "x"; then
 
487
        ETHR_DEFS="$ETHR_DEFS -D_THREAD_SAFE -D_REENTRANT"
 
488
        ETHR_THR_LIB_BASE=pthread
 
489
        AC_DEFINE(ETHR_PTHREADS, 1, [Define if you have pthreads])
 
490
        case $host_os in
 
491
            solaris*)
 
492
                ETHR_DEFS="$ETHR_DEFS -D_POSIX_PTHREAD_SEMANTICS" ;;
 
493
            linux*)
 
494
                ETHR_DEFS="$ETHR_DEFS -D_POSIX_THREAD_SAFE_FUNCTIONS -D_GNU_SOURCE"
 
495
                linux_kernel_vsn_=`uname -r` # FIXME: for cross compilation.
 
496
 
 
497
                usable_sigusrx=no
 
498
                usable_sigaltstack=no
 
499
 
 
500
                # FIXME: Test for actual problems instead of kernel versions.
 
501
                case $linux_kernel_vsn_ in
 
502
                    [[0-1]].*|2.[[0-1]]|2.[[0-1]].*)
 
503
                        ;;
 
504
                    2.[[2-3]]|2.[[2-3]].*)
 
505
                        usable_sigusrx=yes
 
506
                        ;;
 
507
                    *)
 
508
                        usable_sigusrx=yes
 
509
                        usable_sigaltstack=yes
 
510
                        ;;
 
511
                esac
 
512
 
 
513
                AC_MSG_CHECKING(if SIGUSR1 and SIGUSR2 can be used)
 
514
                AC_MSG_RESULT($usable_sigusrx)
 
515
                if test $usable_sigusrx = no; then
 
516
                    ETHR_DEFS="$ETHR_DEFS -DETHR_UNUSABLE_SIGUSRX"
 
517
                fi
 
518
 
 
519
                AC_MSG_CHECKING(if sigaltstack can be used)
 
520
                AC_MSG_RESULT($usable_sigaltstack)
 
521
                if test $usable_sigaltstack = no; then
 
522
                    ETHR_DEFS="$ETHR_DEFS -DETHR_UNUSABLE_SIGALTSTACK"
 
523
                fi
 
524
 
 
525
                AC_MSG_CHECKING(for Native POSIX Thread Library)
 
526
                case `getconf GNU_LIBPTHREAD_VERSION 2>/dev/null` in
 
527
                    nptl*) nptl=yes;;
 
528
                    NPTL*) nptl=yes;;
 
529
                    *)  nptl=no;;
 
530
                esac
 
531
                AC_MSG_RESULT($nptl)
 
532
                if test $nptl = yes; then
 
533
                    ETHR_THR_LIB_BASE_NAME=nptl
 
534
                fi
 
535
                if test $nptl = yes; then
 
536
                    need_nptl_incldir=no
 
537
                    AC_CHECK_HEADER(nptl/pthread.h, need_nptl_incldir=yes)
 
538
                    if test $need_nptl_incldir = yes; then
 
539
                        # Ahh...
 
540
                        nptl_path="$C_INCLUDE_PATH:$CPATH:/usr/local/include:/usr/include"
 
541
                        nptl_ws_path=
 
542
                        save_ifs="$IFS"; IFS=":"
 
543
                        for dir in $nptl_path; do
 
544
                            if test "x$dir" != "x"; then
 
545
                                nptl_ws_path="$nptl_ws_path $dir"
 
546
                            fi
 
547
                        done
 
548
                        IFS=$save_ifs
 
549
                        nptl_incldir=
 
550
                        for dir in $nptl_ws_path; do
 
551
                            AC_CHECK_HEADER($dir/nptl/pthread.h,
 
552
                                            nptl_incldir=$dir/nptl)
 
553
                            if test "x$nptl_incldir" != "x"; then
 
554
                                ETHR_DEFS="$ETHR_DEFS -isystem $nptl_incldir"
 
555
                                break
 
556
                            fi
 
557
                        done
 
558
                        if test "x$nptl_incldir" = "x"; then
 
559
                            AC_MSG_ERROR(Failed to locate nptl system include directory)
 
560
                        fi
 
561
                    fi
 
562
                fi
 
563
 
 
564
                AC_DEFINE(ETHR_INIT_MUTEX_IN_CHILD_AT_FORK, 1, \
 
565
[Define if mutexes should be reinitialized (instead of unlocked) in child at fork.]) ;;
 
566
            *) ;;
 
567
        esac
 
568
 
 
569
        dnl We sometimes need ETHR_DEFS in order to find certain headers
 
570
        dnl (at least for pthread.h on osf1).
 
571
        saved_cppflags=$CPPFLAGS
 
572
        CPPFLAGS="$CPPFLAGS $ETHR_DEFS"
 
573
 
 
574
        dnl We need the thread library in order to find some functions
 
575
        saved_libs=$LIBS
 
576
        LIBS="$LIBS $ETHR_X_LIBS"
 
577
 
 
578
 
 
579
 
 
580
        dnl
 
581
        dnl Check for headers
 
582
        dnl
 
583
 
 
584
        AC_CHECK_HEADER(pthread.h,
 
585
                        AC_DEFINE(ETHR_HAVE_PTHREAD_H, 1, \
 
586
[Define if you have the <pthread.h> header file.]))
 
587
 
 
588
        dnl Some Linuxes have <pthread/mit/pthread.h> instead of <pthread.h>
 
589
        AC_CHECK_HEADER(pthread/mit/pthread.h, \
 
590
                        AC_DEFINE(ETHR_HAVE_MIT_PTHREAD_H, 1, \
 
591
[Define if the pthread.h header file is in pthread/mit directory.]))
 
592
 
 
593
        AC_CHECK_HEADER(sys/time.h, \
 
594
                        AC_DEFINE(ETHR_HAVE_SYS_TIME_H, 1, \
 
595
[Define if you have the <sys/time.h> header file.]))
 
596
 
 
597
        AC_TRY_COMPILE([#include <time.h>
 
598
                        #include <sys/time.h>], 
 
599
                        [struct timeval *tv; return 0;],
 
600
                        AC_DEFINE(ETHR_TIME_WITH_SYS_TIME, 1, \
 
601
[Define if you can safely include both <sys/time.h> and <time.h>.]))
 
602
 
 
603
 
 
604
        dnl
 
605
        dnl Check for functions
 
606
        dnl
 
607
 
 
608
        AC_CHECK_FUNC(pthread_atfork, \
 
609
                        AC_DEFINE(ETHR_HAVE_PTHREAD_ATFORK, 1, \
 
610
[Define if you have the pthread_atfork function.]))
 
611
        AC_CHECK_FUNC(pthread_mutexattr_settype, \
 
612
                        AC_DEFINE(ETHR_HAVE_PTHREAD_MUTEXATTR_SETTYPE, 1, \
 
613
[Define if you have the pthread_mutexattr_settype function.]))
 
614
        AC_CHECK_FUNC(pthread_mutexattr_setkind_np, \
 
615
                        AC_DEFINE(ETHR_HAVE_PTHREAD_MUTEXATTR_SETKIND_NP, 1, \
 
616
[Define if you have the pthread_mutexattr_setkind_np function.]))
 
617
 
 
618
 
 
619
 
 
620
        dnl Restore LIBS
 
621
        LIBS=$saved_libs
 
622
        dnl restore CPPFLAGS
 
623
        CPPFLAGS=$saved_cppflags
 
624
 
 
625
    fi
 
626
fi
 
627
 
 
628
if test "x$ETHR_THR_LIB_BASE" != "x"; then
 
629
        ETHR_DEFS="-DUSE_THREADS $ETHR_DEFS"
 
630
        ETHR_LIBS="-l$ethr_lib_name $ETHR_X_LIBS"
 
631
        ETHR_LIB_NAME=$ethr_lib_name
 
632
fi
 
633
 
 
634
AC_DEFINE(ETHR_HAVE_ETHREAD_DEFINES, 1, \
 
635
[Define if you have all ethread defines])
 
636
 
 
637
AC_SUBST(ETHR_X_LIBS)
 
638
AC_SUBST(ETHR_LIBS)
 
639
AC_SUBST(ETHR_LIB_NAME)
 
640
AC_SUBST(ETHR_DEFS)
 
641
AC_SUBST(ETHR_THR_LIB_BASE)
 
642
AC_SUBST(ETHR_THR_LIB_BASE_NAME)
 
643
 
 
644
])
 
645
 
 
646
 
 
647
 
 
648
dnl ----------------------------------------------------------------------
 
649
dnl
392
650
dnl ERL_TIME_CORRECTION
393
651
dnl
394
652
dnl In the presence of a high resolution realtime timer Erlang can adapt