# Template file for 'unrar'
pkgname=unrar
version=7.1.1
revision=1
archs="x86_64* i686*"
short_desc="Unarchiver for .rar files (non-free version)"
maintainer="skmpz <dem.procopiou@gmail.com>"
license="custom:freeware"
homepage="https://www.rarlab.com/rar_add.htm"
distfiles="https://www.rarlab.com/rar/unrarsrc-${version}.tar.gz"
checksum=2e9cbc9d1c250b40f4a7a6a363b6ccfa3703e190534979d18c8c4ac5ae35dafc
repository=nonfree

do_build() {
	vsed -e 's/-march=native//' \
		 -e 's/^\(CXXFLAGS\)=\(.*\)/\1+=\2/' \
		 -e 's/^\(LDFLAGS\)=\(.*\)/\1+=-lpthread \2/' \
		 -i makefile
	make CXX="$CXX" LD="$LD" STRIP=: -f makefile
	# early install of unrar because makefile deletes unrar on lib creation
	vbin unrar
	# recompile for lib
	make clean
	make CXX="$CXX" LD="$LD" STRIP=: -f makefile lib
}

do_install() {
	vlicense license.txt LICENSE
}

libunrar_package() {
	short_desc+=" - shared library"

	pkg_install() {
		vinstall libunrar.so 0755 /usr/lib/
	}
}

libunrar-devel_package() {
	short_desc+=" - development files"

	pkg_install() {
		vinstall dll.hpp 644 /usr/include/unrar/
	}
}
