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

EAPI=8

inherit autotools 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 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/_/-}

	# Debian only make full snapshots every so often, but apply other
	# commits as backports. This is a bit awkward for us to follow, so
	# roll our own snapshots:
	# $ git archive --format=tar --prefix=gnumach/ HEAD | xz > gnumach-1.8_p20260330.tar.xz
	SRC_URI="https://distfiles.gentoo.org/pub/proj/hurd/snapshots/gnumach/${P}.tar.xz"
	S="${WORKDIR}"/${PN}
else
	SRC_URI="mirror://gnu/${PN}/${P}.tar.gz"
fi

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

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

BDEPEND="sys-apps/texinfo"

src_prepare() {
	default
	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

	# Make sure host make.conf doesn't pollute us
	if target_is_not_host || tc-is-cross-compiler ; then
		CHOST=${CTARGET} strip-unsupported-flags
	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

		$(use_enable debug kdb)
	)

	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
}