From 33c818cf81fb3f8d16241032fd9f4a1bcaeda491 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 20 Feb 2015 21:10:32 +0100 Subject: [PATCH] (RPNG) Make imlib2 optional --- libretro-common/formats/png/Makefile | 10 +++++++++- libretro-common/formats/png/rpng_test.c | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libretro-common/formats/png/Makefile b/libretro-common/formats/png/Makefile index 46fde8a9f1..b757cf4da2 100644 --- a/libretro-common/formats/png/Makefile +++ b/libretro-common/formats/png/Makefile @@ -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) diff --git a/libretro-common/formats/png/rpng_test.c b/libretro-common/formats/png/rpng_test.c index 0d3ad73265..8e639c4a9a 100644 --- a/libretro-common/formats/png/rpng_test.c +++ b/libretro-common/formats/png/rpng_test.c @@ -25,11 +25,16 @@ #include #include #include +#ifdef HAVE_IMLIB2 #include +#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); }