summaryrefslogtreecommitdiff
path: root/sys-kernel/gnumach/gnumach-1.8_p20260224.ebuild
blob: 30a324eb5eab34eb818fb9503d32ce12adc77f3c (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
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit crossdev flag-o-matic toolchain-funcs

DESCRIPTION="GNU Mach microkernel, for the Hurd"
HOMEPAGE="https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html"

if [[ ${PV} == 9999 ]] ; then
	EGIT_REPO_URI="https://git.savannah.gnu.org/git/hurd/gnumach.git"
	inherit autotools git-r3
elif [[ ${PV} == *_p* ]] ; then
	MY_PV=${PV%_p*}+git${PV#*_p}
	MY_P=${PN}_${MY_PV}

	# savannah doesn't allow snapshot downloads from cgit as of 2026-03,
	# but the Debian maintainer is also upstream, so just use theirs
	# instead.
	SRC_URI="mirror://debian/pool/main/${PN:0:1}/${PN}/${MY_P}.orig.tar.xz"
	S="${WORKDIR}"/${MY_P/_/-}
else
	SRC_URI="mirror://gnu/${PN}/${P}.tar.gz"
fi

LICENSE="GPL-2 BSD-2"
SLOT="0"
IUSE="headers-only"
[[ ${PV} != 9999 ]] && KEYWORDS="~amd64 ~x86"

if is_crosspkg ; then
	DEPEND="
		!headers-only? ( cross-${CTARGET}/mig )
	"
else
	DEPEND="
		dev-util/mig
	"
fi

src_prepare() {
	default
	[[ ${PV} == 9999 ]] && eautoreconf
}

src_configure() {
	if target_is_not_host ; then
		local sysroot=/usr/${CTARGET}

		if use headers-only ; then
			# Assume we don't have working cross-compiler
			export CC=$(tc-getBUILD_CC)
		else
			export MIG="${CTARGET}-mig"
		fi
	fi

	strip-flags
	# LTO confuses one of the assemble steps
	filter-lto
	# -g3 confuses MIG which relies on preprocessed input
	replace-flags -ggdb[3-9] -ggdb2
	replace-flags -g3 -g
	# LD gets invoked directly. raw-ldflags would work here except
	# that it breaks configure which uses the compiler driver
	unset LDFLAGS

	local myeconfargs=(
		# MIG machinery relies on this!
		--enable-dependency-tracking
		--prefix="${EPREFIX}${sysroot}/usr"
		--datadir="${EPREFIX}${sysroot}/usr/share"
		--host=${CTARGET}

		# Needed for QEMU with `-net nic,model=ne2k_pc` at least
		--enable-net-group
	)

	econf "${myeconfargs[@]}"
}

src_compile() {
	use headers-only && return
	default
}

src_test() {
	use headers-only && return
	default
}

src_install() {
	emake DESTDIR="${D}" $(usex headers-only install-data install)

	if target_is_not_host ; then
		# On Hurd, gcc expects system headers to be in /include, not /usr/include
		# TODO: Is this needed?
		dosym usr/include /usr/${CTARGET}/include

		# Avoid collisions for other Hurd targets
		# TODO: autoconf var?
		rm -rfv "${ED}"/usr/share/info || die
		rmdir "${ED}"/usr/share || die
	fi
}