SUMMARY="The popular image manipulation software"
DESCRIPTION="GIMP is a cross-platform image editor available for GNU/Linux, \
macOS, Windows and more operating systems.
Whether you are a graphic designer, photographer, illustrator, or scientist, \
GIMP provides you with sophisticated tools to get your job done. You can further \
enhance your productivity with GIMP thanks to many customization options \
and 3rd party plugins."
HOMEPAGE="https://www.gimp.org/"
COPYRIGHT="The GIMP Team"
LICENSE="GNU GPL v3"
REVISION="3"
SOURCE_URI="https://download.gimp.org/mirror/pub/gimp/v2.99/gimp-$portVersion.tar.bz2"
CHECKSUM_SHA256="dd916bd3474ef2efc652a0510280977ab8ea95e3d95d918394b0662261c32aae"
PATCHES="gimp-$portVersion.patchset"
ADDITIONAL_FILES="gimp.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="?x86"

GLOBAL_WRITABLE_FILES="
	settings/gimp/2.99/controllerrc keep-old
	settings/gimp/2.99/gimp.css keep-old
	settings/gimp/2.99/gimprc keep-old
	settings/gimp/2.99/menurc keep-old
	settings/gimp/2.99/sessionrc keep-old
	settings/gimp/2.99/templaterc keep-old
	settings/gimp/2.99/toolrc keep-old
	settings/gimp/2.99/unitrc keep-old
	"

PROVIDES="
	gimp$secondaryArchSuffix = $portVersion
	app:GIMP = $portVersion
	cmd:gimp_console_2.99$secondaryArchSuffix = $portVersion
	cmd:gimp_test_clipboard_2.99$secondaryArchSuffix = $portVersion
	cmd:gimptool_2.99$secondaryArchSuffix = $portVersion
	lib:libgimp_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	lib:libgimpbase_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	lib:libgimpcolor_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	lib:libgimpconfig_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	lib:libgimpmath_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	lib:libgimpmodule_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	lib:libgimpthumb_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	lib:libgimpui_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	lib:libgimpwidgets_3.0$secondaryArchSuffix = 0.9900.8 compat >= 0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	mypaint_brushes
	shared_mime_info$secondaryArchSuffix
	lib:libappstream_glib$secondaryArchSuffix
	lib:libarchive$secondaryArchSuffix
	lib:libatk_1.0$secondaryArchSuffix
	lib:libbabl_0.1$secondaryArchSuffix
	lib:libcairo$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libexiv2$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libfribidi$secondaryArchSuffix
	lib:libgegl_0.4$secondaryArchSuffix
	lib:libgexiv2$secondaryArchSuffix
	lib:libgdk_3$secondaryArchSuffix
	lib:libgdk_pixbuf_2.0$secondaryArchSuffix
	lib:libgtk_3$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libglib_networking_2.0$secondaryArchSuffix
	lib:libharfbuzz$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libjson_c$secondaryArchSuffix
	lib:libjson_glib_1.0$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:liblzma$secondaryArchSuffix
	lib:libmypaint$secondaryArchSuffix
	lib:libpango_1.0$secondaryArchSuffix
	lib:libpangocairo_1.0$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libpoppler$secondaryArchSuffix
	lib:libpoppler_glib$secondaryArchSuffix
	lib:librsvg_2$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libuuid$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libxslt$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	mypaint_brushes
	devel:libappstream_glib$secondaryArchSuffix
	devel:libarchive$secondaryArchSuffix
	devel:libatk_1.0$secondaryArchSuffix
	devel:libbabl_0.1$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libexiv2$secondaryArchSuffix
	devel:libcairo$secondaryArchSuffix
	devel:libfontconfig$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libfribidi$secondaryArchSuffix
	devel:libgegl_0.4$secondaryArchSuffix
	devel:libgexiv2$secondaryArchSuffix
	devel:libgdk_3$secondaryArchSuffix
	devel:libgdk_pixbuf_2.0$secondaryArchSuffix
	devel:libgtk_3$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libharfbuzz$secondaryArchSuffix
	devel:libjson_c$secondaryArchSuffix
	devel:libjson_glib_1.0$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:liblcms2$secondaryArchSuffix
	devel:liblzma$secondaryArchSuffix
	devel:libmypaint$secondaryArchSuffix
	devel:libpango_1.0$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libpoppler$secondaryArchSuffix >= 117
	devel:librsvg_2$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libuuid$secondaryArchSuffix >= 1.3
	devel:libxml2$secondaryArchSuffix
	devel:libxslt$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	lib:libglib_networking_2.0$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:gtkdocize
	cmd:intltool_update
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	cmd:update_mime_database$secondaryArchSuffix
	"

BUILD()
{
	cp -Rf /system/data/mime /tmp/mime
	export XDG_DATA_DIRS="/tmp/mime:/system/data"
	export XDG_DATA_HOME="/tmp/mime"
	update-mime-database /tmp/mime

	export GDK_PIXBUF_MODULE_FILE="/tmp/loaders.cache"
	gdk-pixbuf-query-loaders > $GDK_PIXBUF_MODULE_FILE

	export LIBS="-lnetwork"

	autoreconf -f -i

	runConfigure ./configure \
		--enable-introspection=no \
		--disable-check-update \
		--disable-mp \
		--disable-rpath \
		--without-webkit \
		--without-libbacktrace \
		--without-appdata-test \
		--without-cairo-pdf \
		--without-xmc \
		--with-shm=none \
		--with-vala=no \
		--with-lua=no \
		--with-javascript=no \
		--with-python=no

	make $jobArgs
}

INSTALL()
{
	make install

	mkdir -p $appsDir

	mv $prefix/share/locale $dataDir
	mv $binDir/gimp-2.99 $appsDir/GIMP

	rm -rf \
		$prefix/share \
		$developDir \
		$libDir/*.la \
		$libDir/pkgconfig \
		$dataDir/{metainfo,icons,gtk-doc,applications,aclocal}

	local APP_SIGNATURE="application/x-vnd.gnu-gimp"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/gimp.rdef.in > gimp.rdef

	addResourcesToBinaries gimp.rdef $appsDir/GIMP
	addAppDeskbarSymlink $appsDir/GIMP
}
