From cae912d05bfb354d81427c6ae5354eab90869fe9 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 11 Aug 2003 18:07:38 +0000 Subject: [PATCH] Do not link in libwsock32 on non-win32 platforms. Improve grammar of thread-safety comments. --- configure | 136 ++++++++++++++++++++----------------- configure.in | 31 ++++++--- src/include/pg_config.h.in | 8 +-- 3 files changed, 96 insertions(+), 79 deletions(-) diff --git a/configure b/configure index 75948fc3d0..2ba5879468 100755 --- a/configure +++ b/configure @@ -844,7 +844,7 @@ Optional Features: --enable-debug build with debugging symbols (-g) --enable-depend turn on automatic dependency tracking --enable-cassert enable assertion checks (for debugging) - --enable-thread-safety allow libpq and ecpg to be thread-safe + --enable-thread-safety make client libraries thread-safe --disable-largefile omit support for large files Optional Packages: @@ -1381,7 +1381,7 @@ echo "$as_me: error: '$withval' is not a valid template name. Use 'list' for a l else - # --with-template not given +# --with-template not given case $host_os in aix*) template=aix ;; @@ -2354,9 +2354,13 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + +# # Read the template +# . "$srcdir/src/template/$template" || exit +# adjust CFLAGS per template if test "$ac_env_CFLAGS_set" = set; then CFLAGS=$ac_env_CFLAGS_value fi @@ -2773,10 +2777,10 @@ done IFS=$ac_save_IFS # -# Enable libpq to be thread-safety +# Enable thread-safe client libraries # -echo "$as_me:$LINENO: checking allow thread-safe libpq and ecpg" >&5 -echo $ECHO_N "checking allow thread-safe libpq and ecpg... $ECHO_C" >&6 +echo "$as_me:$LINENO: checking allow thread-safe client libraries" >&5 +echo $ECHO_N "checking allow thread-safe client libraries... $ECHO_C" >&6 # Check whether --enable-thread-safety or --disable-thread-safety was given. @@ -5294,65 +5298,6 @@ _ACEOF fi - -echo "$as_me:$LINENO: checking for main in -lwsock32" >&5 -echo $ECHO_N "checking for main in -lwsock32... $ECHO_C" >&6 -if test "${ac_cv_lib_wsock32_main+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lwsock32 $LIBS" -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -#include "confdefs.h" - - -#ifdef F77_DUMMY_MAIN -# ifdef __cplusplus - extern "C" -# endif - int F77_DUMMY_MAIN() { return 1; } -#endif -int -main () -{ -main (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_wsock32_main=yes -else - echo "$as_me: failed program was:" >&5 -cat conftest.$ac_ext >&5 -ac_cv_lib_wsock32_main=no -fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_wsock32_main" >&5 -echo "${ECHO_T}$ac_cv_lib_wsock32_main" >&6 -if test $ac_cv_lib_wsock32_main = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBWSOCK32 1 -_ACEOF - - LIBS="-lwsock32 $LIBS" - -fi - echo "$as_me:$LINENO: checking for library containing getopt_long" >&5 echo $ECHO_N "checking for library containing getopt_long... $ECHO_C" >&6 if test "${ac_cv_search_getopt_long+set}" = set; then @@ -5873,6 +5818,69 @@ _ACEOF fi +# WIN32: +if test "$PORTNAME" = "win32" +then + +echo "$as_me:$LINENO: checking for main in -lwsock32" >&5 +echo $ECHO_N "checking for main in -lwsock32... $ECHO_C" >&6 +if test "${ac_cv_lib_wsock32_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lwsock32 $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_wsock32_main=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_wsock32_main=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_wsock32_main" >&5 +echo "${ECHO_T}$ac_cv_lib_wsock32_main" >&6 +if test $ac_cv_lib_wsock32_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBWSOCK32 1 +_ACEOF + + LIBS="-lwsock32 $LIBS" + +fi + +fi if test "$with_readline" = yes; then diff --git a/configure.in b/configure.in index ae683fb266..fcd50520b3 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $Header: /cvsroot/pgsql/configure.in,v 1.279 2003/08/07 21:38:55 tgl Exp $ +dnl $Header: /cvsroot/pgsql/configure.in,v 1.280 2003/08/11 18:07:38 tgl Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -52,7 +52,7 @@ PGAC_ARG_REQ(with, template, [], esac ], [ - # --with-template not given +# --with-template not given case $host_os in aix*) template=aix ;; @@ -178,11 +178,11 @@ AC_MSG_RESULT([$default_port]) # Need both of these because some places want an integer and some a string AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port}, [Define to the default TCP port number on which the server listens and -to which clients will try to connect to. This can be overridden at -run-time, but it's convenient if your clients have the right default -compiled in. (--with-pgport=PORTNUM)]) +to which clients will try to connect. This can be overridden at run-time, +but it's convenient if your clients have the right default compiled in. +(--with-pgport=PORTNUM)]) AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}", - [Define to the default TCP port number as string constant.]) + [Define to the default TCP port number as a string constant.]) AC_SUBST(default_port) # @@ -223,9 +223,13 @@ case $template in esac AC_PROG_CC([$pgac_cc_list]) + +# # Read the template +# . "$srcdir/src/template/$template" || exit +# adjust CFLAGS per template if test "$ac_env_CFLAGS_set" = set; then CFLAGS=$ac_env_CFLAGS_value fi @@ -311,11 +315,12 @@ done IFS=$ac_save_IFS # -# Enable libpq to be thread-safety +# Enable thread-safe client libraries # -AC_MSG_CHECKING([allow thread-safe libpq and ecpg]) -PGAC_ARG_BOOL(enable, thread-safety, no, [ --enable-thread-safety allow libpq and ecpg to be thread-safe], - [AC_DEFINE([USE_THREADS], 1, [Define to 1 to build libpq and ecpg to be thread-safe. (--enable-thread-safety)])]) +AC_MSG_CHECKING([allow thread-safe client libraries]) +PGAC_ARG_BOOL(enable, thread-safety, no, [ --enable-thread-safety make client libraries thread-safe], + [AC_DEFINE([USE_THREADS], 1, + [Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety)])]) AC_MSG_RESULT([$enable_thread_safety]) AC_SUBST(enable_thread_safety) @@ -631,7 +636,6 @@ AC_CHECK_LIB(BSD, main) AC_CHECK_LIB(gen, main) AC_CHECK_LIB(PW, main) AC_CHECK_LIB(resolv, main) -AC_CHECK_LIB(wsock32, main) AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt]) # QNX: AC_CHECK_LIB(unix, main) @@ -645,6 +649,11 @@ fi AC_SEARCH_LIBS(fdatasync, [rt posix4]) # Cygwin: AC_CHECK_LIB(cygipc, shmget) +# WIN32: +if test "$PORTNAME" = "win32" +then + AC_CHECK_LIB(wsock32, main) +fi if test "$with_readline" = yes; then PGAC_CHECK_READLINE diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 379f0f4f99..acb140b856 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -25,12 +25,12 @@ #undef ALIGNOF_SHORT /* Define to the default TCP port number on which the server listens and to - which clients will try to connect to. This can be overridden at run-time, - but it's convenient if your clients have the right default compiled in. + which clients will try to connect. This can be overridden at run-time, but + it's convenient if your clients have the right default compiled in. (--with-pgport=PORTNUM) */ #undef DEF_PGPORT -/* Define to the default TCP port number as string constant. */ +/* Define to the default TCP port number as a string constant. */ #undef DEF_PGPORT_STR /* Define to 1 if you want National Language Support. (--enable-nls) */ @@ -603,7 +603,7 @@ /* Define to select SysV-style shared memory. */ #undef USE_SYSV_SHARED_MEMORY -/* Define to 1 to build libpq and ecpg to be thread-safe. +/* Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety) */ #undef USE_THREADS