bootstrap-depends.sh 4.01 KB
Newer Older
1
#!/bin/bash  
2
#set -e
Marek Vavruša's avatar
Marek Vavruša committed
3

4
CMOCKA_TAG="cmocka-0.4.1"
5
CMOCKA_URL="git://git.cryptomilk.org/projects/cmocka.git"
6
LIBUV_TAG="v1.x"
7
LIBUV_URL="https://github.com/libuv/libuv.git"
8
KNOT_TAG="v2.1.1"
9
KNOT_URL="https://github.com/CZ-NIC/knot.git"
10 11 12 13 14 15 16 17
GMP_TAG="6.0.0"
GMP_URL="https://gmplib.org/download/gmp/gmp-${GMP_TAG}.tar.xz"
JANSSON_TAG="2.7"
JANSSON_URL="http://www.digip.org/jansson/releases/jansson-${JANSSON_TAG}.tar.gz"
NETTLE_TAG="2.7.1"
NETTLE_URL="https://ftp.gnu.org/gnu/nettle/nettle-${NETTLE_TAG}.tar.gz"
GNUTLS_TAG="3.3.12"
GNUTLS_URL="ftp://ftp.gnutls.org/gcrypt/gnutls/v3.3/gnutls-${GNUTLS_TAG}.tar.xz"
18
LUA_TAG="v2.1.0-beta2"
19
LUA_URL="https://github.com/LuaJIT/LuaJIT.git"
20
HIREDIS_TAG="v0.13.3"
21
HIREDIS_URL="https://github.com/redis/hiredis.git"
22 23
LIBMEMCACHED_TAG="1.0.18"
LIBMEMCACHED_URL="https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz"
Marek Vavruša's avatar
Marek Vavruša committed
24

25 26
# prepare install prefix
PREFIX=${1}; [ -z ${PREFIX} ] && export PREFIX="${HOME}/.local"
27
install -d ${PREFIX}/{lib,libexec,include,bin,sbin,man,share,etc,info,doc,var}
Marek Vavruša's avatar
Marek Vavruša committed
28

29
# prepare build env
30
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
31 32 33
export BUILD_DIR="$(pwd)/.build-depend"
export LOG=$(pwd)/build.log
[ ! -e ${BUILD_DIR} ] && mkdir ${BUILD_DIR}; cd ${BUILD_DIR}
Marek Vavruša's avatar
Marek Vavruša committed
34 35
echo "build: ${BUILD_DIR}"
echo "log:   ${LOG}" | tee ${LOG}
36

37 38 39
function on_failure {
	cat ${LOG}
}
Marek Vavruša's avatar
Marek Vavruša committed
40
trap on_failure ERR
41

42 43
function fetch_pkg {
	if [ "${2##*.}" == git ]; then
44 45
		[ ! -e $1 ] && git clone "$2" $1 &> /dev/null
		cd $1; git checkout $3 &> /dev/null; cd -
46
	else
47
		[ ! -f $1.tar.${2##*.} ] && curl -L "$2" > $1.tar.${2##*.}
48 49 50 51 52 53
		tar xf $1.tar.${2##*.}
	fi
	cd $1
}

function build_pkg {
54
	if [ -f configure.ac ]; then
55 56 57
		if [ ! -e ./configure ]; then
			[ -e autogen.sh ] && sh autogen.sh || autoreconf -if
		fi
58
		./configure --prefix=${PREFIX} --enable-shared $*
59 60
		make ${MAKEOPTS}
		make install
61 62 63 64 65
	elif [ -f CMakeLists.txt ]; then
		[ -e cmake-build ] && rm -rf cmake-build; mkdir cmake-build; cd cmake-build
		cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} ..
		make ${MAKEOPTS}
		make install
66
	else
67
		make $*
68 69 70 71
	fi
}

function pkg {
72
	if [ ! -e ${PREFIX}/$4 ] && [ "${BUILD_IGNORE}" == "${BUILD_IGNORE/$1/}" ] ; then
73 74 75 76 77 78 79 80 81
		cd ${BUILD_DIR}
		echo "[x] fetching $1-$3"
		fetch_pkg "$1-$3" "$2" $3 >> ${LOG}
		echo "[x] building $1-$3"
		shift 4
		(build_pkg $*) >> ${LOG} 2>&1
	fi
}

82
# travis-specific
83
PIP_PKGS="dnspython==1.11 cpp-coveralls Jinja2"
84 85 86
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
	DEPEND_CACHE="https://dl.dropboxusercontent.com/u/2255176/resolver-${TRAVIS_OS_NAME}-cache.tar.gz"
	curl "${DEPEND_CACHE}" > cache.tar.gz && tar -xz -C ${HOME} -f cache.tar.gz || true
Marek Vavruša's avatar
Marek Vavruša committed
87
	brew update
88
	brew install --force makedepend python hiredis libmemcached || true
89 90
	brew link --overwrite python || true
	pip install --upgrade pip || true
Marek Vavruša's avatar
Marek Vavruša committed
91
	pip install ${PIP_PKGS}
92 93
fi
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
Marek Vavruša's avatar
Marek Vavruša committed
94
	pip install --user ${USER} ${PIP_PKGS} || true
95
	rm ${HOME}/.cache/pip/log/debug.log || true
96 97
	pkg hiredis ${HIREDIS_URL} ${HIREDIS_TAG} include/hiredis/hiredis.h install PREFIX=${PREFIX}
	pkg libmemcached ${LIBMEMCACHED_URL} ${LIBMEMCACHED_TAG} include/libmemcached/memcached.h
98 99
fi

100
pkg gmp ${GMP_URL} ${GMP_TAG} include/gmp.h --disable-static
101 102 103 104 105
pkg nettle ${NETTLE_URL} ${NETTLE_TAG} include/nettle \
	--disable-documentation --with-lib-path=${PREFIX}/lib --with-include-path=${PREFIX}/include
export GMP_CFLAGS="-I${PREFIX}/include"
export GMP_LIBS="-L${PREFIX}/lib -lgmp"
pkg gnutls ${GNUTLS_URL} ${GNUTLS_TAG} include/gnutls \
106
	--disable-tests --disable-doc --disable-valgrind-tests --disable-static --with-included-libtasn1
107
pkg jansson ${JANSSON_URL} ${JANSSON_TAG} include/jansson.h --disable-static
108
pkg libknot ${KNOT_URL} ${KNOT_TAG} include/libknot \
109 110
	--disable-static --with-lmdb=no --disable-fastparser --disable-daemon --disable-utilities --disable-documentation
pkg cmocka ${CMOCKA_URL} ${CMOCKA_TAG} include/cmocka.h
111
pkg libuv ${LIBUV_URL} ${LIBUV_TAG} include/uv.h --disable-static
112
pkg lua ${LUA_URL} ${LUA_TAG} lib/pkgconfig/luajit.pc install BUILDMODE=dynamic LDFLAGS=-lm PREFIX=${PREFIX}
113 114 115

# remove on successful build
rm -rf ${BUILD_DIR}