# Description: OpenGL and OpenGL ES shader front end and validator
# URL: https://www.khronos.org/opengles/sdk/tools/Reference-Compiler
# Maintainer: CRUX System Team, core-ports at crux dot nu
# Depends on: spirv-tools

name=glslang
version=14.1.0
release=1
source=(https://github.com/KhronosGroup/glslang/archive/$version/$name-sdk-$version.tar.gz)

build() {
	local config="
		-G Ninja
		-S $name-$version
		-D CMAKE_INSTALL_PREFIX=/usr
		-D CMAKE_INSTALL_LIBDIR=lib
		-D CMAKE_BUILD_TYPE=Release
		-D CMAKE_SKIP_RPATH=yes
		-D ENABLE_PCH=OFF
		-D BUILD_EXTERNAL=OFF
		-D ENABLE_PCH=OFF
		-D ALLOW_EXTERNAL_SPIRV_TOOLS=ON
		-Wno-dev"

	cmake -B build-static $config $PKGMK_GLSLANG \
		-D BUILD_SHARED_LIBS=OFF \
		-D CMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS} -ffat-lto-objects"
	cmake --build build-static

	cmake -B build-shared $config $PKGMK_GLSLANG \
		-D BUILD_SHARED_LIBS=ON \
		-D CMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS} -ffat-lto-objects" \
		-D CMAKE_SHARED_LINKER_FLAGS='-Wl,--no-undefined'
	cmake --build build-shared

	DESTDIR=$PKG cmake --build build-static --target install
	DESTDIR=$PKG cmake --build build-shared --target install
}
