#Packager: Dimitris Tzemos <dijemos~at~gmail~dot~com>

pkgname=inkscape
pkgver=1.2.2
pkgrel=1dj
source=("https://inkscape.org/gallery/item/37360/inkscape-1.2.2.tar.xz")
docs=("AUTHORS" "COPYING*" "INSTALL" "NEWS" "README*" "TRANSLATORS" "doc/*")
url=http://www.inkscape.org/

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"inkscape (an Open Source vector graphics editor)"
"Inkscape is an Open Source vector graphics editor, with capabilities"
"similar to Illustrator, CorelDraw, or Xara X, using the W3C standard"
"Scalable Vector Graphics (SVG) file format. Inkscape supports many"
"advanced SVG features (markers, clones, alpha blending, etc.) and"
"great care is taken in designing a streamlined interface. It is very"
"easy to edit nodes, perform complex path operations, trace bitmaps and"
"much more. We also aim to maintain a thriving user and developer"
"community by using open, community-oriented development."
)


build() {
	cd $startdir/src/inkscape-1.2.2_2022-12-01_b0a8486541
	# strip invalid tag
	sed -i /url/d $startdir/src/inkscape-${pkgver}_*/org.inkscape.Inkscape.appdata.xml.in

	# https://bugs.launchpad.net/inkscape/+bug/314381
	# a couple of files have executable bits set,
	# despite not being executable
	find . -name '*.cpp' | xargs chmod -x
	find . -name '*.h' | xargs chmod -x
	# Fix end of line encodings
	dos2unix -k -q share/extensions/*.py || exit 1
	
	mkdir -p build
	cd build
	cmake -Wno-dev \
		-DCMAKE_C_FLAGS_RELEASE:STRING="$SLKCFLAGS -DNDEBUG" \
		-DCMAKE_CXX_FLAGS_RELEASE:STRING="$SLKCFLAGS -DNDEBUG" \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib$LIBDIRSUFFIX \
		-DCMAKE_INSTALL_MANDIR=/usr/man \
		-DENABLE_LCMS=ON \
		-DENABLE_POPPLER=ON \
		-DENABLE_POPPLER_CAIRO=ON \
		-DWITH_JEMALLOC=ON \
		-DWITH_GRAPHICS_MAGICK=ON \
		-DWITH_IMAGE_MAGICK=OFF \
		-DBUILD_SHARED_LIBS=OFF \
		-DBUILD_TESTING=OFF \
		-DWITH_INTERNAL_2GEOM=ON \
		..
	make -j $numjobs || return 1
	make install DESTDIR=$startdir/pkg

	# Don't ship .la files:
	rm -f $startdir/pkg/{,usr/}lib${LIBDIRSUFFIX}/*.la || return 1
	
	# while we're at it, move the bash-completion script too
	mkdir -p $startdir/pkg/etc/bash_completion.d
	mv $startdir/pkg/usr/share/bash-completion/completions/inkscape $startdir/pkg/etc/bash_completion.d/
	rm -rf $startdir/pkg/usr/share/bash-completion
} 
 
