--- configure.in Mon Aug 6 00:38:46 2007 +++ configure.in Thu Sep 18 18:30:00 2008 @@ -470,14 +470,25 @@ dnl # On Some systems, we need extra pre-processor flags, to get them to dnl # to do the threading properly. dnl # - AC_CHECK_LIB(pthread, pthread_create, - [ CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" - LIBS="$LIBS -lpthread" ], - AC_CHECK_LIB(c_r, pthread_create, - [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ], - [ WITH_THREADS="no" ] - ) - ) +dnl # On FreeBSD, check the pthread_create function with -pthread in $CFLAGS +dnl # but WITHOUT -lpthread (see FreeBSD Porter's Handbook, section 12.12 +dnl # at http://tinyurl.com/34cya8 ) + case "$build" in + *-freebsd*) + CFLAGS="$CFLAGS -pthread" + AC_CHECK_FUNC(pthread_create, , [ WITH_THREADS="no" ]) + ;; + *) + AC_CHECK_LIB(pthread, pthread_create, + [ CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" + LIBS="$LIBS -lpthread" ], + AC_CHECK_LIB(c_r, pthread_create, + [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ], + [ WITH_THREADS="no" ] + ) + ) + ;; + esac fi dnl # --- src/modules/rlm_ldap/configure.in Fri Jul 27 17:51:33 2007 +++ src/modules/rlm_ldap/configure.in Thu Sep 18 18:30:00 2008 @@ -77,14 +77,27 @@ dnl pthread stuff is usually in -lpthread dnl or in -lc_r, on *BSD + dnl FreeBSD uses -pthread if test "x$rlm_ldap_with_threads" = "xyes"; then - AC_CHECK_LIB(pthread, pthread_create, - [ LIBS="-lpthread $LIBS" ], - AC_CHECK_LIB(c_r, pthread_create, - [ LIBS="-lc_r $LIBS" ], - [ rlm_ldap_with_threads="no" ] - ) - ) + case "$build" in + *-freebsd*) + old_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -pthread" + AC_CHECK_FUNC(pthread_create, , [ rlm_ldap_with_threads="no" ]) + if test "x$rlm_ldap_with_threads" = "xno"; then + CFLAGS=$old_CFLAGS + fi + ;; + *) + AC_CHECK_LIB(pthread, pthread_create, + [ LIBS="-lpthread $LIBS" ], + AC_CHECK_LIB(c_r, pthread_create, + [ LIBS="-lc_r $LIBS" ], + [ rlm_ldap_with_threads="no" ] + ) + ) + ;; + esac fi dnl Try only "-lldap_r" or "-lldap" --- src/modules/rlm_sql/drivers/rlm_sql_mysql/configure.in Fri Nov 25 20:31:54 2005 +++ src/modules/rlm_sql/drivers/rlm_sql_mysql/configure.in Thu Sep 18 18:30:00 2008 @@ -61,14 +61,27 @@ dnl pthread stuff is usually in -lpthread dnl or in -lc_r, on *BSD + dnl FreeBSD uses -pthread if test "x$mysql_with_threads" = "xyes"; then - AC_CHECK_LIB(pthread, pthread_create, - [ LIBS="-lpthread $LIBS" ], - AC_CHECK_LIB(c_r, pthread_create, - [ LIBS="-lc_r $LIBS" ], - [ mysql_with_threads=no ] - ) - ) + case "$build" in + *-freebsd*) + old_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -pthread" + AC_CHECK_FUNC(pthread_create, , [ mysql_with_threads="no" ]) + if test "x$mysql_with_threads" = "xno"; then + CFLAGS=$old_CFLAGS + fi + ;; + *) + AC_CHECK_LIB(pthread, pthread_create, + [ LIBS="-lpthread $LIBS" ], + AC_CHECK_LIB(c_r, pthread_create, + [ LIBS="-lc_r $LIBS" ], + [ mysql_with_threads=no ] + ) + ) + ;; + esac fi if test "x$mysql_with_threads" = "xyes"; then --- src/modules/rlm_python/configure.in Mon May 14 23:27:21 2007 +++ src/modules/rlm_python/configure.in Thu Sep 18 18:30:00 2008 @@ -85,6 +85,34 @@ FR_SMART_CHECK_LIB(python${PY_VERSION}, Py_Initialize) LIBS=$old_LIBS +dnl # If that check fails, try it again having identified threading libraries +dnl # in case libpython is threaded + + if test "x$smart_lib" = "x"; then + AC_MSG_NOTICE([Checking to see if libpython needs -pthread.]) + libpython_with_threads="yes" + case "$build" in + *-freebsd*) + old_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -pthread" + AC_CHECK_FUNC(pthread_create, , [ libpython_with_threads="no" ]) + if test "x$libpython_with_threads" = "xno"; then + CFLAGS=$old_CFLAGS + fi + ;; + *) + ;; + esac + + if test "x$libpython_with_threads" = "xyes"; then + old_LIBS=$LIBS + LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm" + smart_try_dir=$PY_LIB_DIR + FR_SMART_CHECK_LIB(python${PY_VERSION}, Py_Initialize) + LIBS=$old_LIBS + fi + fi + eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}} if test "x$t" = "xyes"; then python_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS -lpython${PY_VERSION} -lm"