# Template file for 'amdvlk'
pkgname=amdvlk
version=2024.Q2.3
revision=1
_xgl_commit=5dd432ade87244461b8cf357b5cb641e7ee7ff15
_pal_commit=695337aa8131913d883ff15787cd75f6fcb11229
_llpc_commit=f64d106c023e7bed59bfb441ffb258c127e500c1
_gpurt_commit=6ca06bbba1c0e4bbb82f10e93423e607b2227985
_llvm_project_commit=72a6d2843ca05fa8d18a789664a642b4d0c9e069
_MetroHash_commit=18893fb28601bb9af1154cd1a671a121fff6d8d3
_CWPack_commit=4f8cf0584442a91d829d269158567d7ed926f026
_llvm_dialects_commit=ed4b46e8425066a96a5e79afc29bce3d82eecf71
archs="i686* x86_64*"
create_wrksrc=yes
build_wrksrc="xgl"
build_style=cmake
configure_args="-DBUILD_WAYLAND_SUPPORT=ON
 -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="3dd43ce83bf3e9aa32f2d6d02817c8547092b46fc135e4c4e783750d77939c6e
a7d101ca216cf3df1ba0eb428d9f490cf2fded068bbf9cdd15d02bead9dab8e4
dabb381102aae721c48e8ec24e83504258f0009fa72bc4efaf0254a99ff9c531
771d9b2006393ecbcae90edf6e197cc63056a4c935bafb87f4522a4b9ebe5c66
b2cd8b047e15e90f13be9474dd024dca518979801dc8e77265ae49b25b954f77
ba92d72d0a1298a683a8bb4e540bdea653f84559f735bb9ade9968e021f8b462
141e6c156a834b8e0f90ba108664d7f35193df11acddefa117f394dbf2b7371a
87ed9209c129f47d0b64c914fb99d6c69e59a257445ec3a394c3e00d5e2b4484
a6d4a7aabfa887ee332c5136a1fc6d123ff9b5daf6d864a973978362cf011183"
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
}
