Now builds on Solaris (issue #110)

This commit is contained in:
Magnus Edenhill 2014-05-04 23:38:52 +02:00
parent 1a7b1e8981
commit f21682ac34
10 changed files with 86 additions and 13 deletions

View File

@ -72,6 +72,7 @@ For an introduction to the performance and usage of librdkafka, see
## Requirements
The GNU toolchain
GNU make
pthreads
zlib

View File

@ -6,18 +6,12 @@ mkl_require lib
mkl_require pic
mkl_require atomics must pass
mkl_require good_cflags
mkl_require socket
# Generate version variables from rdkafka.h hex version define
# so we can use it as string version when generating a pkg-config file.
# Check if sed takes the -r or -E option for extended regexp.
if $(echo foo | sed -r s/foo// > /dev/null 2>&1); then
ESED="sed -r"
else
ESED="sed -E"
fi
verdef=$(grep -E '^#define +RD_KAFKA_VERSION +0x' src/rdkafka.h | $ESED 's/^#define +RD_KAFKA_VERSION +(0x[a-f0-9]+)\.*$/\1/')
verdef=$(grep '^#define *RD_KAFKA_VERSION *0x' src/rdkafka.h | sed 's/^#define *RD_KAFKA_VERSION *\(0x[a-f0-9]*\)\.*$/\1/')
mkl_require parseversion hex2str "%d.%d.%d" "$verdef" RDKAFKA_VERSION_STR
mkl_require gen-pkg-config "rdkafka" "The Apache Kafka C/C++ library" \
@ -36,6 +30,11 @@ function checks {
# Older g++ (<=4.1?) gives invalid warnings for the C++ code.
mkl_mkvar_append CXXFLAGS CXXFLAGS "-Wno-non-virtual-dtor"
# Required on SunOS
if [[ $MKL_DISTRO == "SunOS" ]]; then
mkl_mkvar_append CPPFLAGS CPPFLAGS "-D_POSIX_PTHREAD_SEMANTICS"
fi
# Figure out what tool to use for dumping public symbols.
# We rely on configure.cc setting up $NM if it exists.
if mkl_prog_check "otool" "" cont "otool"; then

View File

@ -6,8 +6,22 @@
#
@funcs = ();
my $last_line = "";
while (<>) {
push(@funcs, $2) if /^(\S+.*\s+\**)?(rd_kafka_\S+)\s+\(/;
chomp;
if (/^(\S+.*\s+\**)?(rd_kafka_\S+)\s+\(/) {
$sym = $2;
# Ignore functions marked as unused since they wont generate
# any symbols and the Solaris linker warns about that.
if ("$last_line.$_" !~ /__attribute__\(\(unused\)\)/) {
push(@funcs, $sym);
}
$last_line = "";
} else {
$last_line = $_;
}
}

View File

@ -24,7 +24,8 @@ function checks {
mkl_check_begin "distro" "" "no-cache" "OS or distribution"
# Try lsb_release
local sys=$(lsb_release -is 2>/dev/null)
local sys
sys=$(lsb_release -is 2>/dev/null)
if [[ $? -gt 0 ]]; then
# That didnt work, try uname.
local kn=$(uname -s)

View File

@ -18,11 +18,31 @@ function checks {
"-shared -Wl,-soname,mkltest.0" "" ; then
# GNU linker
mkl_mkvar_append LIB_LDFLAGS LIB_LDFLAGS '-Wl,-soname,$(LIBNAME).so.$(LIBVER)'
mkl_mkvar_set gnulib_lds WITH_LDS y
elif mkl_compile_check osxlib WITH_OSXLD cont CC \
"-dynamiclib -Wl,-install_name,/tmp/mkltest.so.0" ; then
# OSX linker
mkl_mkvar_append LIB_LDFLAGS LIB_LDFLAGS '-dynamiclib -Wl,-install_name,$(DESTDIR)$(libdir)/$(LIBNAME).so.$(LIBVER)'
fi
# Check what argument is needed for passing linker script.
local ldsfile=$(mktemp _mkltmpXXXX.lds)
echo "{
global:
*;
};
" > $ldsfile
mkl_meta_set ldsflagvs name "linker-script ld flag"
if mkl_compile_check ldsflagvs "" cont CC \
"-shared -Wl,--version-script=$ldsfile"; then
mkl_mkvar_set ldsflagvs LDFLAG_LINKERSCRIPT "-Wl,--version-script="
mkl_mkvar_set gnulib_lds WITH_LDS y
elif mkl_compile_check ldsflagvs "" ignore CC \
"-shared -Wl,-M$ldsfile"; then
mkl_mkvar_set ldsflagvs LDFLAG_LINKERSCRIPT "-Wl,-M"
mkl_mkvar_set gnulib_lds WITH_LDS y
fi
rm -f "$ldsfile"
}

View File

@ -0,0 +1,20 @@
#!/bin/bash
#
# Provides proper compiler flags for socket support, e.g. socket(3).
function checks {
local src="
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
void foo (void) {
int s = socket(0, 0, 0);
close(s);
}"
if ! mkl_compile_check socket "" cont CC "" "$src"; then
if mkl_compile_check socket_nsl "" fail CC "-lsocket -lnsl" "$src"; then
mkl_mkvar_append socket_nsl LIBS "-lsocket -lnsl"
fi
fi
}

View File

@ -29,7 +29,7 @@ clean: lib-clean
ifeq ($(WITH_LDS),y)
# Enable linker script if supported by platform
LIB_LDFLAGS+= -Wl,--version-script=$(LIBNAME).lds
LIB_LDFLAGS+= $(LDFLAG_LINKERSCRIPT)$(LIBNAME).lds
endif
$(LIBNAME).lds: $(HDRS)

View File

@ -33,7 +33,7 @@ clean: lib-clean
ifeq ($(WITH_LDS),y)
# Enable linker script if supported by platform
LIB_LDFLAGS+= -Wl,--version-script=$(LIBNAME).lds
LIB_LDFLAGS+= $(LDFLAG_LINKERSCRIPT)$(LIBNAME).lds
endif
$(LIBNAME).lds: $(HDRS)

View File

@ -34,6 +34,11 @@
#include <endian.h>
#elif defined __BSD__
#include <sys/endian.h>
#elif defined sun
#include <sys/byteorder.h>
#define __bswap_64(x) BSWAP_64(x)
#define __bswap_32(x) BSWAP_32(x)
#define __bswap_16(x) BSWAP_16(x)
#elif defined __APPLE__
#include <sys/_endian.h>
#include <libkern/OSByteOrder.h>

View File

@ -95,8 +95,21 @@
#ifndef be64toh
#ifdef sun
# if __BYTE_ORDER == __BIG_ENDIAN
#define be64toh(x) (x)
# else
# if __BYTE_ORDER == __LITTLE_ENDIAN
#define be64toh(x) ntohll(x)
# endif
# endif
#endif /* sun */
#ifndef __APPLE__
#ifndef sun
#include <byteswap.h>
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
#define be64toh(x) (x)