# Template file for 'EternalTerminal'
pkgname=EternalTerminal
version=6.2.11
revision=1
# revisions used for the specific versions of submodules.
# they can be found in the external/ directory of the source code.
_sanitizers_gitrev="99e159ec9bc8dd362b08d18436bd40ff0648417b"
_threadpool_gitrev="9a42ec1329f259a5f4881a291db1dcb8f2ad9040"
build_wrksrc=${pkgname}
build_style=cmake
configure_args="-DDISABLE_VCPKG=ON -DDISABLE_TELEMETRY=ON -DDISABLE_SENTRY=ON"
hostmakedepends="protobuf pkg-config"
makedepends="gflags-devel libsodium-devel protobuf-devel openssl-devel
 zlib-devel libunwind-devel libutempter-devel libselinux-devel libsepol-devel pcre-devel"
short_desc="Re-Connectable secure remote shell"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://eternalterminal.dev/"
distfiles="https://github.com/MisterTea/EternalTerminal/archive/et-v${version}.tar.gz
 https://github.com/arsenm/sanitizers-cmake/archive/${_sanitizers_gitrev}.tar.gz
 https://github.com/progschj/ThreadPool/archive/${_threadpool_gitrev}.tar.gz"
checksum="e8e80800babc026be610d50d402a8ecbdfbd39e130d1cfeb51fb102c1ad63b0f
 f9cf386638f455c5d2e7a835b95941201387d2531b8682942d59827663b58341
 954e0ecdac1aa0da1e0fa78577ff0d352e53094df43762fbc1884f76a7e1dcd2"
system_accounts="_eternal"

LDFLAGS="-lgflags"

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	makedepends+=" libexecinfo-devel"
fi

post_extract() {
	mv EternalTerminal-et-v${version} ${build_wrksrc}
	mv sanitizers-cmake-${_sanitizers_gitrev}/* \
		${build_wrksrc}/external/sanitizers-cmake
	mv ThreadPool-${_threadpool_gitrev}/* ${build_wrksrc}/external/ThreadPool
}

post_patch() {
	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
		# Use external libexecinfo
		vsed -i CMakeLists.txt \
			-e '/execinfo/!s/CORE_LIBRARIES$/& execinfo/'
	fi
}

post_install() {
	vsv etserver
}
