Krolyxon
Commit a4b90ae

Branches

Refs →

nsxiva4b90ae

Added HAVE_GIFLIB macro for optional dependency on giflib

Author
Bert
Date
2011-08-17 18:17 +0200
Committer
Bert · 2011-08-19 15:12 +0200
Parent
79bd86d
Commit
a4b90aee2001d0b0f458f3d741fbf5bcad04a7cb

+13 −3

3 files changed

  1. M Makefile +1 −1
  2. M Makefile.netbsd +1 −1
  3. M image.c +11 −1
M Makefile View
@@ -5,7 +5,7 @@ VERSION = git-20110819
55 CC = gcc
66 DESTDIR =
77 PREFIX = /usr/local
8−CFLAGS = -Wall -pedantic -O2 -DVERSION=\"$(VERSION)\"
8+CFLAGS = -Wall -pedantic -O2 -DVERSION=\"$(VERSION)\" -DHAVE_GIFLIB
99 LDFLAGS =
1010 LIBS = -lX11 -lImlib2 -lgif
1111
M Makefile.netbsd View
@@ -1,4 +1,4 @@
11 .include "Makefile"
22
3−CFLAGS = -Wall -pedantic -DVERSION=\"$(VERSION)\" -I/usr/X11R7/include -I/usr/pkg/include
3+CFLAGS = -Wall -pedantic -O2 -DVERSION=\"$(VERSION)\" -DHAVE_GIFLIB -I/usr/X11R7/include -I/usr/pkg/include
44 LDFLAGS = -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib
M image.c View
@@ -18,11 +18,14 @@
1818
1919 #define _IMAGE_CONFIG
2020
21+#include <unistd.h>
22+
23+#ifdef HAVE_GIFLIB
2124 #include <stdlib.h>
2225 #include <string.h>
23−#include <unistd.h>
2426 #include <sys/types.h>
2527 #include <gif_lib.h>
28+#endif
2629
2730 #include "image.h"
2831 #include "options.h"
@@ -55,6 +58,7 @@ void img_init(img_t *img, win_t *win) {
5558 }
5659 }
5760
61+#ifdef HAVE_GIFLIB
5862 int img_load_gif(img_t *img, const fileinfo_t *file) {
5963 GifFileType *gif;
6064 GifRowType *rows = NULL;
@@ -208,6 +212,7 @@ int img_load_gif(img_t *img, const fileinfo_t *file) {
208212
209213 return !err;
210214 }
215+#endif /* HAVE_GIFLIB */
211216
212217 int img_load(img_t *img, const fileinfo_t *file) {
213218 const char *fmt;
@@ -225,8 +230,13 @@ int img_load(img_t *img, const fileinfo_t *file) {
225230 imlib_context_set_anti_alias(img->aa);
226231
227232 fmt = imlib_image_format();
233+#ifdef HAVE_GIFLIB
228234 if (!strcmp(fmt, "gif"))
229235 img_load_gif(img, file);
236+#else
237+ /* avoid unused-but-set-variable warning */
238+ (void) fmt;
239+#endif
230240
231241 img->scalemode = options->scalemode;
232242 img->re = 0;