# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=sleuthkit
pkgver=4.4.2
pkgrel=0
pkgdesc="File system and media management forensic analysis tools"
arch="all"
license="custom"
depends="perl"
url="http://www.sleuthkit.org/sleuthkit"
depends_dev="libewf-dev sqlite-dev"
makedepends="$depends_dev autoconf automake libtool"
install=""
options="libtool"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/sleuthkit/sleuthkit/releases/download/$pkgname-$pkgver/$pkgname-$pkgver.tar.gz
	30_fix-manpages.patch
	40_no_static_ldflags.patch
	50_disable_ant_clean.patch"

builddir="$srcdir"/$pkgname-$pkgver

prepare() {
	cd "$builddir"
	sed -i 's/daddr_t/uint32_t/g' tools/srchtools/sigfind.cpp
	autoreconf -fi
	default_prepare
}

build() {
	cd "$builddir"
	# https://github.com/sleuthkit/sleuthkit/issues/642
	export CFLAGS="$CFLAGS -DHAVE_LIBEWF_V2_API -Dlibewf_handle_read_random=libewf_handle_read_buffer_at_offset"
	./configure --prefix=/usr
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
	install -d "$pkgdir"/usr/share/licenses/$pkgname
	install -Dm0644 licenses/* "$pkgdir"/usr/share/licenses/$pkgname

}

sha512sums="970704c0e650b54df49d92f7a5c82d1c8cd37f589bf1a90ba5df6b3cd26a4e3676fbbbf58a176eeb002cdefbd33fb1fc057b11256b4a3cf1b8f782beb618a1de  sleuthkit-4.4.2.tar.gz
4b68367bff62c731c09ab9a95f810b11562f0942021825226ca8d5e846e54c64004f77ac587ea0377bcb5c50c9dcb33dba1caa8cffd717076cc13c9931dd2c9c  30_fix-manpages.patch
e0421b2fc4bb1d04d3bdb13805d060b386f700586d9e33728185eaff26eef14d5fdbf89979fb5d898dfeee7467f891b5d3c33441f9cb35af5f93d3d576e7cc26  40_no_static_ldflags.patch
cb0d17840f1b4570da1ee0d092f8716a7e073463658d4a7b1cddb74058c5eccf316fcbd2e7c5fba3af0f0adaaabe4e395bd5a41aa1438be615edacb8c6efd89d  50_disable_ant_clean.patch"
