From 07b92bf6a5bc3f81da461594d03e45ddf9cfc840 Mon Sep 17 00:00:00 2001 From: Bryce Denney Date: Sat, 2 Jun 2001 03:07:28 +0000 Subject: [PATCH] - 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. --- bochs/Makefile.in | 2 +- bochs/configure | 64 +++++++++++++++++++++++++++++++--------------- bochs/configure.in | 35 +++++++++++++++++-------- 3 files changed, 70 insertions(+), 31 deletions(-) diff --git a/bochs/Makefile.in b/bochs/Makefile.in index d1d66e1f6..decd80801 100644 --- a/bochs/Makefile.in +++ b/bochs/Makefile.in @@ -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 diff --git a/bochs/configure b/bochs/configure index 9decd65d3..3334b41d9 100755 --- a/bochs/configure +++ b/bochs/configure @@ -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 < +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 <&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 <&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 diff --git a/bochs/configure.in b/bochs/configure.in index 350736d51..cc0f421bb 100644 --- a/bochs/configure.in +++ b/bochs/configure.in @@ -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_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)