The attached diffs (relative to todays CVS) detect pthreads on FreeBSD.
Even when the app itself doesn't need threading, any app linked against
Mesa must by compile with "g++ -pthread" (otherwise, "gssInit called
without valid rendering context" rears its ugly but helpful head).

The checks only kick in when pthread.h is present but pthread_exit can't
be found. This seems to me to be the more "generic" way of testing it in
autoconf. Needless to say, testing to see if ${host} matches *freebsd*
would be a quicker way to stuff -pthread into C{,XX}FLAGS :-)

Todays CVS snapshot of FlightGear crashes in the new XML menu stuff;
haven't investigated yet where menubar.xml is supposed to come from
(just joined the list). That said, with the attached patches it pops up
the splash screen, whereas without it, it would die early on.

For what it's worth, the flightgear patch also applies cleanly to
0.9.1-release and makes it work on FreeBSD.

Cheers,

                                -- Bert
-- 
Bert Driehuis -- [EMAIL PROTECTED] -- +31-20-3116119
If the only tool you've got is an axe, every problem looks like fun!
Index: configure.ac
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/configure.ac,v
retrieving revision 1.15
diff -c -r1.15 configure.ac
*** configure.ac        30 Dec 2002 21:33:56 -0000      1.15
--- configure.ac        19 Jan 2003 18:19:47 -0000
***************
*** 147,152 ****
--- 147,169 ----
      CXXFLAGS="$CXXFLAGS -D_REENTRANT"
      CFLAGS="$CFLAGS -D_REENTRANT"
  fi
+ if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = 
+"xyes"; then
+     dnl See if we need -pthread instead of -lpthread
+     save_CXXFLAGS="$CXXFLAGS"
+     save_CFLAGS="$FLAGS"
+     CXXFLAGS="-pthread $CXXFLAGS"
+     CFLAGS="-pthread $FLAGS"
+     save_LIBS=$LIBS
+     AC_CHECK_LIB(c_r, pthread_exit)
+     if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
+       CXXFLAGS=$save_CXXFLAGS
+       CFLAGS=$save_CFLAGS
+     else
+       dnl This is cheating a bit. pthread_exit comes with using -pthread, not 
+-lpthread
+       ac_cv_lib_pthread_pthread_exit="yes"
+     fi
+     LIBS=$save_LIBS
+ fi
  AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a 
"x$ac_cv_header_pthread_h" = "xyes")
  
  AC_CHECK_LIB(socket, socket)
Index: configure.ac
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/configure.ac,v
retrieving revision 1.22
diff -c -r1.22 configure.ac
*** configure.ac        18 Jan 2003 17:36:59 -0000      1.22
--- configure.ac        19 Jan 2003 18:27:35 -0000
***************
*** 98,105 ****
      AC_DEFINE([ENABLE_THREADS], 1, [Define to enable threaded tile paging])
      CXXFLAGS="$CXXFLAGS -D_REENTRANT"
      CFLAGS="$CFLAGS -D_REENTRANT"
-     AC_CHECK_HEADER(pthread.h)
  fi
  AM_CONDITIONAL(WITH_THREADS, test "x$with_threads" = "xyes")
  
  # specify the plib location
--- 98,105 ----
      AC_DEFINE([ENABLE_THREADS], 1, [Define to enable threaded tile paging])
      CXXFLAGS="$CXXFLAGS -D_REENTRANT"
      CFLAGS="$CFLAGS -D_REENTRANT"
  fi
+ AC_CHECK_HEADER(pthread.h)
  AM_CONDITIONAL(WITH_THREADS, test "x$with_threads" = "xyes")
  
  # specify the plib location
***************
*** 204,209 ****
--- 204,223 ----
  
  dnl Thread related checks
  AC_CHECK_LIB(pthread, pthread_exit)
+ if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = 
+"xyes"; then
+     dnl See if we need -pthread instead of -lpthread
+     save_CXXFLAGS="$CXXFLAGS"
+     save_CFLAGS="$FLAGS"
+     CXXFLAGS="-pthread $CXXFLAGS"
+     CFLAGS="-pthread $FLAGS"
+     save_LIBS=$LIBS
+     AC_CHECK_LIB(c_r, pthread_exit)
+     if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
+       CXXFLAGS=$save_CXXFLAGS
+       CFLAGS=$save_CFLAGS
+     fi
+     LIBS=$save_LIBS
+ fi
  AC_CHECK_LIB(socket, socket)
  
  dnl check for glut location

Reply via email to