From f307354df645d61f872b74102d501068c9443e2e Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sun, 3 Feb 2013 20:35:06 -0500 Subject: [PATCH] Harmonize WIN32, and update bootstrap --- Makefile.am | 9 +++++---- bootstrap.sh | 38 ++++++++++++++++++++++++------------- clients/memcapable.cc | 2 +- clients/utilities.cc | 4 ++-- libmemcached-1.0/platform.h | 4 ++-- libmemcached/common.h | 2 +- libmemcached/connect.cc | 8 ++++---- libmemcached/include.am | 4 ++-- libmemcached/poll.cc | 6 +++--- libmemcached/poll.h | 6 +++--- libmemcachedutil-1.0/pid.h | 4 ++-- libtest/common.h | 2 +- libtest/dream.cc | 2 +- libtest/lite.h | 2 +- 14 files changed, 53 insertions(+), 40 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6aa50af8..a359ac00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,6 +86,8 @@ TESTS += ${bin_PROGRAMS} TESTS += ${check_PROGRAMS} XFAIL_TESTS += ${bin_PROGRAMS} +if ! BUILD_WIN32 + merge-clean: @find ./ | $(GREP) \.gcda | xargs rm -f @find ./ | $(GREP) \.gcno | xargs rm -f @@ -101,8 +103,8 @@ merge-clean: @echo "Files that need to be either removed or checked in:" @bzr unknowns -clean-local: - -rm -rf docs/_build docs/doctrees +clean-local: clean-libtest-check clean-docs-check + lcov: lcov-clean check @echo @@ -117,11 +119,10 @@ lcov-clean: clean @rm -rf lcov */lcov.out @find . -name '*.gcno' | xargs rm -f @find . -name '*.gcda' | xargs rm -f +endif DISTCLEANFILES+= config/top.h -clean-local: clean-libtest-check clean-docs-check - maintainer-clean-local: find . -type f -name '*~' -exec rm -f '{}' \; -rm -f @PACKAGE@-*.rpm diff --git a/bootstrap.sh b/bootstrap.sh index fdc43f99..194dd695 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -296,42 +296,42 @@ function run_configure () # Arguments for configure local BUILD_CONFIGURE_ARG= - # Set ENV DEBUG in order to enable debugging + # If ENV DEBUG is set we enable both debug and asssert, otherwise we see if this is a VCS checkout and if so enable assert + # Set ENV ASSERT in order to enable assert if $DEBUG; then - BUILD_CONFIGURE_ARG='--enable-debug' + BUILD_CONFIGURE_ARG+=' --enable-debug --enable-assert' + elif [[ -n "$VCS_CHECKOUT" ]]; then + BUILD_CONFIGURE_ARG+=' --enable-assert' fi - # Set ENV ASSERT in order to enable assert - if [[ -n "$ASSERT" ]]; then - local ASSERT_ARG= - ASSERT_ARG='--enable-assert' - BUILD_CONFIGURE_ARG="$ASSERT_ARG $BUILD_CONFIGURE_ARG" + if [[ -n "$CONFIGURE_ARG" ]]; then + BUILD_CONFIGURE_ARG+=" $CONFIGURE_ARG" fi - if [[ -n "$CONFIGURE_ARG" ]]; then - BUILD_CONFIGURE_ARG= "$BUILD_CONFIGURE_ARG $CONFIGURE_ARG" + if [[ -n "$PREFIX_ARG" ]]; then + BUILD_CONFIGURE_ARG+=" $PREFIX_ARG" fi ret=1; # If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV case $HOST_OS in *-darwin-*) - CC=clang CXX=clang++ $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG $PREFIX_ARG" + CC=clang CXX=clang++ $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG" ret=$? ;; rhel-5*) command_exists 'gcc44' || die "Could not locate gcc44" - CC=gcc44 CXX=gcc44 $top_srcdir/configure $BUILD_CONFIGURE_ARG $PREFIX_ARG || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG $PREFIX_ARG" + CC=gcc44 CXX=gcc44 $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG" ret=$? ;; *) - $CONFIGURE $BUILD_CONFIGURE_ARG $PREFIX_ARG + $CONFIGURE $BUILD_CONFIGURE_ARG ret=$? ;; esac if [ $ret -ne 0 ]; then - die "Could not execute $CONFIGURE $BUILD_CONFIGURE_ARG $PREFIX_ARG" + die "Could not execute $CONFIGURE $BUILD_CONFIGURE_ARG" fi if [ ! -f 'Makefile' ]; then @@ -367,6 +367,10 @@ function save_BUILD () die "OLD_CONFIGURE_ARG($OLD_CONFIGURE_ARG) was set on push, programmer error!" fi + if [[ -n "$OLD_PREFIX" ]]; then + die "OLD_PREFIX($OLD_PREFIX) was set on push, programmer error!" + fi + if [[ -n "$OLD_MAKE" ]]; then die "OLD_MAKE($OLD_MAKE) was set on push, programmer error!" fi @@ -402,6 +406,10 @@ function restore_BUILD () CONFIGURE_ARG=$OLD_CONFIGURE_ARG fi + if [[ -n "$OLD_PREFIX" ]]; then + CONFIGURE_ARG=$OLD_PREFIX + fi + if [[ -n "$OLD_MAKE" ]]; then MAKE=$OLD_MAKE fi @@ -412,6 +420,7 @@ function restore_BUILD () OLD_CONFIGURE= OLD_CONFIGURE_ARG= + OLD_PREFIX= OLD_MAKE= OLD_TESTS_ENVIRONMENT= @@ -1142,6 +1151,8 @@ function determine_vcs () VCS_CHECKOUT=svn elif [[ -d '.hg' ]]; then VCS_CHECKOUT=hg + else + VCS_CHECKOUT= fi if [[ -n "$VCS_CHECKOUT" ]]; then @@ -1580,6 +1591,7 @@ function main () local OLD_CONFIGURE= local OLD_CONFIGURE_ARG= + local OLD_PREFIX= local OLD_MAKE= local OLD_TESTS_ENVIRONMENT= diff --git a/clients/memcapable.cc b/clients/memcapable.cc index c8d294f9..0343e15d 100644 --- a/clients/memcapable.cc +++ b/clients/memcapable.cc @@ -124,7 +124,7 @@ static struct addrinfo *lookuphost(const char *hostname, const char *port) */ static memcached_socket_t set_noblock(void) { -#ifdef WIN32 +#if defined(_WIN32) u_long arg = 1; if (ioctlsocket(sock, FIONBIO, &arg) == SOCKET_ERROR) { diff --git a/clients/utilities.cc b/clients/utilities.cc index 5f5958e2..15889051 100644 --- a/clients/utilities.cc +++ b/clients/utilities.cc @@ -184,12 +184,12 @@ void process_hash_option(memcached_st *memc, char *opt_hash) void initialize_sockets(void) { /* Define the function for all platforms to avoid #ifdefs in each program */ -#if defined(WIN32) && WIN32 +#if defined(_WIN32) WSADATA wsaData; if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0) { fprintf(stderr, "Socket Initialization Error. Program aborted\n"); exit(EXIT_FAILURE); } -#endif +#endif // #if defined(_WIN32) } diff --git a/libmemcached-1.0/platform.h b/libmemcached-1.0/platform.h index 9cbc705f..efdf53f8 100644 --- a/libmemcached-1.0/platform.h +++ b/libmemcached-1.0/platform.h @@ -38,7 +38,7 @@ #pragma once -#if defined(WIN32) || defined(__MINGW32__) +#if defined(_WIN32) # include # include @@ -59,4 +59,4 @@ typedef SOCKET memcached_socket_t; typedef int memcached_socket_t; -#endif /* WIN32 */ +#endif /* _WIN32 */ diff --git a/libmemcached/common.h b/libmemcached/common.h index fac6d775..71db19b0 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -107,7 +107,7 @@ # include #endif -#if defined(WIN32) || defined(__MINGW32__) +#if defined(_WIN32) # include "libmemcached/windows.hpp" #endif diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 2ec9975c..22e259f4 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -267,7 +267,7 @@ static memcached_return_t set_hostinfo(org::libmemcached::Instance* server) static inline void set_socket_nonblocking(org::libmemcached::Instance* server) { -#ifdef WIN32 +#if defined(_WIN32) u_long arg= 1; if (ioctlsocket(server->fd, FIONBIO, &arg) == SOCKET_ERROR) { @@ -372,7 +372,7 @@ static bool set_socket_options(org::libmemcached::Instance* server) #if defined(_WIN32) #else -#if defined(SO_NOSIGPIPE) +# if defined(SO_NOSIGPIPE) if (SO_NOSIGPIPE) { int set= 1; @@ -388,7 +388,7 @@ static bool set_socket_options(org::libmemcached::Instance* server) #endif } } -#endif // SO_NOSIGPIPE +# endif // SO_NOSIGPIPE #endif // _WIN32 if (server->root->flags.no_block) @@ -461,7 +461,7 @@ static bool set_socket_options(org::libmemcached::Instance* server) static memcached_return_t unix_socket_connect(org::libmemcached::Instance* server) { -#ifndef WIN32 +#ifndef _WIN32 WATCHPOINT_ASSERT(server->fd == INVALID_SOCKET); do { diff --git a/libmemcached/include.am b/libmemcached/include.am index f604731a..9eb1942c 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -61,8 +61,8 @@ libmemcached_libmemcached_la_CXXFLAGS= -DBUILDING_LIBMEMCACHED if BUILD_WIN32 libmemcached_libmemcached_la_CFLAGS+= -DBUILDING_HASHKIT libmemcached_libmemcached_la_CXXFLAGS+= -DBUILDING_HASHKIT -libmemcached_libmemcached_la_LIBADD+= -lmingw64 -libmemcached_libmemcached_la_LIBADD+= -lws2_64 +libmemcached_libmemcached_la_LIBADD+= -lmingw32 +libmemcached_libmemcached_la_LIBADD+= -lws2_32 endif libmemcached_libmemcached_la_SOURCES+= libmemcached/instance.cc diff --git a/libmemcached/poll.cc b/libmemcached/poll.cc index abd15d4c..6fdf242c 100644 --- a/libmemcached/poll.cc +++ b/libmemcached/poll.cc @@ -12,7 +12,7 @@ #include "libmemcached/common.h" -#if defined(WIN32) || defined(__MINGW32__) +#if defined(_WIN32) #include "libmemcached/poll.h" #include @@ -31,7 +31,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int tmo) { if (fds[x].events & (POLLIN | POLLOUT)) { -#ifndef WIN32 +#ifndef _WIN32 if (fds[x].fd > maxfd) { maxfd= fds[x].fd; @@ -82,4 +82,4 @@ int poll(struct pollfd fds[], nfds_t nfds, int tmo) return ret; } -#endif // defined(WIN32) || defined(__MINGW32__) +#endif // defined(_WIN32) diff --git a/libmemcached/poll.h b/libmemcached/poll.h index 8445f009..46636c40 100644 --- a/libmemcached/poll.h +++ b/libmemcached/poll.h @@ -12,7 +12,7 @@ #pragma once -#if defined(WIN32) || defined(__MINGW32__) +#if defined(_WIN32) #include @@ -22,7 +22,7 @@ extern "C" { typedef struct pollfd { -#ifdef WIN32 +#if defined(_WIN32) SOCKET fd; #else int fd; @@ -45,4 +45,4 @@ int poll(struct pollfd fds[], nfds_t nfds, int tmo); } #endif -#endif // defined(WIN32) || defined(__MINGW32__) +#endif // defined(_WIN32) diff --git a/libmemcachedutil-1.0/pid.h b/libmemcachedutil-1.0/pid.h index 01738acc..3ce0131c 100644 --- a/libmemcachedutil-1.0/pid.h +++ b/libmemcachedutil-1.0/pid.h @@ -36,8 +36,8 @@ #pragma once -#ifndef WIN32 -#include +#ifndef _WIN32 +# include #endif #include diff --git a/libtest/common.h b/libtest/common.h index 7be0221c..b611e1a9 100644 --- a/libtest/common.h +++ b/libtest/common.h @@ -69,7 +69,7 @@ # include #endif -#if defined(WIN32) || defined(__MINGW32__) +#if defined(_WIN32) # include "win32/wrappers.h" # define get_socket_errno() WSAGetLastError() #else diff --git a/libtest/dream.cc b/libtest/dream.cc index 114ac672..cd7d6aa6 100644 --- a/libtest/dream.cc +++ b/libtest/dream.cc @@ -41,7 +41,7 @@ namespace libtest { void dream(time_t tv_sec, long tv_nsec) { -#ifdef WIN32 +#if defined(_WIN32) if (tv_sec == 0 and tv_nsec) { tv_sec++; diff --git a/libtest/lite.h b/libtest/lite.h index 52e96380..100b8e20 100644 --- a/libtest/lite.h +++ b/libtest/lite.h @@ -51,7 +51,7 @@ # include #endif -#ifdef _WIN32 +#if defined(_WIN32) # include #else # include -- 2.30.2