summaryrefslogtreecommitdiff
blob: 04dd3b4cc65a9381c3bb3dc4f2ca14f0075f442a (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
78
79
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-libs/libbsd/libbsd-0.2.0.ebuild,v 1.3 2011/10/24 20:21:18 maekke Exp $

EAPI=4
inherit eutils multilib toolchain-funcs

DESCRIPTION="A BSD compatibility library"
HOMEPAGE="http://libbsd.freedesktop.org/wiki/"
SRC_URI="http://libbsd.freedesktop.org/releases/${P}.tar.gz"

LICENSE="BSD BSD-2 BSD-4 ISC"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE=""

pkg_setup() {
	mylibbsdconf=(
		libdir=/usr/$(get_libdir)
		usrlibdir=/usr/$(get_libdir)
		pkgconfigdir=/usr/$(get_libdir)/pkgconfig
	)
	if ! has_version "dev-libs/libbsd"; then
		if [[ -e ${ROOT}/usr/$(get_libdir)/libbsd.a ]]; then
			eerror
			eerror "Sorry, you will need to rebuild sys-libs/glibc before"
			eerror "installing dev-libs/libbsd. (emerge -1 sys-libs/glibc)"
			eerror
			die "Unable to install until glibc rebuilt."
		fi
	fi
}

src_prepare() {
	mv include/nlist.h include/bsd/nlist.h
	epatch "${FILESDIR}"/${P}-arc4random-prototypes.patch \
		"${FILESDIR}"/${P}-move-nlist.patch
	sed -i \
		-e 's/gcc /$(CC) ${LDFLAGS} /' \
		-e 's/^	ar /	$(AR) /' \
		Makefile || die "Fix Makefile"
	# Fix header paths in manpages. Has to be done in steps because
	# not every reference in every man page is wrong.
	sed -i \
		-e 's^\.In stdio.h^.In bsd/stdio.h^' \
		src/fgetln.3 \
		src/fmtcheck.3 || die "Fix stdio.h man pages"
	sed -i \
		-e 's^\.In stdlib.h^.In bsd/stdlib.h^' \
		src/humanize_number.3 \
		src/strtonum.3 \
		src/arc4random.3 || die "Fix stdlib.h man pages"
	sed -i \
		-e 's^\.In unistd.h^.In bsd/unistd.h^' \
		src/setmode.3 || die "Fix unistd.h man pages"
	sed -i \
		-e 's^\.In string.h^.In bsd/string.h^' \
		src/strlcpy.3 \
		src/strmode.3 || die "Fix string.h man pages"
	sed -i \
		-e 's^\.Fd #include <mdX.h>^.Fd #include <bsd/mdX.h>^' \
		src/mdX.3 || die "Fix md5.h man pages"
	sed -i \
		-e 's^\.Fd #include <readpassphrase.h>^.Fd #include <bsd/readpassphrase.h>^' \
		src/readpassphrase.3 || die "Fix readpassphrase man page"
	sed -i \
		-e 's^\.In nlist.h^.In bsd/nlist.h^' \
		src/nlist.3
}

src_compile() {
	tc-export CC AR
	emake ${mylibbsdconf[@]}
}

src_install() {
	emake DESTDIR="${D}" ${mylibbsdconf[@]} install
	dodoc ChangeLog README TODO Versions
}