blob: 0e7a8dfb20f840c9ae233292e1968954a8331d1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
inherit bsdmk freebsd flag-o-matic toolchain-funcs
DESCRIPTION="FreeBSD kernel sources"
SLOT="0"
IUSE="+build-kernel debug dtrace profile zfs"
if [[ ${PV} != *9999* ]]; then
KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
SRC_URI="mirror://gentoo/${SYS}.tar.xz
mirror://gentoo/${UBIN}.tar.xz"
fi
RDEPEND="dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
=sys-freebsd/freebsd-mk-defs-${RV}*
!sys-freebsd/virtio-kmod
!sys-fs/fuse4bsd
!<sys-freebsd/freebsd-sources-9.2_beta1"
DEPEND="build-kernel? (
dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
!sparc-fbsd? ( sys-devel/clang )
>=sys-freebsd/freebsd-usbin-9.1
=sys-freebsd/freebsd-mk-defs-${RV}*
)"
RESTRICT="strip binchecks"
S="${WORKDIR}/sys"
KERN_BUILD=GENTOO
PATCHES=( "${FILESDIR}/${PN}-9.0-disable-optimization.patch"
"${FILESDIR}/${PN}-10.0-gentoo.patch"
"${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
"${FILESDIR}/${PN}-7.1-types.h-fix.patch"
"${FILESDIR}/${PN}-8.0-subnet-route-pr40133.patch"
"${FILESDIR}/${PN}-7.1-includes.patch"
"${FILESDIR}/${PN}-9.0-sysctluint.patch"
"${FILESDIR}/${PN}-9.2-gentoo-gcc.patch" )
pkg_setup() {
# Force set CC=clang. when using gcc, aesni fails to build.
use sparc-fbsd || export CC=clang
use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL="
}
src_prepare() {
local conf="${S}/$(tc-arch-kernel)/conf/${KERN_BUILD}"
# This replaces the gentoover patch, it doesn't need reapply every time.
sed -i -e 's:^REVISION=.*:REVISION="'${PVR}'":' \
-e 's:^BRANCH=.*:BRANCH="Gentoo":' \
-e 's:^VERSION=.*:VERSION="${TYPE} ${BRANCH} ${REVISION}":' \
"${S}/conf/newvers.sh"
# __FreeBSD_cc_version comes from FreeBSD's gcc.
# on 10.0-RELEASE it's 1000001.
# FYI, can get it from gnu/usr.bin/cc/cc_tools/freebsd-native.h.
sed -e "s:-D_KERNEL:-D_KERNEL -D__FreeBSD_cc_version=1000001:g" \
-i "${S}/conf/kern.pre.mk" \
-i "${S}/conf/kmod.mk" || die "Couldn't set __FreeBSD_cc_version"
# Remove -Werror
sed -e "s:-Werror:-Wno-error:g" \
-i "${S}/conf/kern.pre.mk" \
-i "${S}/conf/kmod.mk" || die
# Set the kernel configuration using USE flags.
cp -f "${FILESDIR}/config-GENTOO" "${conf}" || die
use debug || echo 'nomakeoptions DEBUG' >> "${conf}"
use dtrace || echo 'nomakeoptions WITH_CTF' >> "${conf}"
# 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
if has_version "<sys-freebsd/freebsd-ubin-10.0"; then
cd "${WORKDIR}"/usr.bin/bmake || die
if [[ -e /usr/lib/libgcc.a ]] ; then
freebsd_src_compile
else
local CC_SAVE="${CC}"
CC=gcc freebsd_src_compile
export CC="${CC_SAVE}"
fi
export BMAKE="${WORKDIR}/usr.bin/bmake/make"
fi
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}/"*
}
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
}
|