# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 EAPI=5 inherit bsdmk freebsd flag-o-matic toolchain-funcs DESCRIPTION="FreeBSD kernel sources" SLOT="0" LICENSE="BSD dtrace? ( CDDL ) zfs? ( CDDL )" IUSE="+build-kernel debug dtrace zfs" # Security Advisory and Errata patches. UPSTREAM_PATCHES=( "SA-17:08/ptrace.patch" "SA-17:10/kldstat.patch" "EN-17:07/vnet.patch" "EN-17:08/pf.patch" ) if [[ ${PV} != *9999* ]]; then KEYWORDS="~amd64-fbsd ~x86-fbsd" SRC_URI="${SRC_URI} $(freebsd_upstream_patches)" fi EXTRACTONLY="sys/" RDEPEND="dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 ) =sys-freebsd/freebsd-mk-defs-${RV}* !sys-freebsd/virtio-kmod !sys-fs/fuse4bsd !> "${conf}" use dtrace || echo 'nomakeoptions WITH_CTF' >> "${conf}" # hyperv fails to compile on x86-fbsd. if use x86-fbsd && [[ $(tc-getCC) == *gcc* ]] ; then echo 'nodevice hyperv' >> "${conf}" dummy_mk modules/hyperv fi # Only used with USE=build-kernel, let the kernel build with its own flags, its safer. unset LDFLAGS CFLAGS CXXFLAGS ASFLAGS KERNEL } src_configure() { if use build-kernel ; then tc-export CC cd "${S}/$(tc-arch-kernel)/conf" || die config ${KERN_BUILD} || die fi } src_compile() { if use build-kernel ; then cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die freebsd_src_compile depend freebsd_src_compile else einfo "Nothing to compile.." fi } src_install() { if use build-kernel ; then cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die freebsd_src_install rm -rf "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" cd "${S}" fi insinto "/usr/src/sys" doins -r "${S}/". if use dtrace ; then insinto "/usr/src/cddl" doins -r "${WORKDIR}/cddl/". fi } pkg_preinst() { if [[ -L "${ROOT}/usr/src/sys" ]]; then einfo "/usr/src/sys is a symlink, removing it..." rm -f "${ROOT}/usr/src/sys" fi # if use sparc-fbsd ; then # ewarn "WARNING: kldload currently causes kernel panics" # ewarn "on sparc64. This is probably a gcc-4.1 issue, but" # ewarn "we need gcc-4.1 to compile the kernel correctly :/" # ewarn "Please compile all modules you need into the kernel" # fi ewarn "If you want to manually compile (not recommended), please don't forget the following steps." # if ! use sparc-fbsd ; then # ewarn "export CC=clang" # ewarn "export CXX=clang++" # fi if ! use zfs ; then ewarn "export WITHOUT_CDDL=" ewarn "Note, Please set USE=zfs if you want to enable modules under the CDDL." fi if ! use dtrace && ! has_version '>=sys-freebsd/freebsd-cddl-9.2_beta1' ; then ewarn "The GENERIC config requires sys-freebsd/freebsd-cddl. Please emerge it." fi }