$NetBSD: patch-ab,v 1.1.1.1 2004/11/27 14:14:05 taca Exp $ --- configure.orig 2002-11-19 20:49:26.000000000 +0900 +++ configure @@ -29,6 +29,8 @@ ac_help="$ac_help --with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]" ac_help="$ac_help --with-search-path=DIR specify the additional search path" +ac_help="$ac_help +--enable-pthread use pthread library." # Initialize some variables set by options. # The variables have the same names as the options, with @@ -2877,7 +2879,8 @@ fi for ac_hdr in stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\ fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\ - syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h + syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h\ + pthread.h ucontext.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 @@ -4387,6 +4390,330 @@ EOF fi +if test "$enable_pthread" = "yes"; then + echo $ac_n "checking for pthread_kill in -lpthread""... $ac_c" 1>&6 +echo "configure:4388: checking for pthread_kill in -lpthread" >&5 +ac_lib_var=`echo pthread'_'pthread_kill | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lpthread $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + rb_with_pthread=yes +else + echo "$ac_t""no" 1>&6 +rb_with_pthread=no +fi + + if test "$rb_with_pthread" = "yes"; then + LIBS="-lpthread $LIBS" + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _THREAD_SAFE 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_LIBPTHREAD 1 +EOF + + else + echo $ac_n "checking for pthread_kill in -lpthreads""... $ac_c" 1>&6 +echo "configure:4444: checking for pthread_kill in -lpthreads" >&5 +ac_lib_var=`echo pthreads'_'pthread_kill | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lpthreads $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + rb_with_pthread=yes +else + echo "$ac_t""no" 1>&6 +rb_with_pthread=no +fi + + if test "$rb_with_pthread" = "yes"; then + LIBS="-lpthreads $LIBS" + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _THREAD_SAFE 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_LIBPTHREAD 1 +EOF + + else + echo $ac_n "checking for pthread_kill in -lc""... $ac_c" 1>&6 +echo "configure:4500: checking for pthread_kill in -lc" >&5 +ac_lib_var=`echo c'_'pthread_kill | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lc $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + rb_with_pthread=yes +else + echo "$ac_t""no" 1>&6 +rb_with_pthread=no +fi + + if test "$rb_with_pthread" = "yes"; then + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _THREAD_SAFE 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_LIBPTHREAD 1 +EOF + + else + echo $ac_n "checking for pthread_kill in -lc_r""... $ac_c" 1>&6 +echo "configure:4555: checking for pthread_kill in -lc_r" >&5 +ac_lib_var=`echo c_r'_'pthread_kill | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lc_r $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + rb_with_pthread=yes +else + echo "$ac_t""no" 1>&6 +rb_with_pthread=no +fi + + if test "$rb_with_pthread" = "yes"; then + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _THREAD_SAFE 1 +EOF + + cat >> confdefs.h <<\EOF +#define HAVE_LIBPTHREAD 1 +EOF + + MAINLIBS="-pthread $MAINLIBS" + else + echo "configure: warning: 'Don\'t know how to find pthread library on your system -- thread support disabled'" 1>&2 + fi + fi + fi + fi + echo $ac_n "checking for nanosleep""... $ac_c" 1>&6 +echo "configure:4616: checking for nanosleep" >&5 +if eval "test \"`echo '$''{'ac_cv_func_nanosleep'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char nanosleep(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_nanosleep) || defined (__stub___nanosleep) +choke me +#else +nanosleep(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4644: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_nanosleep=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_nanosleep=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'nanosleep`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test "$ac_cv_func_nanosleep" = "no"; then + echo $ac_n "checking for nanosleep in -lrt""... $ac_c" 1>&6 +echo "configure:4665: checking for nanosleep in -lrt" >&5 +ac_lib_var=`echo rt'_'nanosleep | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lrt $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_NANOSLEEP 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + + fi +fi + DEFAULT_KCODE="KCODE_NONE" # Check whether --with-default-kcode or --without-default-kcode was given. @@ -4524,7 +4851,7 @@ echo "configure:4501: checking whether O case "$target_os" in hpux*) DLDFLAGS="-E" - LDSHARED='ld -b' + LDSHARED="ld -b $LDSHARED" LDFLAGS="-Wl,-E" rb_cv_dlopen=yes;; solaris*) if test "$GCC" = yes; then @@ -4539,7 +4866,8 @@ echo "configure:4501: checking whether O rb_cv_dlopen=yes;; sunos*) LDSHARED='ld -assert nodefinitions' rb_cv_dlopen=yes;; - irix*) LDSHARED='ld -shared' + irix*) LDSHARED='ld -shared -L${X11BASE}/lib${ABI}' + LDFLAGS="-L${X11BASE}/lib${ABI} ${LDFLAGS}" rb_cv_dlopen=yes;; sysv4*) LDSHARED='ld -G' rb_cv_dlopen=yes;; @@ -4550,6 +4878,12 @@ echo "configure:4501: checking whether O osf*) LDSHARED="$CC -shared" rb_cv_dlopen=yes ;; linux*) LDSHARED="$CC -shared" + if test "$rb_cv_binary_elf" = yes; then + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)' + LIBPATHFLAG=' -L%1$-s' + RPATHFLAG=' -Wl,-R%1$-s' + fi rb_cv_dlopen=yes ;; freebsd*) LDSHARED="$CC -shared" if test "$rb_cv_binary_elf" = yes; then @@ -4562,6 +4896,9 @@ echo "configure:4501: checking whether O netbsd*) LDSHARED='${CC} -shared' if test "$rb_cv_binary_elf" = yes; then LDFLAGS="-Wl,-export-dynamic" + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)' + LIBPATHFLAG=' -L%1$-s' + RPATHFLAG=' -Wl,-R%1$-s' fi rb_cv_dlopen=yes ;; openbsd*) LDSHARED="ld -Bforcearchive -Bshareable" @@ -5070,6 +5407,7 @@ if test "$enable_shared" = 'yes'; then ;; linux*) LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)' + LIBRUBYARG_SHARED='-Wl,-R -Wl,${libdir} -L${libdir} -L. -l$(RUBY_SO_NAME)' LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so' ;; freebsd*) @@ -5315,6 +5653,15 @@ EOF fi +# Check whether --enable-pthread or --disable-pthread was given. +if test "${enable_pthread+set}" = set; then + enableval="$enable_pthread" + enable_pthread=$enableval +else + enable_pthread=no +fi + + if test -f config.h && tr -d '\015' < confdefs.h | cmp -s config.h -; then echo "config.h unchanged" else