# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit git-r3 savedconfig toolchain-funcs

DESCRIPTION="A suckless-adjacent fetch program written in C"
HOMEPAGE="https://gitbtw.com/fordon_greeman/sfetch"
EGIT_REPO_URI="https://gitbtw.com/fordon_greeman/sfetch.git"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS=""

src_prepare() {
	default
	restore_config src/main.c
}

src_compile() {
	$(tc-getCC) ${CFLAGS} ${LDFLAGS} sfetch.c -o sfetch \
		|| die "Failed to compile sfetch"
}

src_install() {
	dobin sfetch
	save_config sfetch.c
}

pkg_postinst() {
	if use savedconfig; then
		elog "Edit sfetch through /etc/portage/savedconfig/app-misc/sfetch-${PV}"
		elog "Requires re-emerging after change!"
	fi
}