Cherry-picked r34095 'Add giflib-5.1.0 compatibility' into patches to fix build against recent versions of giflib. Signed-off-by: Daniel Golle <daniel@makrotopia.org>