@@ -261,6 +261,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -36,10 +36,10 @@
/* Define to 1 if you have the `posix_memalign' function. */
#undef HAVE_POSIX_MEMALIGN
-/* Found pthread_cancel */
+/* Define to 1 if you have the `pthread_cancel' function. */
#undef HAVE_PTHREAD_CANCEL
-/* Found pthread_kill */
+/* Define to 1 if you have the `pthread_kill' function. */
#undef HAVE_PTHREAD_KILL
/* Define to 1 if you have the <stdint.h> header file. */
@@ -652,6 +652,7 @@ OS_FREEBSD_TRUE
os_libs
os_cflags
GETOPT_O_FILES
+PTHREAD_LIB
CPP
LT_SYS_LIBRARY_PATH
OTOOL64
@@ -12332,9 +12333,10 @@ _ACEOF
fi
done
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_cancel" >&5
-$as_echo_n "checking for library containing pthread_cancel... " >&6; }
-if ${ac_cv_search_pthread_cancel+:} false; then :
+SAVED_LIBS=$LIBS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5
+$as_echo_n "checking for library containing pthread_create... " >&6; }
+if ${ac_cv_search_pthread_create+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
@@ -12347,11 +12349,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
-char pthread_cancel ();
+char pthread_create ();
int
main ()
{
-return pthread_cancel ();
+return pthread_create ();
;
return 0;
}
@@ -12364,89 +12366,47 @@ for ac_lib in '' pthread; do
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_pthread_cancel=$ac_res
+ ac_cv_search_pthread_create=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
- if ${ac_cv_search_pthread_cancel+:} false; then :
+ if ${ac_cv_search_pthread_create+:} false; then :
break
fi
done
-if ${ac_cv_search_pthread_cancel+:} false; then :
+if ${ac_cv_search_pthread_create+:} false; then :
else
- ac_cv_search_pthread_cancel=no
+ ac_cv_search_pthread_create=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_cancel" >&5
-$as_echo "$ac_cv_search_pthread_cancel" >&6; }
-ac_res=$ac_cv_search_pthread_cancel
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5
+$as_echo "$ac_cv_search_pthread_create" >&6; }
+ac_res=$ac_cv_search_pthread_create
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-$as_echo "#define HAVE_PTHREAD_CANCEL 1" >>confdefs.h
-
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_kill" >&5
-$as_echo_n "checking for library containing pthread_kill... " >&6; }
-if ${ac_cv_search_pthread_kill+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pthread_kill ();
-int
-main ()
-{
-return pthread_kill ();
- ;
- return 0;
-}
+# AC_SEARCH_LIBS adds libraries at the start of $LIBS so remove $SAVED_LIBS
+# from the end of $LIBS.
+pthread_lib=${LIBS%${SAVED_LIBS}}
+for ac_func in pthread_cancel pthread_kill
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
-for ac_lib in '' pthread; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_pthread_kill=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_pthread_kill+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_pthread_kill+:} false; then :
-else
- ac_cv_search_pthread_kill=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_kill" >&5
-$as_echo "$ac_cv_search_pthread_kill" >&6; }
-ac_res=$ac_cv_search_pthread_kill
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-$as_echo "#define HAVE_PTHREAD_KILL 1" >>confdefs.h
+done
-fi
+LIBS=$SAVED_LIBS
+PTHREAD_LIB=$pthread_lib
@@ -25,8 +25,14 @@ AC_CHECK_FUNCS(posix_fadvise)
AC_CHECK_FUNCS(posix_memalign)
AC_CHECK_FUNCS(sysconf)
AC_CHECK_FUNCS(lseek64)
-AC_SEARCH_LIBS([pthread_cancel], [pthread], [AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Found pthread_cancel])], [])
-AC_SEARCH_LIBS([pthread_kill], [pthread], [AC_DEFINE(HAVE_PTHREAD_KILL, 1, [Found pthread_kill])], [])
+SAVED_LIBS=$LIBS
+AC_SEARCH_LIBS([pthread_create], [pthread])
+# AC_SEARCH_LIBS adds libraries at the start of $LIBS so remove $SAVED_LIBS
+# from the end of $LIBS.
+pthread_lib=${LIBS%${SAVED_LIBS}}
+AC_CHECK_FUNCS([pthread_cancel pthread_kill])
+LIBS=$SAVED_LIBS
+AC_SUBST(PTHREAD_LIB, [$pthread_lib])
AC_SUBST(GETOPT_O_FILES)
AC_CANONICAL_HOST
@@ -219,6 +219,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -239,6 +239,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -283,6 +283,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -208,6 +208,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -86,7 +86,7 @@ sg_modes_LDADD = ../lib/libsgutils2.la @os_libs@
sg_opcodes_LDADD = ../lib/libsgutils2.la @os_libs@
-sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -lpthread
+sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ @PTHREAD_LIB@
sg_persist_LDADD = ../lib/libsgutils2.la @os_libs@
@@ -499,6 +499,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -590,7 +591,7 @@ sg_map_LDADD = ../lib/libsgutils2.la @os_libs@
sgm_dd_LDADD = ../lib/libsgutils2.la @os_libs@
sg_modes_LDADD = ../lib/libsgutils2.la @os_libs@
sg_opcodes_LDADD = ../lib/libsgutils2.la @os_libs@
-sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -lpthread
+sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ @PTHREAD_LIB@
sg_persist_LDADD = ../lib/libsgutils2.la @os_libs@
sg_prevent_LDADD = ../lib/libsgutils2.la @os_libs@
sg_raw_LDADD = ../lib/libsgutils2.la @os_libs@
Let the configure script detect whether pthread functions occur in the pthread library (all platforms except Android) or in the C library (Android). From the autoconf manual: action-if-found is a list of shell commands to run if the link with the library succeeds; action-if-not-found is a list of shell commands to run if the link fails. If action-if-found is not specified, the default action prepends -llibrary to LIBS and defines 'HAVE_LIBlibrary' (in all capitals). Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> --- Makefile.in | 1 + config.h.in | 4 +-- configure | 94 +++++++++++++++-------------------------------------- configure.ac | 10 ++++-- doc/Makefile.in | 1 + include/Makefile.in | 1 + lib/Makefile.in | 1 + scripts/Makefile.in | 1 + src/Makefile.am | 2 +- src/Makefile.in | 3 +- 10 files changed, 45 insertions(+), 73 deletions(-)