summaryrefslogtreecommitdiff
blob: 52c115ce41c356eef6e85b02b26112ef212b3ce5 (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
80
81
82
83
84
85
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5

FORTRAN_NEEDED=fortran

inherit eutils fcaps linux-info multilib fortran-2

DESCRIPTION="A performance-oriented tool suite for x86 multicore environments"
HOMEPAGE="https://github.com/rrze-likwid/likwid"
SRC_URI="https://github.com/rrze-likwid/likwid/archive/likwid-${PV}.tar.gz"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64"
IUSE="fortran"

RDEPEND="dev-lang/perl"

DEPEND="${RDEPEND}
	sys-apps/sed
	fortran? ( sys-devel/gcc:*[fortran] )
	dev-lang/lua:0"

CONFIG_CHECK="~X86_MSR"

FILECAPS=(
	cap_sys_rawio usr/sbin/likwid-accessD --
	cap_sys_rawio usr/bin/likwid-{perfctr,bench,powermeter}
)

S=${WORKDIR}/likwid-likwid-${PV}

src_prepare() {
	# See Bug 558402
	epatch "${FILESDIR}"/${P}-Makefile.patch \
			"${FILESDIR}"/${P}-fix-gnustack.patch \
			"${FILESDIR}"/${P}-lua-makefile.patch \
			"${FILESDIR}"/${P}-config.mk.patch

	# Set PREFIX path to include sandbox path
	sed -e 's:^PREFIX = .*:PREFIX = '${D}'/usr:' -i config.mk || die

	# Set correct LDFLAGS
	sed -e '/LIBS/aSHARED_LFLAGS += -Wl,-soname,$@' \
		-i make/include_GCC.mk || die

	# Insert date and version info man pages
	sed -e 's/<DATE>/21.08.2015/g' \
		-e "s/VERSION/${PV}/g" \
		-i doc/*.1 || die

	# Set path to the access daemon, once installed into the system
	sed -e "/exeprog/s|TOSTRING(ACCESSDAEMON)|\"/usr/sbin/likwid-accessD\"|" \
		-i src/accessClient.c || die

	# Ensure we build with a non executable stack
	sed -e "s:CFLAGS += \$(SHARED_CFLAGS):CFLAGS += \$(SHARED_CFLAGS) -g -Wa,--noexecstack:" \
	        -i make/config_defines.mk || die

	if use fortran; then

		# If fortran USE is enabled, enable the fortran interfaces
		sed -i 's:^FORTRAN_INTERFACE = false:FORTRAN_INTERFACE = likwid.mod:' config.mk || die

		# Set the correct fortrant compiler for GCC
		sed -i "s:^FC  = ifort:FC = ${FC}:" make/include_GCC.mk || die

		# Set the correct FCFLAGS for gcc fortran
		sed -i '/^FCFLAGS/c\FCFLAGS  = -J ./ -fsyntax-only' make/include_GCC.mk || die
	fi

}

src_install () {
	default
	if use fortran; then
		insinto /usr/include
		doins likwid.mod
	fi

	doman doc/*.1
}