summaryrefslogtreecommitdiff
blob: b0bcd1ed763a3fb9d695d9c691d01d1418c6ff49 (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
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit toolchain-funcs

DESCRIPTION="Simple implementation of msgpack in C"
HOMEPAGE="https://github.com/libmpack/libmpack"
SRC_URI="https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~sparc x86 ~x64-macos"

src_prepare() {
	default

	# Make compiling verbose
	sed -e 's/@$(LIBTOOL)/$(LIBTOOL)/g' -i Makefile || die

	# Respect users CFLAGS
	sed -e 's/-ggdb//g' -i Makefile || die
	sed -e 's/-O3//g' -i .config/release.mk || die
}

src_compile() {
	local myemakeargs=(
		"PREFIX=${EPREFIX}/usr"
		"CC=$(tc-getCC)"
		"config=release"
		"LIBDIR=/usr/$(get_libdir)"
	)

	emake "${myemakeargs[@]}" lib-bin
}

src_test() {
	emake XLDFLAGS="-shared" test
}

src_install() {
	local myemakeargs=(
		"PREFIX=${EPREFIX}/usr"
		"DESTDIR=${ED}"
		"LIBDIR=/usr/$(get_libdir)"
		"XLDFLAGS=-shared"
	)

	emake "${myemakeargs[@]}" install

	if [[ ${CHOST} == *-darwin* ]] ; then
		local file="libmpack.0.0.0.dylib"
		install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${file}" "${ED}/usr/$(get_libdir)/${file}" || die "Failed to adjust install_name"
	fi

	find "${ED}" -name '*.la' -delete || die
}