(RPNG) Make imlib2 optional

This commit is contained in:
twinaphex 2015-02-20 21:10:32 +01:00
parent 1f2db14c2d
commit 33c818cf81
2 changed files with 16 additions and 2 deletions

View File

@ -1,4 +1,12 @@
TARGET := rpng
HAVE_IMLIB2=1
LDFLAGS += -lz
ifeq ($(HAVE_IMLIB2),1)
CFLAGS += -DHAVE_IMLIB2
LDFLAGS += -lImlib2
endif
SOURCES := rpng.c rpng_test.c ../../file/nbio/nbio_stdio.c
OBJS := $(SOURCES:.c=.o)
@ -11,7 +19,7 @@ all: $(TARGET)
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS) -lz -lImlib2
$(CC) -o $@ $^ $(LDFLAGS)
clean:
rm -f $(TARGET) $(OBJS)

View File

@ -25,11 +25,16 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#ifdef HAVE_IMLIB2
#include <Imlib2.h>
#endif
int main(int argc, char *argv[])
{
#ifdef HAVE_IMLIB2
Imlib_Image img;
const uint32_t *imlib_data = NULL;
#endif
const uint32_t test_data[] = {
0xff000000 | 0x50, 0xff000000 | 0x80,
0xff000000 | 0x40, 0xff000000 | 0x88,
@ -43,7 +48,6 @@ int main(int argc, char *argv[])
uint32_t *data = NULL;
unsigned width = 0;
unsigned height = 0;
const uint32_t *imlib_data = NULL;
const char *in_path = "/tmp/test.png";
if (argc > 2)
@ -76,6 +80,7 @@ int main(int argc, char *argv[])
}
#endif
#ifdef HAVE_IMLIB2
/* Validate with imlib2 as well. */
img = imlib_load_image(in_path);
if (!img)
@ -106,6 +111,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Imlib and RPNG are equivalent!\n");
imlib_free_image();
#endif
free(data);
}