# Template file for 'gmic'
pkgname=gmic
version=2.1.8
revision=4
_communityhash=c43f88d9537c58be4eeac515282eec8096c4a797
_qthash=c37a653270e69df1956b2614f0e9ce94934c4b06
build_style=gnu-makefile
hostmakedepends="pkg-config gimp"
makedepends="fftw-devel libopenexr-devel MesaLib-devel libopencv-devel
 libgomp-devel libpng-devel libjpeg-turbo-devel tiff-devel libcurl-devel
 gtk+-devel gimp-devel qt5-devel"
short_desc="GREYC's Magic for Image Computing (image processing framework)"
maintainer="Jakub Skrzypnik <jot.skrzyp@gmail.com>"
license="CeCILL"
homepage="http://gmic.eu/"
distfiles="http://gmic.eu/files/source/gmic_${version}.tar.gz
 https://github.com/dtschump/gmic-community/archive/${_communityhash}.tar.gz
 https://github.com/c-koi/gmic-qt/archive/${_qthash}.tar.gz"
checksum="f22783f14cb202dec4a840733f2028f6e2c464fdd2f0166fc38943702cea6bde
 ce71a7d6acf9acde79de42a660f715e8779933e1689f14d39fb0ceaca7582efd
 0bb1683f7ad8f55476ec57e53d73454e05cb79fc55b297eb519b2a24df728b44"
nocross="https://build.voidlinux.eu/builders/armv7l_builder/builds/8869/steps/shell_3/logs/stdio"

CXXFLAGS="-Wno-strict-overflow -Wno-deprecated -fkeep-inline-functions"

pre_build() {
	mv ${XBPS_BUILDDIR}/gmic-qt-${_qthash} ${wrksrc}/gmic-qt
	mv ${XBPS_BUILDDIR}/gmic-community{-${_communityhash},}
	mv ${XBPS_BUILDDIR}/gmic-community/zart ${wrksrc}

	sed -i ${wrksrc}/src/Makefile -e 's;\( *\)ar\( *\);\1$(AR)\2;'

	# Create a toplevel Makefile
	cat > Makefile <<EOF
CC	= $CC
CXX	= $CXX
LD	= $CXX
AR	= $AR
CFLAGS	= $CFLAGS
CXXFLAGS= $CXXFLAGS
LDFLAGS = $LDFLAGS

all:
	make -C src

install:
	make -C src DESTDIR="$DESTDIR" install
EOF
}

post_install() {
	vlicense COPYING
}

gmic-gimp_package() {
	short_desc+=" - GIMP plugin"
	depends="gimp ${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/lib/gimp
	}
}
gmic-zart_package() {
	short_desc+=" - ZArt tool"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/bin/zart
	}
}
gmic-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.so
	}
}
