- first test if -pthread arg to compiler causes pthread library to work.

If so, use it.  Otherwise, check if -lpthread works.  If so, us it.
  Otherwise, print an error and fail.
This commit is contained in:
Bryce Denney 2001-06-02 03:07:28 +00:00
parent 86dc440418
commit 07b92bf6a5
3 changed files with 70 additions and 31 deletions

View File

@ -74,7 +74,7 @@ X_LIBS = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
GUI_LINK_OPTS_X = $(X_LIBS) $(X_PRE_LIBS) -lX11
GUI_LINK_OPTS_BEOS = -lbe
GUI_LINK_OPTS_RFB = -lpthread
GUI_LINK_OPTS_RFB = @RFB_LIBS@
GUI_LINK_OPTS_WIN32 = -luser32 -lgdi32 -lwinmm -lcomdlg32 -lcomctl32
GUI_LINK_OPTS_WIN32_VCPP = user32.lib gdi32.lib winmm.lib \
comdlg32.lib comctl32.lib wsock32.lib

64
bochs/configure vendored
View File

@ -4228,9 +4228,36 @@ fi
fi
if test "$with_rfb" = yes; then
# if RFB, check if pthread library is available
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
echo "configure:4234: checking for pthread_create in -lpthread" >&5
# first see if compiler takes "-pthread" argument
echo $ac_n "checking for -pthread arg to compiler""... $ac_c" 1>&6
echo "configure:4234: checking for -pthread arg to compiler" >&5
CFLAGS_SAVE="$CFLAGS"
CFLAGS="$CFLAGS -pthread"
cat > conftest.$ac_ext <<EOF
#line 4238 "configure"
#include "confdefs.h"
#include <pthread.h>
int main() {
pthread_create(0,0,0,0);
; return 0; }
EOF
if { (eval echo configure:4245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
# it compiles with -pthread
echo "$ac_t""yes" 1>&6
CXXFLAGS="$CXXFLAGS -pthread"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
echo "$ac_t""no" 1>&6
# now try with -lpthread
CFLAGS="$CFLAGS_SAVE"
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
echo "configure:4261: checking for pthread_create in -lpthread" >&5
ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -4238,7 +4265,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthread $LIBS"
cat > conftest.$ac_ext <<EOF
#line 4242 "configure"
#line 4269 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -4249,7 +4276,7 @@ int main() {
pthread_create()
; return 0; }
EOF
if { (eval echo configure:4253: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -4264,23 +4291,20 @@ LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_lib=HAVE_LIB`echo pthread | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
cat >> confdefs.h <<EOF
#define $ac_tr_lib 1
EOF
LIBS="-lpthread $LIBS"
# it compiles with -lpthread
RFB_LIBS='-lpthread'
else
echo "$ac_t""no" 1>&6
echo ERROR: --with-rfb requires the pthread library, which could not be found.
exit 1
echo ERROR: --with-rfb requires the pthread library, which could not be found.; exit 1
fi
fi
rm -f conftest*
fi
@ -4301,11 +4325,10 @@ fi
# Extract the first word of "gzip", so it can be a program name with args.
set dummy gzip; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4309: checking for $ac_word" >&5
echo "configure:4332: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GZIP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -4340,7 +4363,7 @@ fi
# Extract the first word of "tar", so it can be a program name with args.
set dummy tar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4344: checking for $ac_word" >&5
echo "configure:4367: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_TAR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -4542,6 +4565,7 @@ s%@IODEV_LIB_VAR@%$IODEV_LIB_VAR%g
s%@NONINLINE_VAR@%$NONINLINE_VAR%g
s%@INLINE_VAR@%$INLINE_VAR%g
s%@EXTERNAL_DEPENDENCY@%$EXTERNAL_DEPENDENCY%g
s%@RFB_LIBS@%$RFB_LIBS%g
s%@GUI_OBJS@%$GUI_OBJS%g
s%@GUI_LINK_OPTS@%$GUI_LINK_OPTS%g
s%@GUI_LINK_OPTS_TERM@%$GUI_LINK_OPTS_TERM%g

View File

@ -865,19 +865,34 @@ if test "$use_curses" = yes; then
fi
if test "$with_rfb" = yes; then
# if RFB, check if pthread library is available
AC_CHECK_LIB(pthread,
pthread_create,
[],
# first see if compiler takes "-pthread" argument
AC_MSG_CHECKING(for -pthread arg to compiler)
CFLAGS_SAVE="$CFLAGS"
CFLAGS="$CFLAGS -pthread"
AC_TRY_LINK([ #include <pthread.h> ],
[ pthread_create(0,0,0,0); ],
[
# it compiles with -pthread
AC_MSG_RESULT(yes)
CXXFLAGS="$CXXFLAGS -pthread"
],
[
echo ERROR: --with-rfb requires the pthread library, which could not be found.
exit 1
]
)
AC_MSG_RESULT(no)
# now try with -lpthread
CFLAGS="$CFLAGS_SAVE"
AC_CHECK_LIB(pthread,
pthread_create,
[
# it compiles with -lpthread
RFB_LIBS='-lpthread'
],
[
echo ERROR: --with-rfb requires the pthread library, which could not be found.; exit 1
])
])
fi
AC_SUBST(RFB_LIBS)
AC_SUBST(GUI_OBJS)
AC_SUBST(GUI_LINK_OPTS)
AC_SUBST(GUI_LINK_OPTS_TERM)