# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
inherit go-module

DESCRIPTION="A UPnP DLNA Digital Media Server that includes basic video transcoding. Tested on a Panasonic Viera television, several Android UPnP apps, and Chromecast."
HOMEPAGE="https://github.com/anacrolix/dms"
SRC_URI="https://github.com/anacrolix/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" https://codeberg.org/Perfect_Gentleman/Sources/raw/branch/main/${P}-deps.tar.xz"
LICENSE="Apache-2.0"
LICENSE+=" BSD BSD-2 ISC MIT"
SLOT="0"

KEYWORDS="~amd64"
IUSE=""

BDEPEND=">=dev-lang/go-1.25.0"

src_unpack() {
	default
	mv ${S}/go-mod ${WORKDIR}
}

src_compile() {
	export CGO_CFLAGS="${CFLAGS}"
	export CGO_CXXFLAGS="${CXXFLAGS}"
	export CGO_LDFLAGS="${LDFLAGS}"
	ego build -gcflags "all=-trimpath=${S}" -asmflags "all=-trimpath=${S}" -ldflags "-extldflags \"${LDFLAGS}\""
}

src_install() {
	dobin dms
	default
}