1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit versionator eutils toolchain-funcs linux-info autotools flag-o-matic
8 DESCRIPTION="Misc tools bundled with kernel sources"
9 HOMEPAGE="https://kernel.org/"
13 KEYWORDS="~amd64 ~ppc ~x86"
14 IUSE="static-libs tcpd usbip"
17 MY_PV="${MY_PV/-pre/-git}"
19 LINUX_V=$(get_version_component_range 1-2)
21 if [ ${PV/_rc} != ${PV} ]; then
22 LINUX_VER=$(get_version_component_range 1-2).$(($(get_version_component_range 3)-1))
23 PATCH_VERSION=$(get_version_component_range 1-3)
24 LINUX_PATCH=patch-${PV//_/-}.xz
25 SRC_URI="https://www.kernel.org/pub/linux/kernel/v3.x/testing/${LINUX_PATCH}
26 https://www.kernel.org/pub/linux/kernel/v3.x/testing/v${PATCH_VERSION}/${LINUX_PATCH}"
27 elif [ $(get_version_component_count) == 4 ]; then
28 # stable-release series
29 LINUX_VER=$(get_version_component_range 1-3)
30 LINUX_PATCH=patch-${PV}.xz
31 SRC_URI="https://www.kernel.org/pub/linux/kernel/v3.x/${LINUX_PATCH}"
36 LINUX_SOURCES=linux-${LINUX_VER}.tar.xz
37 SRC_URI="${SRC_URI} https://www.kernel.org/pub/linux/kernel/v3.x/${LINUX_SOURCES}"
39 # pmtools also provides turbostat
40 # usbip available in seperate package now
41 RDEPEND="sys-apps/hwids
43 >=sys-kernel/linux-headers-$(get_version_component_range 1-2)
46 tcpd? ( sys-apps/tcp-wrappers )
53 S="${WORKDIR}/linux-${LINUX_VER}"
55 # All of these are integrated with the kernel build system,
56 # No make install, and ideally build with with the root Makefile
58 samples/watchdog/watchdog-simple.c
59 tools/accounting/getdelays.c
60 tools/cgroup/cgroup_event_listener.c
61 tools/laptop/freefall/freefall.c
62 tools/testing/selftests/networking/timestamping/timestamping.c
66 #tools/lguest/lguest.c # fails to compile
67 #tools/vm/page-types.c # page-types.c:(.text+0xe2b): undefined reference to `debugfs__mount', not defined anywhere
68 #tools/net/bpf_jit_disasm.c # /usr/include/x86_64-pc-linux-gnu/bfd.h:35:2: error: #error config.h must be included before this header
70 # tools/vm/page-types.c - broken, header path issue
71 # tools/hv/hv_kvp_daemon.c - broken in 3.7 by missing linux/hyperv.h userspace
72 # Documentation/networking/ifenslave.c - obsolete
73 # Documentation/ptp/testptp.c - pending linux-headers-3.0
75 # These have a broken make install, no DESTDIR
77 samples/mei:mei-amt-version
78 tools/firewire:nosy-dump
79 tools/iio:iio_event_monitor
80 tools/iio:iio_generic_buffer
82 tools/laptop/dslm:dslm
83 tools/power/x86/turbostat:turbostat
84 tools/power/x86/x86_energy_perf_policy:x86_energy_perf_policy
85 tools/thermal/tmon:tmon
87 # tools/perf - covered by dev-utils/perf
88 # tools/usb - testcases only
89 # tools/virtio - testcaes only
91 #for _pattern in {Documentation,scripts,tools,usr,include,lib,"arch/*/include",Makefile,Kbuild,Kconfig}; do
93 unpack ${LINUX_SOURCES}
96 for _AFILE in ${A}; do
97 [[ ${_AFILE} == ${LINUX_SOURCES} ]] && continue
98 [[ ${_AFILE} == ${LINUX_PATCH} ]] && continue
99 MY_A="${MY_A} ${_AFILE}"
101 [[ -n ${MY_A} ]] && unpack ${MY_A}
105 if [[ -n ${LINUX_PATCH} ]]; then
106 epatch "${DISTDIR}"/${LINUX_PATCH}
109 pushd tools/usb/usbip/ >/dev/null &&
110 sed -i 's/-Werror[^ ]* //g' configure.ac &&
111 eautoreconf -i -f -v &&
112 popd >/dev/null || die "usbip"
115 -e '/^nosy-dump.*LDFLAGS/d' \
116 -e '/^nosy-dump.*CFLAGS/d' \
117 -e '/^nosy-dump.*CPPFLAGS/s,CPPFLAGS =,CPPFLAGS +=,g' \
118 "${S}"/tools/firewire/Makefile
125 x86|amd64) echo x86 ;;
126 ppc*) echo powerpc ;;
128 alpha|arm|ia64|m68k|mips|sh|sparc*) echo ${1} ;;
129 *) die "TODO: Update the code for your asm-ARCH symlink" ;;
135 pushd tools/usb/usbip/ || die
137 $(use_enable static-libs static) \
138 $(use tcpd || echo --without-tcp-wrappers) \
139 --with-usbids-dir=/usr/share/misc
145 local karch=$(kernel_asm_arch "${ARCH}")
146 # This is the minimal amount needed to start building host binaries.
147 #emake allmodconfig ARCH=${karch}
148 #emake prepare modules_prepare ARCH=${karch}
149 #touch Module.symvers
151 # Now we can start building
152 append-cflags -I./tools/lib
153 for s in ${TARGETS_SIMPLE[@]} ; do
154 dir=$(dirname $s) src=$(basename $s) bin=${src%.c}
155 einfo "Building $s => $bin"
156 emake -f /dev/null M=${dir} ARCH=${karch} ${s%.c}
159 for t in ${TARGET_MAKE_SIMPLE[@]} ; do
160 dir=${t/:*} target_binfile=${t#*:}
161 target=${target_binfile/:*} binfile=${target_binfile/*:}
162 [ -z "${binfile}" ] && binfile=$target
163 einfo "Building $dir => $binfile (via emake $target)"
164 emake -C $dir ARCH=${karch} $target
168 emake -C tools/usb/usbip
174 for s in ${TARGETS_SIMPLE[@]} ; do
175 dir=$(dirname $s) src=$(basename $s) bin=${src%.c}
176 einfo "Installing $s => $bin"
180 for t in ${TARGET_MAKE_SIMPLE[@]} ; do
181 dir=${t/:*} target_binfile=${t#*:}
182 target=${target_binfile/:*} binfile=${target_binfile/*:}
183 [ -z "${binfile}" ] && binfile=$target
184 einfo "Installing $dir => $binfile"
185 dosbin ${dir}/${binfile}
189 pushd tools/usb/usbip/ >/dev/null || die "usbip"
190 emake DESTDIR="${D}" install
191 newdoc README README.usbip
192 newdoc AUTHORS AUTHORS.usbip
194 dodoc Documentation/usb/usbip_protocol.rst
195 find "${D}" -name 'libusbip*.la' -delete || die
198 # At one point upstream it was moved, but be generic to detect if it's
200 if [[ -f "${D}"/usr/sbin/generic_buffer ]] && \
201 [[ ! -f "${D}"/usr/sbin/iio_generic_buffer ]]; then
202 mv -f "${D}"/usr/sbin/{,iio_}generic_buffer || die
205 newconfd "${FILESDIR}"/freefall.confd freefall
206 newinitd "${FILESDIR}"/freefall.initd freefall
211 elog "The cpupower utility is maintained separately at sys-power/cpupower"
212 elog "The lguest utility no longer builds, and has been dropped."
213 elog "The hpfall tool has been renamed by upstream to freefall; update your config if needed"
214 if find "${ROOT}"/etc/runlevels/ -name hpfall ; then
215 ewarn "You must change hpfall to freefall in your runlevels!"
218 elog "For using USB/IP you need to enable USBIP_VHCI_HCD in the client"
219 elog "machine's kernel config and USBIP_HOST on the server."