1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
7 #PYTHON_COMPAT=( python3_{6,7} )
9 # 4.3.4 will need python-single-r1
10 inherit fcaps fortran-2 linux-info toolchain-funcs
12 DESCRIPTION="A performance-oriented tool suite for x86 multicore environments"
13 HOMEPAGE="https://github.com/rrze-likwid/likwid"
14 SRC_URI="https://ftp.fau.de/pub/likwid/${P}.tar.gz"
16 # If this ebuild is changed to use the bundled Lua-5.3, then MIT should be
17 # added to the LICENSE field.
21 KEYWORDS="~amd64" # upstream partial support exists for x86 arm arm64
22 IUSE="fortran" # ${PYTHON_REQUIRED_USE}
25 # likwid's primary functionality is driven by a set of lua scripts installed in
27 # likwid bundles lua-5.3.2, AND supports using a system copy of lua-5.2 or
28 # lua-5.3, which we use. This ebuild uses the system copy of Lua instead.
31 # likwid bundles a MODIFIED copy of hwloc-2.0.0a1 with specific configuration
32 # for CPU probing & access
35 # likwid uses Perl to convert from an internal text format to ASM listings
36 # likwid also uses perl for some installed helper scripts
37 # The build system bundles some Perl modules, that are not removed at this time:
42 # Python3 is used for one helper script, filter/json, added after 4.3.3
43 CDEPEND="dev-lang/perl
46 # filter/json uses Python3
50 # Part of the build process depends on Data::Dumper
51 # perl-core/Data-Dumper"
54 CONFIG_CHECK="~X86_MSR"
57 -M 755 cap_sys_rawio+ep usr/sbin/likwid-accessD
59 -M 755 cap_sys_rawio+ep usr/sbin/likwid-setFreq
63 "${FILESDIR}/${PN}-4.3.1-fix-gnustack.patch"
64 # Old patches are obsolete:
65 #"${FILESDIR}/${PN}-4.3.1-Makefile.patch"
66 #"${FILESDIR}/${PN}-4.3.1-config.mk.patch"
71 #python-single-r1_pkg_setup
75 # Ensure we build with a non executable stack
77 -e '/^SHARED_CFLAGS/s/$/ -Wa,--noexecstack/' \
78 -i make/include_{GCC*,CLANG}.mk \
79 || die "Failed to set nonexecstack"
81 # Make the install targets respect Q= for being quiet or not
82 # MUCH easier for debugging
84 -e '/^install/,/^[a-z]/{/^\t@/{ s/@/$(Q)/; }}' \
86 Makefile || die "Failed to sed Makefile"
89 -e '/^\.NOTPARALLEL:/d' \
92 ext/hwloc/Makefile || die "Failed to re-enable parallel"
98 # Warning: this build system uses PREFIX in a way that differs from
99 # autoconf! It's more like:
100 # PREFIX=$(DESTDIR)$(INSTALLED_PREFIX)
101 # it's not 100% like that, because parts of the Makefiles are inconsistent.
102 # this is the same solution used in the upstream RPM specs
103 # these variables are uppercase so they match what's put into Make.
104 local INSTALLED_PREFIX=/usr
105 local INSTALLED_LIBPREFIX=/usr/$(get_libdir) # upstream is '$(INSTALLED_PREFIX)/lib'
106 local INSTALLED_MANPREFIX=/usr/share/man # upstream has it as used but undefined variable.
107 # TODO: support LUA_SINGLE_TARGET here later for Lua 5.2
109 # If the build is too loud, pass 'Q=@'
112 "INSTALLED_PREFIX=${INSTALLED_PREFIX}"
113 "INSTALLED_LIBPREFIX=${INSTALLED_LIBPREFIX}"
114 "INSTALLED_MANPREFIX=${INSTALLED_MANPREFIX}"
115 "PREFIX=${INSTALLED_PREFIX}"
116 "LIBPREFIX=${INSTALLED_LIBPREFIX}"
117 "MANPREFIX=${INSTALLED_MANPREFIX}"
119 "ANSI_CFLAGS=${CFLAGS}"
120 "INSTRUMENT_BENCH=true"
121 "LUA_INCLUDE_DIR=/usr/include/lua${LUASLOT}"
122 "LUA_LIB_DIR=/usr/$(get_libdir)"
123 "LUA_LIB_NAME=lua${LUASLOT}"
125 "FORTRAN_INTERFACE=$(usex fortran likwid.mod false)"
126 "FC=$(usex fortran "${FC}" false)"
127 "FCFLAGS=-J ./ -fsyntax-only" # needed for building correctly
130 "PREFIX=${D}${INSTALLED_PREFIX}"
131 "LIBPREFIX=${D}${INSTALLED_LIBPREFIX}"
132 "MANPREFIX=${D}${INSTALLED_MANPREFIX}"
139 "${src_compile_opts[@]}"
145 "${src_compile_opts[@]}" \
146 "${src_install_opts[@]}" \
150 use fortran && doheader likwid.mod
152 # Fix Python filter added shortly after 4.3.3
153 #python_fix_shebang "${D}"/usr/share/likwid/filter/
155 # Do NOT use 'doman'! The upstream 'make install' target does a sed as it's
156 # generating the final manpage to the real install dir; and the copies in
157 # ${S} are unmodified.
158 dodoc README.md CHANGELOG doc/logo.png
161 dodoc -r doc/applications doc/archs
162 # Fix upstream partial doc install
163 rm -rf "${D}"/usr/share/likwid/docs || die
164 ln -sf "/usr/share/doc/${PF}" "${D}"/usr/share/likwid/docs || die
168 # This is now a symlink, but used to be a plain directory
169 OLDDOCDIR=/usr/share/likwid/docs
170 if [[ ! -L "${OLDDOCDIR}" && -d "${OLDDOCDIR}" ]]; then
171 einfo "Cleaning up old docdir at ${OLDDOCDIR}"
172 rm -rf "${OLDDOCDIR}" || die
178 einfo "If you get 'Cannot gather values from MSR_PLATFORM_INFO', then 'modprobe msr'!"
180 ewarn "To enable users to access performance counters it is necessary to"
181 ewarn "change the access permissions to /dev/cpu/msr[0]* devices."
182 ewarn "It can be accomplished by adding the following line to file"
183 ewarn "/etc/udev/rules.d/99-myrules.rules: KERNEL==\"msr[0-9]*\" MODE=\"0666\""
184 ewarn "Alternatively, assign the MSR files to a unique group and use mode 0660"