# Template file for 'unar'
pkgname=unar
version=1.10.8
revision=1
_ud_ver=1.1
build_wrksrc="XADMaster"
build_style=gnu-makefile
make_use_env="yes"
make_cmd="make -f Makefile.linux"
hostmakedepends="gcc-objc"
makedepends="gnustep-base-devel bzip2-devel wavpack-devel"
short_desc="Unarchiver for a variety of file formats"
maintainer="Orphaned <orphan@voidlinux.org>"
license="LGPL-2.1-or-later"
homepage="https://theunarchiver.com/command-line"
changelog="https://github.com/MacPaw/XADMaster/releases"
distfiles="https://github.com/MacPaw/XADMaster/archive/refs/tags/v${version}.tar.gz
 https://github.com/MacPaw/universal-detector/archive/refs/tags/${_ud_ver}.tar.gz>universal-detector-${_ud_ver}.tar.gz"
checksum="652953d7988b3c33f4f52b61c357afd1a7c2fc170e5e6e2219f4432b0c4cd39f
 8e8532111d0163628eb828a60d67b53133afad3f710b1967e69d3b8eee28a811"
make_check=no # Doesn't have any tests.
nocross="objc doesn't get cross build at present within gcc (as seen in gnustep)"

post_extract() {
	mv XADMaster-${version} XADMaster
	mv universal-detector-${_ud_ver} UniversalDetector
	vsed -i XADMaster/Makefile.linux UniversalDetector/Makefile.linux \
		-e '/-D_NATIVE_OBJC_EXCEPTIONS/d'

	# tag version v1.10.8 still identifies as v1.10.7
	vsed -i XADMaster/unar.m XADMaster/lsar.m \
		-e "s/v1\\.10\\.7/v${version}/"

	if [ "$XBPS_TARGET_LIBC" = musl ]; then
		# This a copy of glibc's regex, also LGPL-2.1-or-later
		cp XADMaster/Windows/include/regex.h XADMaster/xad_regex.h
		cp XADMaster/Windows/regex.c XADMaster
	fi
}

do_install() {
	for x in unar lsar; do
		vbin "${x}"
		vman "Extra/${x}.1"
		vinstall "Extra/${x}.bash_completion" 644 usr/share/bash-completion/completions "${x}"
	done
}
