sys-apps/gawk: stable 5.0.1 for ppc64, bug #725374
[gentoo.git] / sys-apps / likwid / likwid-4.3.3.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 FORTRAN_NEEDED=fortran
7 #PYTHON_COMPAT=( python3_{6,7} )
8
9 # 4.3.4 will need python-single-r1
10 inherit fcaps fortran-2 linux-info toolchain-funcs
11
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"
15
16 # If this ebuild is changed to use the bundled Lua-5.3, then MIT should be
17 # added to the LICENSE field.
18 LICENSE="GPL-3+ BSD"
19
20 SLOT="0"
21 KEYWORDS="~amd64" # upstream partial support exists for x86 arm arm64
22 IUSE="fortran" # ${PYTHON_REQUIRED_USE}
23
24 # lua:
25 # likwid's primary functionality is driven by a set of lua scripts installed in
26 # /usr/bin/
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.
29 #
30 # hwloc:
31 # likwid bundles a MODIFIED copy of hwloc-2.0.0a1 with specific configuration
32 # for CPU probing & access
33 #
34 # Perl:
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:
38 # Parse-RecDescent
39 # Template
40 #
41 # Python:
42 # Python3 is used for one helper script, filter/json, added after 4.3.3
43 CDEPEND="dev-lang/perl
44         dev-lang/lua:5.3"
45
46 # filter/json uses Python3
47 RDEPEND="${CDEPEND}"
48         #${PYTHON_DEPS}"
49
50 # Part of the build process depends on Data::Dumper
51 #       perl-core/Data-Dumper"
52 DEPEND="${CDEPEND}"
53
54 CONFIG_CHECK="~X86_MSR"
55
56 FILECAPS=(
57         -M 755 cap_sys_rawio+ep usr/sbin/likwid-accessD
58         --
59         -M 755 cap_sys_rawio+ep usr/sbin/likwid-setFreq
60 )
61
62 PATCHES=(
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"
67 )
68
69 pkg_setup() {
70         fortran-2_pkg_setup
71         #python-single-r1_pkg_setup
72 }
73
74 src_prepare() {
75         # Ensure we build with a non executable stack
76         sed \
77                 -e '/^SHARED_CFLAGS/s/$/ -Wa,--noexecstack/' \
78                 -i make/include_{GCC*,CLANG}.mk \
79                 || die "Failed to set nonexecstack"
80
81         # Make the install targets respect Q= for being quiet or not
82         # MUCH easier for debugging
83         sed -r \
84                 -e '/^install/,/^[a-z]/{/^\t@/{ s/@/$(Q)/; }}' \
85                 -i \
86                 Makefile || die "Failed to sed Makefile"
87
88         sed -i \
89                 -e '/^\.NOTPARALLEL:/d' \
90                 Makefile \
91                 bench/Makefile \
92                 ext/hwloc/Makefile || die "Failed to re-enable parallel"
93
94         default
95 }
96
97 export_emake_opts() {
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
108         local LUASLOT='5.3'
109         # If the build is too loud, pass 'Q=@'
110         src_compile_opts=(
111                 "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}"
118                 "CC=$(tc-getCC)"
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}"
124                 "LUA_BIN=/usr/bin"
125                 "FORTRAN_INTERFACE=$(usex fortran likwid.mod false)"
126                 "FC=$(usex fortran "${FC}" false)"
127                 "FCFLAGS=-J ./ -fsyntax-only" # needed for building correctly
128         )
129         src_install_opts=(
130                 "PREFIX=${D}${INSTALLED_PREFIX}"
131                 "LIBPREFIX=${D}${INSTALLED_LIBPREFIX}"
132                 "MANPREFIX=${D}${INSTALLED_MANPREFIX}"
133         )
134 }
135
136 src_compile() {
137         export_emake_opts
138         emake \
139                 "${src_compile_opts[@]}"
140 }
141
142 src_install() {
143         export_emake_opts
144         emake \
145                 "${src_compile_opts[@]}" \
146                 "${src_install_opts[@]}" \
147                 DESTDIR="${D}" \
148                 install
149
150         use fortran && doheader likwid.mod
151
152         # Fix Python filter added shortly after 4.3.3
153         #python_fix_shebang "${D}"/usr/share/likwid/filter/
154
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
159         dodoc doc/*.txt
160         dodoc doc/*.md
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
165 }
166
167 pkg_preinst() {
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
173         fi
174 }
175
176 pkg_postinst() {
177         fcaps_pkg_postinst
178         einfo "If you get 'Cannot gather values from MSR_PLATFORM_INFO', then 'modprobe msr'!"
179         einfo
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"
185 }