bbswitch-9999.ebuild 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # Copyright 1999-2023 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. inherit linux-mod
  5. if [[ ${PV} == 9999 ]]; then
  6. inherit git-r3
  7. EGIT_REPO_URI="https://github.com/Bumblebee-Project/${PN}.git"
  8. EGIT_BRANCH="develop"
  9. else
  10. PATCHES=( "${FILESDIR}/${PN}-0.8-kernel-4.12.patch" )
  11. SRC_URI="https://github.com/Bumblebee-Project/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
  12. KEYWORDS="~amd64 ~x86"
  13. fi
  14. DESCRIPTION="Toggle discrete NVIDIA Optimus graphics card"
  15. HOMEPAGE="https://github.com/Bumblebee-Project/bbswitch"
  16. SLOT="0"
  17. LICENSE="GPL-3+"
  18. IUSE=""
  19. DEPEND="
  20. virtual/linux-sources
  21. sys-kernel/linux-headers
  22. "
  23. RDEPEND=""
  24. MODULE_NAMES="bbswitch(acpi)"
  25. pkg_setup() {
  26. if ! linux_config_exists; then
  27. ewarn "Cannot check the linux kernel configuration."
  28. fi
  29. BUILD_TARGETS="default"
  30. BUILD_PARAMS="KVERSION=${KV_FULL}"
  31. if linux_chkconfig_present CC_IS_CLANG; then
  32. BUILD_PARAMS+=" CC=${CHOST}-clang"
  33. if linux_chkconfig_present LD_IS_LLD; then
  34. BUILD_PARAMS+=' LD=ld.lld'
  35. if linux_chkconfig_present LTO_CLANG_THIN; then
  36. # kernel enables cache by default leading to sandbox violations
  37. BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
  38. fi
  39. fi
  40. fi
  41. linux-mod_pkg_setup
  42. }
  43. src_prepare() {
  44. # Fix build failure, bug #513542
  45. sed -i 's/^KDIR.*$/KDIR\ \:= \/usr\/src\/linux/g' Makefile || die
  46. default
  47. }
  48. src_install() {
  49. insinto /etc/modprobe.d
  50. newins "${FILESDIR}"/bbswitch.modprobe bbswitch.conf
  51. dodoc NEWS README.md
  52. linux-mod_src_install
  53. }