| # |
| # Copyright 2022 Google LLC |
| # |
| # This program is free software; you can redistribute it and/or |
| # modify it under the terms of the GNU General Public License |
| # version 2 as published by the Free Software Foundation. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| |
| EAPI=7 |
| |
| inherit eutils cos-linux-mod udev |
| |
| DESCRIPTION="Snaggletooth kernel drivers" |
| HOMEPAGE="https://cloud.google.com/tpu" |
| COS_PKG_COMMIT="cb119a8607ee9bb70542867579dc9b6e69a85c5a" |
| SRC_URI="https://github.com/tensorflow/tpu/archive/${COS_PKG_COMMIT}.tar.gz -> ${P}.tar.gz" |
| |
| LICENSE="BSD-Google" |
| SLOT="0" |
| KEYWORDS="*" |
| IUSE+=" kernel-6_1 kernel-6_6" |
| |
| S="${WORKDIR}/tpu-${COS_PKG_COMMIT}/tools/driver/" |
| |
| MODULE_NAMES=" |
| accel-class(kernel/drivers/accel:${S}) |
| asic_sw(kernel/drivers/asic_sw:${S}) |
| gasket(kernel/drivers/gasket:${S}) |
| tpu_common(kernel/drivers/tpu_common:${S}) |
| tpu_v2_core(kernel/drivers/tpu_common:${S}) |
| tpu_v2(kernel/drivers/tpu_common:${S}) |
| tpu_v3(kernel/drivers/tpu_common:${S}) |
| tpuv4common_common(kernel/drivers/tpu_common:${S}) |
| tpu_v4(kernel/drivers/tpu_common:${S}) |
| tpu_v4_lite(kernel/drivers/tpu_common:${S})" |
| |
| src_prepare() { |
| if use kernel-6_1; then |
| PATCHES+=( "${FILESDIR}"/${PN}-6.1-build-compatible.patch ) |
| fi |
| if use kernel-6_6; then |
| PATCHES+=( "${FILESDIR}"/${PN}-6.6-build-compatible.patch ) |
| fi |
| default |
| } |
| |
| src_compile() { |
| cros_allow_gnu_build_tools |
| LIBELF="$("${CBUILD}-pkg-config" libelf --libs 2>/dev/null || echo -lelf)" |
| BUILD_PARAMS="HOST_LIBELF_LIBS=${LIBELF} KERNELDIR=${KBUILD_OUTPUT}" |
| BUILD_PARAMS+=" -f Makefile.tpu_kernel_modules" |
| BUILD_TARGETS="all" |
| cos-linux-mod_src_compile |
| } |
| |
| src_install() { |
| cos-linux-mod_src_install |
| udev_dorules "${FILESDIR}/99-tpu.rules" |
| } |