# Template file for 'amdvlk'
pkgname=amdvlk
version=2025.Q1.3
revision=1
_xgl_commit=ba24064a9c93e76d0cafb0196996e779fbe70bf4
_pal_commit=04bc1e796dd15fc90fff8fa826d32e431d8722f6
_llpc_commit=188bbf6a5b9403813e51d39f6fc8429550dbf267
_gpurt_commit=f734985ebc31f471c376ed0cb217f43bdd40ee17
_llvm_project_commit=cf4271cbb7c60a6517c45e9fc9fa09a9f420f512
_MetroHash_commit=18893fb28601bb9af1154cd1a671a121fff6d8d3
_CWPack_commit=4f8cf0584442a91d829d269158567d7ed926f026
_llvm_dialects_commit=50260f8bdd9ce47b388f5009546a438aba8b9d16
archs="i686* x86_64*"
create_wrksrc=yes
build_wrksrc="xgl"
build_style=cmake
configure_args="-DCMAKE_BUILD_TYPE=Release
 -DLLVM_PARALLEL_LINK_JOBS=2"
hostmakedepends="pkg-config python3 perl"
makedepends="libxml2-devel xorg-server-devel libXrandr-devel libffi-devel wayland-devel
 DirectXShaderCompiler-devel glslang-devel python3-Jinja2 python3-ruamel.yaml"
depends="vulkan-loader"
short_desc="AMD Open Source Driver For Vulkan"
maintainer="John <me@johnnynator.dev>"
license="MIT"
homepage="https://github.com/GPUOpen-Drivers/AMDVLK"
distfiles="https://github.com/GPUOpen-Drivers/AMDVLK/archive/v-${version}.tar.gz
 https://github.com/GPUOpen-Drivers/llpc/archive/${_llpc_commit}.tar.gz
 https://github.com/GPUOpen-Drivers/gpurt/archive/${_gpurt_commit}.tar.gz
 https://github.com/GPUOpen-Drivers/xgl/archive/${_xgl_commit}.tar.gz
 https://github.com/GPUOpen-Drivers/pal/archive/${_pal_commit}.tar.gz
 https://github.com/GPUOpen-Drivers/llvm-project/archive/${_llvm_project_commit}.tar.gz
 https://github.com/GPUOpen-Drivers/MetroHash/archive/${_MetroHash_commit}.tar.gz
 https://github.com/GPUOpen-Drivers/CWPack/archive/${_CWPack_commit}.tar.gz
 https://github.com/GPUOpen-Drivers/llvm-dialects/archive/${_llvm_dialects_commit}.tar.gz"
checksum="368f8202610324434a098f743b7307b02221b2a5dbc06094da5777c96708faad
 fe6b49f55730426b013e2d34a25ebf80d053e61a6269f8de0ec9212c2a01c2cf
 1cb298691c142833f2b7b144ca51cef874ae3a0b59a3965df14e023bfa80ec93
 b117f8b53c058c49765d4bbb94f19c386f51d67ef72d68ed54b62f46788d7c1b
 d48cbb9193314ecb42e8b59ead4693f403b39bd5277de81a29e15c92e036d6f3
 1251139b8ff45a3919c5cb3a0b7e963e674a7511f883665e97c95df375735fa7
 141e6c156a834b8e0f90ba108664d7f35193df11acddefa117f394dbf2b7371a
 87ed9209c129f47d0b64c914fb99d6c69e59a257445ec3a394c3e00d5e2b4484
 48ea45e6a06657d674fced1304eab541861b6628d5892f4792ded9f3aaa5b253"
nocross=yes
lib32files="/usr/share/vulkan/icd.d/amd_icd32.json"

case "$XBPS_TARGET_MACHINE" in
	i686*) nodebug=yes;;
esac

post_extract() {
	mv ${wrksrc}/AMDVLK-v-${version} ${wrksrc}/AMDVLK
	mv ${wrksrc}/xgl-${_xgl_commit} ${wrksrc}/xgl
	mv ${wrksrc}/pal-${_pal_commit} ${wrksrc}/pal
	mv ${wrksrc}/llpc-${_llpc_commit} ${wrksrc}/llpc
	mv ${wrksrc}/gpurt-${_gpurt_commit} ${wrksrc}/gpurt
	mv ${wrksrc}/llvm-project-${_llvm_project_commit} ${wrksrc}/llvm-project
	mkdir ${wrksrc}/third_party
	mv ${wrksrc}/MetroHash-${_MetroHash_commit} ${wrksrc}/third_party/metrohash
	mv ${wrksrc}/CWPack-${_CWPack_commit} ${wrksrc}/third_party/cwpack
	rmdir ${wrksrc}/llpc/imported/llvm-dialects/
	mv ${wrksrc}/llvm-dialects-${_llvm_dialects_commit}/ ${wrksrc}/llpc/imported/llvm-dialects/
}

pre_configure() {
	case "$XBPS_TARGET_MACHINE" in
		i686*) _arch="X86";;
		x86_64*) _arch="X86";;
	esac
	configure_args+=" -DLLVM_TARGET_ARCH=${_arch}"
	configure_args+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}"
}

do_install() {
	vinstall build/icd/amdvlk${XBPS_TARGET_WORDSIZE}.so 644 usr/lib/
	vinstall build/icd/amd_icd${XBPS_TARGET_WORDSIZE}.json \
		644 usr/share/vulkan/icd.d/
	vlicense ${wrksrc}/AMDVLK/LICENSE.txt
}
