summaryrefslogtreecommitdiff
path: root/dev-libs/hiredis/hiredis-0.13.1.ebuild
blob: 6d9684d43b3881cb1ab04b962434ab99147384ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5

inherit eutils multilib

DESCRIPTION="Minimalistic C client library for the Redis database"
HOMEPAGE="https://github.com/redis/hiredis"
SRC_URI="https://github.com/redis/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="alpha amd64 hppa ppc64 ~x86 ~x86-fbsd ~x64-solaris"
IUSE="examples static-libs test"

DEPEND="test? ( dev-db/redis )"

src_prepare() {
	epatch "${FILESDIR}/${P}-disable-network-tests.patch"

	# use GNU ld syntax on Solaris
	sed -i -e '/DYLIB_MAKE_CMD=.* -G/d' Makefile || die
}

_build() {
	emake \
		AR="$(tc-getAR)" \
		CC="$(tc-getCC)" \
		PREFIX="${EPREFIX%/}/usr" \
		LIBRARY_PATH="$(get_libdir)" \
		ARCH= \
		DEBUG= \
		OPTIMIZATION="${CPPFLAGS}" \
		"$@"
}

src_compile() {
	# The static lib re-uses the same objects as the shared lib, so
	# overhead is low w/creating it all the time.  It's also needed
	# by the tests.
	_build dynamic static hiredis.pc
}

src_test() {
	local REDIS_PID="${T}"/hiredis.pid
	local REDIS_SOCK="${T}"/hiredis.sock
	local REDIS_PORT=56379
	local REDIS_TEST_CONFIG="daemonize yes
		pidfile ${REDIS_PID}
		port ${REDIS_PORT}
		bind 127.0.0.1
		unixsocket //${REDIS_SOCK}"

	_build hiredis-test

	/usr/sbin/redis-server - <<< "${REDIS_TEST_CONFIG}" || die
	./hiredis-test -h 127.0.0.1 -p ${REDIS_PID} -s ${REDIS_SOCK}
	local ret=$?

	kill "$(<"${REDIS_PID}")" || die
	[ ${ret} != "0" ] && die "tests failed"
}

src_install() {
	_build PREFIX="${ED%/}/usr" install
	if use static-libs; then
		rm "${ED%/}/usr/$(get_libdir)/libhiredis.a" || die
	fi
	use examples && dodoc -r examples

	insinto /usr/$(get_libdir)/pkgconfig
	doins ${PN}.pc

	dodoc CHANGELOG.md README.md
}