]> granicus.if.org Git - sudo/commitdiff
Link with -lpthread on HP-UX since a plugin may be linked with -lpthread
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 11 May 2010 16:11:03 +0000 (12:11 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 11 May 2010 16:11:03 +0000 (12:11 -0400)
and dlopen() will fail if the shared object has a dependency on -lpthread
but the main program is not linked with it.

configure
configure.in

index c8626aed4e6c14b955daa3f53688f4eb73c238dd..e368d741e3f6f5846180c8d4b7d380efb5ce093f 100755 (executable)
--- a/configure
+++ b/configure
@@ -26404,6 +26404,75 @@ echo "$as_me: WARNING: Unable to locate gssapi.h, you will have to edit the Make
     LDFLAGS="$_LDFLAGS"
 fi
 
+# On HP-UX, you cannot dlopen() a shared object that uses pthreads
+# unless the main program is linked against -lpthread.  Since we
+# have no knowledge what libraries a plugin may depend on, we always
+# link against -lpthread on HP-UX if it is available.
+# This check should go after all other libraries tests.
+case "$host" in
+    *-*-hpux*)
+       { echo "$as_me:$LINENO: checking for main in -lpthread" >&5
+echo $ECHO_N "checking for main in -lpthread... $ECHO_C" >&6; }
+if test "${ac_cv_lib_pthread_main+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_pthread_main=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_lib_pthread_main=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_main" >&5
+echo "${ECHO_T}$ac_cv_lib_pthread_main" >&6; }
+if test $ac_cv_lib_pthread_main = yes; then
+  SUDO_LIBS="${SUDO_LIBS} -lpthread"
+fi
+
+       ;;
+esac
+
 if test X"$LIBVAS_RPATH" != X""; then
     if test -n "$blibpath"; then
        blibpath_add="${blibpath_add}:$LIBVAS_RPATH"
index 546f89ad013f86713201e5ff161d5e31a100d0a9..f6cf5777c68692764707fce6b58ba4570e0f1cef 100644 (file)
@@ -2618,6 +2618,17 @@ if test ${with_ldap-'no'} != "no"; then
     LDFLAGS="$_LDFLAGS"
 fi
 
+# On HP-UX, you cannot dlopen() a shared object that uses pthreads
+# unless the main program is linked against -lpthread.  Since we
+# have no knowledge what libraries a plugin may depend on, we always
+# link against -lpthread on HP-UX if it is available.
+# This check should go after all other libraries tests.
+case "$host" in
+    *-*-hpux*)
+       AC_CHECK_LIB(pthread, main, [SUDO_LIBS="${SUDO_LIBS} -lpthread"])
+       ;;
+esac
+
 dnl
 dnl Add LIBVAS_RPATH to LDFLAGS
 dnl GNU ld accepts -R/path/ as an alias for -rpath /path/