Switching back to static linking to avoid platform issues and have

confidence when in deployment of what code is being used.
This commit is contained in:
Gregory Burd 2013-04-16 11:47:04 -04:00
parent 941bb0a929
commit 249c600554
6 changed files with 169 additions and 48 deletions

View file

@ -13,9 +13,11 @@ all: compile
deps: get-deps
get-deps:
c_src/build_deps.sh get-deps
@$(REBAR) get-deps
update-deps:
c_src/build_deps.sh update-deps
@$(REBAR) update-deps
c_src/wterl.o: c_src/async_nif.h

View file

@ -1,40 +1,151 @@
#!/bin/bash
# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
POSIX_SHELL="true"
export POSIX_SHELL
exec /usr/bin/ksh $0 $@
fi
unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well
set -e
WT_REPO=http://github.com/wiredtiger/wiredtiger.git
WT_BRANCH=basho
WT_REMOTE_REPO=http://github.com/wiredtiger/wiredtiger.git
WT_VSN=""
WT_DIR=wiredtiger-$WT_BRANCH
#SNAPPY_REPO=
#SNAPPY_BRANCH=
SNAPPY_VSN="1.0.4"
SNAPPY_DIR=snappy-$SNAPPY_VSN
#BZIP2_REPO=
#BZIP2_BRANCH=
BZIP2_VSN="1.0.6"
BZIP2_DIR=bzip2-$BZIP2_VSN
[ `basename $PWD` != "c_src" ] && cd c_src
BASEDIR="$PWD"
export BASEDIR="$PWD"
which gmake 1>/dev/null 2>/dev/null && MAKE=gmake
MAKE=${MAKE:-make}
export CFLAGS="$CFLAGS -g -I $BASEDIR/system/include"
export CXXFLAGS="$CXXFLAGS -I $BASEDIR/system/include"
export LDFLAGS="$LDFLAGS -L$BASEDIR/system/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$BASEDIR/system/lib:$LD_LIBRARY_PATH"
build_wt ()
{
(cd $BASEDIR/$WT_DIR/build_posix && \
$MAKE -j && $MAKE install)
}
build_snappy ()
{
(cd $BASEDIR/$SNAPPY_DIR && \
$MAKE -j && \
$MAKE install
)
}
build_bzip2 ()
{
(cd $BASEDIR/$BZIP2_DIR && \
$MAKE -j && \
$MAKE install
)
}
case "$1" in
clean)
rm -rf system wiredtiger
rm -rf system $WT_DIR $SNAPPY_DIR $BZIP2_DIR
;;
test)
(cd $BASEDIR/$WT_DIR && $MAKE -j test)
;;
update-deps)
if [ -d $BASEDIR/$WT_DIR/.git ]; then
(cd $BASEDIR/$WT_DIR
if [ "X$WT_VSN" == "X" ]; then
git pull -u || exit 1
else
git checkout $WT_VSN || exit 1
fi
)
fi
;;
get-deps)
# WiredTiger
if [ -d $BASEDIR/$WT_DIR/.git ]; then
(cd $BASEDIR/$WT_DIR && git pull -u) || exit 1
else
if [ "X$WT_VSN" == "X" ]; then
git clone ${WT_REPO} && \
(cd $BASEDIR/wiredtiger && git checkout $WT_VSN || exit 1)
else
git clone -b ${WT_BRANCH} --single-branch ${WT_REPO} && \
(cd $BASEDIR/wiredtiger && git checkout -b $WT_BRANCH || exit 1)
fi
mv wiredtiger $WT_DIR || exit 1
fi
[ -d $BASEDIR/$WT_DIR ] || (echo "Missing WiredTiger source directory" && exit 1)
(cd $BASEDIR/$WT_DIR
[ -e $BASEDIR/wiredtiger-*.patch ] && \
(patch -p1 --forward < $BASEDIR/wiredtiger-*.patch || exit 1 )
./autogen.sh || exit 1
cd ./build_posix || exit 1
[ -e Makefile ] && $MAKE distclean
../configure --with-pic \
--disable-shared \
--enable-snappy \
--enable-bzip2 \
--prefix=${BASEDIR}/system || exit 1
)
# Snappy
[ -e snappy-$SNAPPY_VSN.tar.gz ] || (echo "Missing Snappy ($SNAPPY_VSN) source package" && exit 1)
[ -d $BASEDIR/$SNAPPY_DIR ] || tar -xzf snappy-$SNAPPY_VSN.tar.gz
[ -e $BASEDIR/snappy-*.patch ] && \
(cd $BASEDIR/$SNAPPY_DIR || exit 1
patch -p1 --forward < $BASEDIR/snappy-*.patch || exit 1)
(cd $BASEDIR/$SNAPPY_DIR || exit 1
./configure --with-pic \
--disable-shared \
--prefix=$BASEDIR/system || exit 1
)
# BZip2
[ -e bzip2-$BZIP2_VSN.tar.gz ] || (echo "Missing bzip2 ($BZIP2_VSN) source package" && exit 1)
[ -d $BASEDIR/$BZIP2_DIR ] || tar -xzf bzip2-$BZIP2_VSN.tar.gz
[ -e $BASEDIR/bzip2-*.patch ] && \
(cd $BASEDIR/$BZIP2_DIR || exit 1
patch -p1 --forward < $BASEDIR/bzip2-*.patch || exit 1)
;;
*)
test -f system/lib/libwiredtiger.a && exit 0
# Build Snappy
[ -d $BASEDIR/$SNAPPY_DIR ] || (echo "Missing Snappy source directory (did you first get-deps?)" && exit 1)
test -f system/lib/libsnappy.a || build_snappy;
# Build BZIP2
[ -d $BASEDIR/$BZIP2_DIR ] || (echo "Missing BZip2 source directory (did you first get-deps?)" && exit 1)
test -f system/lib/libbz2.a || build_bzip2;
# Build WiredTiger
[ -d $BASEDIR/$WT_DIR ] || (echo "Missing WiredTiger source directory (did you first get-deps?)" && exit 1)
test -f system/lib/libwiredtiger.a -a \
-f system/lib/libwiredtiger_snappy.a -a \
-f system/lib/libwiredtiger_bzip2.a || build_wt;
[ -d $BASEDIR/../priv ] || mkdir ${BASEDIR}/../priv
cp $BASEDIR/system/bin/wt ${BASEDIR}/../priv
if [ -d wiredtiger/.git ]; then
(cd wiredtiger && \
git fetch && \
git merge origin/${WT_BRANCH})
else
git clone -b ${WT_BRANCH} --single-branch ${WT_REMOTE_REPO} && \
(cd wiredtiger && \
patch -p1 < ../wiredtiger-extension-link.patch && \
./autogen.sh)
fi
(cd wiredtiger/build_posix && \
CFLAGS="-I/usr/local/include -L/usr/local/lib" \
../configure --with-pic \
--enable-snappy \
--prefix=${BASEDIR}/system && \
make -j && make install)
[ -d ${BASEDIR}/../priv ] || mkdir ${BASEDIR}/../priv
cp ${BASEDIR}/system/bin/wt ${BASEDIR}/../priv
cp ${BASEDIR}/system/lib/*.so ${BASEDIR}/../priv
;;
esac

11
c_src/bzip2-build.patch Normal file
View file

@ -0,0 +1,11 @@
--- foo/Makefile.orig 2013-04-16 10:25:18.837249297 -0400
+++ foo/Makefile 2013-04-16 10:28:32.113926986 -0400
@@ -24,7 +24,7 @@
CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
# Where you want it installed when you do 'make install'
-PREFIX=/usr/local
+PREFIX=$(BASEDIR)/system
OBJS= blocksort.o \

View file

@ -0,0 +1,20 @@
diff --git a/ext/compressors/bzip2/Makefile.am b/ext/compressors/bzip2/Makefile.am
index 0aedc2e..9cd96e3 100644
--- a/ext/compressors/bzip2/Makefile.am
+++ b/ext/compressors/bzip2/Makefile.am
@@ -3,4 +3,4 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include
lib_LTLIBRARIES = libwiredtiger_bzip2.la
libwiredtiger_bzip2_la_SOURCES = bzip2_compress.c
libwiredtiger_bzip2_la_LDFLAGS = -avoid-version -module
-libwiredtiger_bzip2_la_LIBADD = -lbz2
+libwiredtiger_bzip2_la_LIBADD = -l$(BASEDIR)/system/lib/libbz2.a
diff --git a/ext/compressors/snappy/Makefile.am b/ext/compressors/snappy/Makefile.am
index 6d78823..286dc55 100644
--- a/ext/compressors/snappy/Makefile.am
+++ b/ext/compressors/snappy/Makefile.am
@@ -3,4 +3,4 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include
lib_LTLIBRARIES = libwiredtiger_snappy.la
libwiredtiger_snappy_la_SOURCES = snappy_compress.c
libwiredtiger_snappy_la_LDFLAGS = -avoid-version -module
-libwiredtiger_snappy_la_LIBADD = -lsnappy
+libwiredtiger_snappy_la_LIBADD = -l$(BASEDIR)/system/lib/libsnappy.a

View file

@ -1,22 +0,0 @@
diff --git a/ext/compressors/bzip2/Makefile.am b/ext/compressors/bzip2/Makefile.am
index 0aedc2e..1cc4cf6 100644
--- a/ext/compressors/bzip2/Makefile.am
+++ b/ext/compressors/bzip2/Makefile.am
@@ -2,5 +2,5 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include
lib_LTLIBRARIES = libwiredtiger_bzip2.la
libwiredtiger_bzip2_la_SOURCES = bzip2_compress.c
-libwiredtiger_bzip2_la_LDFLAGS = -avoid-version -module
+libwiredtiger_bzip2_la_LDFLAGS = -avoid-version -module -Wl,-rpath,lib/wterl/priv:priv:/usr/local/lib
libwiredtiger_bzip2_la_LIBADD = -lbz2
diff --git a/ext/compressors/snappy/Makefile.am b/ext/compressors/snappy/Makefile.am
index 6d78823..7d35777 100644
--- a/ext/compressors/snappy/Makefile.am
+++ b/ext/compressors/snappy/Makefile.am
@@ -2,5 +2,5 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include
lib_LTLIBRARIES = libwiredtiger_snappy.la
libwiredtiger_snappy_la_SOURCES = snappy_compress.c
-libwiredtiger_snappy_la_LDFLAGS = -avoid-version -module
+libwiredtiger_snappy_la_LDFLAGS = -avoid-version -module -Wl,-rpath,lib/wterl/priv:priv:/usr/local/lib
libwiredtiger_snappy_la_LIBADD = -lsnappy

View file

@ -37,9 +37,8 @@
{port_env, [
{"DRV_CFLAGS", "$DRV_CFLAGS -Werror -I c_src/system/include"},
{"DRV_LDFLAGS", "$DRV_LDFLAGS -Wl,-rpath,lib/wterl/priv:priv -Lpriv -lwiredtiger"}
{"DRV_LDFLAGS", "$DRV_LDFLAGS -Lc_src/system/lib -lsnappy -lbz2 -lwiredtiger -lwiredtiger_snappy -lwiredtiger_bzip2"}
]}.
{pre_hooks, [{compile, "c_src/build_deps.sh"}]}.
{pre_hooks, [{compile, "c_src/build_deps.sh compile"}]}.
{post_hooks, [{clean, "c_src/build_deps.sh clean"}]}.