--- /dev/null
+--- a/src/libimage/gif.c
++++ b/src/libimage/gif.c
+@@ -20,6 +20,7 @@
+
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <stdbool.h>
+ #include <string.h>
+
+ #include <gif_lib.h>
+@@ -179,7 +180,11 @@
+ }
+ }
+
++#if GIFLIB_MAJOR >= 5
++ if (DGifCloseFile(GifFile, NULL) == GIF_ERROR) {
++#else
+ if (DGifCloseFile(GifFile) == GIF_ERROR) {
++#endif
+ return(0);
+ }
+
+@@ -240,7 +245,7 @@
+ * Also non of the parameter are allocated by this routine.
+ * This function returns GIF_OK if succesfull, GIF_ERROR otherwise.
+ ******************************************************************************/
+-static int
++int
+ QuantizeBuffer(unsigned int Width,
+ unsigned int Height,
+ int *ColorMapSize,
+@@ -493,7 +498,11 @@
+ static void QuitGifError(GifFileType *GifFile)
+ {
+ fprintf(stderr, "Error writing GIF file\n");
++#if GIFLIB_MAJOR >= 5
++ if (GifFile != NULL) EGifCloseFile(GifFile, NULL);
++#else
+ if (GifFile != NULL) EGifCloseFile(GifFile);
++#endif
+ }
+
+ int
+@@ -589,7 +598,11 @@
+ Ptr += width;
+ }
+
++#if GIFLIB_MAJOR >= 5
++ if (EGifCloseFile(GifFile, NULL) == GIF_ERROR)
++#else
+ if (EGifCloseFile(GifFile) == GIF_ERROR)
++#endif
+
+ {
+ QuitGifError(GifFile);
--- /dev/null
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+inherit base flag-o-matic
+
+DESCRIPTION="Render images of the earth into the X root window"
+HOMEPAGE="http://xplanet.sourceforge.net/"
+SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~sparc ~x86"
+IUSE="gif jpeg png tiff truetype X"
+
+RDEPEND="gif? ( >media-libs/giflib-4.2 )
+ jpeg? ( virtual/jpeg )
+ png? (
+ media-libs/libpng:0
+ media-libs/netpbm
+ )
+ tiff? ( media-libs/tiff:0 )
+ truetype? (
+ media-libs/freetype:2
+ x11-libs/pango
+ )
+ X? (
+ x11-libs/libX11
+ x11-libs/libXext
+ x11-libs/libXScrnSaver
+ x11-libs/libXt
+ )"
+DEPEND="${RDEPEND}
+ truetype? ( virtual/pkgconfig )
+ X? (
+ x11-proto/scrnsaverproto
+ x11-proto/xproto
+ )"
+
+DOCS="AUTHORS ChangeLog NEWS README TODO"
+
+PATCHES=( "${FILESDIR}"/${P}-giflib.patch )
+
+src_configure() {
+ # econf says 'checking pnm.h presence... no'
+ use png && append-cppflags -I/usr/include/netpbm
+
+ local myconf
+
+ use X \
+ && myconf+=" --with-x --with-xscreensaver" \
+ || myconf+=" --with-x=no --with-xscreensaver=no"
+
+ use gif \
+ && myconf+=" --with-gif" \
+ || myconf+=" --with-gif=no"
+
+ use jpeg \
+ && myconf+=" --with-jpeg" \
+ || myconf+=" --with-jpeg=no"
+
+ use tiff \
+ && myconf+=" --with-tiff" \
+ || myconf+=" --with-tiff=no"
+
+ use png \
+ && myconf+=" --with-png --with-pnm" \
+ || myconf+=" --with-png=no --with-pnm=no"
+
+ use truetype \
+ && myconf+=" --with-freetype --with-pango" \
+ || myconf+=" --with-freetype=no --with-pango=no"
+
+ econf \
+ --with-cspice=no \
+ ${myconf}
+}