# Contributor: George Hopkins <george-hopkins@null.net>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=imhex
pkgver=1.35.4
pkgrel=0
pkgdesc="Hex editor for reverse engineers and programmers"
url="https://github.com/WerWolv/ImHex"
# armhf, armv7, x86: 32-bit not supported
arch="all !armhf !armv7 !x86"
license="GPL-2.0-or-later"
options="!check" # No testsuite
makedepends="
	capstone-dev
	cmake
	curl-dev
	file-dev
	fmt-dev
	freetype-dev
	glfw-dev
	glm-dev
	gtk+3.0-dev
	libarchive-dev
	llvm-dev
	llvm-gtest
	llvm-static
	mbedtls-dev
	nlohmann-json
	openssl-dev
	python3-dev
	samurai
	yara-dev
	"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/WerWolv/ImHex/releases/download/v$pkgver/Full.Sources.tar.gz
	$pkgname-patterns-$pkgver.tar.gz::https://github.com/WerWolv/ImHex-Patterns/archive/refs/tags/ImHex-v$pkgver.tar.gz
	fix-lfs64.patch
	no-werror.patch
	"
builddir="$srcdir/ImHex"

prepare() {
	default_prepare

	mv -v "$srcdir"/ImHex-Patterns-ImHex-v$pkgver/ \
		ImHex-Patterns
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_SYSTEM_CAPSTONE=ON \
		-DUSE_SYSTEM_NLOHMANN_JSON=ON \
		-DUSE_SYSTEM_FMT=ON \
		-DUSE_SYSTEM_LLVM=ON \
		-DUSE_SYSTEM_YARA=ON \
		-DIMHEX_DISABLE_STACKTRACE=ON \
		-DIMHEX_IGNORE_BAD_CLONE=ON \
		-DIMHEX_OFFLINE_BUILD=ON \
		-DIMHEX_STRIP_RELEASE=OFF \
		-DIMHEX_USE_GTK_FILE_PICKER=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	cd "$pkgdir"
	rm -rf usr/share/imhex/sdk
	rm usr/bin/imhex-updater
}

sha512sums="
a18215a76d949cd4bb7395c57965d1ca04fccad37142d130c17d3edbf8c383875a4f7e11ee3244aa4f08a5a512f19bd5e3e8ab3cdfb59603e7df142876c43318  imhex-1.35.4.tar.gz
1af5818468eb0cf8d8078cd57d0659d93cf6d59380b3fc7e4cb07442ebc4f90e33e401516d1adafef65a696b458e1738984f92a5a5052a945a84422eda5a6bea  imhex-patterns-1.35.4.tar.gz
e705ce53d0af206ae87b51f0978b2ce7529ceefa31049dc84ca6803e8f25101e6bde88b66fb2ae3fec16239f97bc2b3bc98ebbf6c2bfaa57eed89667af087adb  fix-lfs64.patch
7882b0cc1fe1c620de0757f1a2b5893b7ff395479aa870719e0662dc11625c2929e786412d9031df9653257e76edd0292a3d50492f072b2ab275e46e75c3e441  no-werror.patch
"
