# Description: An open source SVG editor.
# URL: https://www.inkscape.org/
# Maintainer: John McQuah, jmcquah at disroot dot org
# Depends on: boehm-gc boost double-conversion graphicsmagick gsl gtkmm3 libsoup libxslt poppler-glib popt potrace gdl

name=inkscape
version=1.2.2
release=3
source=(https://inkscape.org/gallery/item/37360/inkscape-$version.tar.xz)

build() {
	# https://gitlab.gnome.org/GNOME/glib/-/issues/2331
	CFLAGS+=' -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_46 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_66 -L/usr/lib/inkscape'
	CXXFLAGS+=' -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_46 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_66 -L/usr/lib/inkscape'
	export LDFLAGS+=" -Wl,-rpath=/usr/lib/inkscape"

	cmake -S inkscape-${version}* -B build -G Ninja \
		-D CMAKE_INSTALL_PREFIX=/usr \
		-D CMAKE_INSTALL_LIBDIR=lib \
		-D CMAKE_BUILD_TYPE=Release \
		-D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
		-D CMAKE_C_FLAGS_RELEASE="$CFLAGS" \
		-D WITH_INTERNAL_2GEOM=ON \
		-Wno-dev

	cmake --build build
	DESTDIR=$PKG cmake --install build

	rm -r 	$PKG/usr/share/man/?? \
		$PKG/usr/share/locale \
		$PKG/usr/share/inkscape/doc

	find $PKG/usr/share/inkscape \( -name 'README' -o -name 'README.*' \) -delete

	/usr/bin/python3 -mcompileall $PKG
	/usr/bin/python3 -O -m compileall $PKG
	/usr/bin/python3 -OO -m compileall $PKG

	rm -rf	$PKG/usr/share/man/zh_TW \
		$PKG/usr/share/man/pt_BR
}
