diff options
-rw-r--r-- | Makefile | 21 | ||||
-rw-r--r-- | config.mk | 19 | ||||
-rw-r--r-- | src/backend_freeimage.c | 11 | ||||
-rw-r--r-- | src/backend_libpng.c | 12 | ||||
-rw-r--r-- | src/backend_librsvg.c (renamed from src/backend_rsvg.c) | 19 | ||||
-rw-r--r-- | src/backend_librsvg.h (renamed from src/backend_rsvg.h) | 2 | ||||
-rw-r--r-- | src/main.c | 13 |
7 files changed, 87 insertions, 10 deletions
@@ -1,5 +1,7 @@ .PHONY: imv clean check install uninstall doc +include config.mk + PREFIX ?= /usr BINPREFIX ?= $(PREFIX)/bin MANPREFIX ?= $(PREFIX)/share/man @@ -8,11 +10,8 @@ CONFIGPREFIX ?= /etc CFLAGS ?= -W -Wall -pedantic -Wmissing-prototypes CFLAGS += -std=c99 -CFLAGS += $(shell pkg-config --cflags librsvg-2.0) CPPFLAGS += $(shell sdl2-config --cflags) -D_XOPEN_SOURCE=700 LIBS := $(shell sdl2-config --libs) -LIBS += -lfreeimage -lpng -LIBS += $(shell pkg-config --libs librsvg-2.0) LIBS += -lSDL2_ttf -lfontconfig -lpthread BUILDDIR ?= build @@ -28,6 +27,22 @@ VERSION != git describe --dirty --always --tags 2> /dev/null || echo v3.0.0 CFLAGS += -DIMV_VERSION=\""$(VERSION)"\" +# Add backends to build as configured +ifeq ($(BACKEND_FREEIMAGE),yes) + CFLAGS += -DIMV_BACKEND_FREEIMAGE + LIBS += -lfreeimage +endif + +ifeq ($(BACKEND_LIBPNG),yes) + CFLAGS += -DIMV_BACKEND_LIBPNG + LIBS += -lpng +endif + +ifeq ($(BACKEND_LIBRSVG),yes) + CFLAGS += -DIMV_BACKEND_LIBRSVG $(shell pkg-config --cflags librsvg-2.0) + LIBS += $(shell pkg-config --libs librsvg-2.0) +endif + imv: $(TARGET) $(TARGET): $(OBJECTS) diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..e2fa1bf --- /dev/null +++ b/config.mk @@ -0,0 +1,19 @@ +# Configure available backends: + +# FreeImage http://freeimage.sourceforge.net +# provides: png, jpg, animated gif, raw, psd, bmp, tiff, webp, etc. +# depends: libjpeg, openexr, openjpeg2, libwebp, libraw, jxrlib +# license: FIPL v1.0 +BACKEND_FREEIMAGE=yes + +# libpng http://www.libpng.org/pub/png/libpng.html +# provides: png +# depends: zlib +# license: libpng license +BACKEND_LIBPNG=no + +# librsvg https://wiki.gnome.org/Projects/LibRsvg +# provides: svg +# depends: gdk-pixbuf2 pango libcroco +# license: LGPL +BACKEND_LIBRSVG=yes diff --git a/src/backend_freeimage.c b/src/backend_freeimage.c index 8849922..9443075 100644 --- a/src/backend_freeimage.c +++ b/src/backend_freeimage.c @@ -6,6 +6,8 @@ #include <stdio.h> #include <string.h> +#ifdef IMV_BACKEND_FREEIMAGE + #include <FreeImage.h> struct private { @@ -269,3 +271,12 @@ struct imv_backend *imv_backend_freeimage(void) backend->free = &backend_free; return backend; } + +#else + +struct imv_backend *imv_backend_freeimage(void) +{ + return NULL; +} + +#endif diff --git a/src/backend_libpng.c b/src/backend_libpng.c index 20606b4..d5a2676 100644 --- a/src/backend_libpng.c +++ b/src/backend_libpng.c @@ -1,12 +1,13 @@ #include "backend_libpng.h" #include "backend.h" #include "source.h" - #include <alloca.h> #include <stdlib.h> #include <stdio.h> #include <string.h> +#ifdef IMV_BACKEND_LIBPNG + #include <png.h> struct private { @@ -191,3 +192,12 @@ struct imv_backend *imv_backend_libpng(void) backend->free = &backend_free; return backend; } + +#else + +struct imv_backend *imv_backend_libpng(void) +{ + return NULL; +} + +#endif diff --git a/src/backend_rsvg.c b/src/backend_librsvg.c index f259e5c..416743a 100644 --- a/src/backend_rsvg.c +++ b/src/backend_librsvg.c @@ -1,7 +1,11 @@ -#include "backend_rsvg.h" +#include "backend_librsvg.h" #include "backend.h" #include "source.h" +#include <stddef.h> + +#ifdef IMV_BACKEND_LIBRSVG + #include <librsvg/rsvg.h> /* Some systems like GNU/Hurd don't define PATH_MAX */ @@ -131,11 +135,20 @@ static void backend_free(struct imv_backend *backend) free(backend); } -struct imv_backend *imv_backend_rsvg(void) +struct imv_backend *imv_backend_librsvg(void) { struct imv_backend *backend = malloc(sizeof(struct imv_backend)); - backend->name = "rsvg (LGPL license)"; + backend->name = "librsvg (LGPL license)"; backend->open_path = &open_path; backend->free = &backend_free; return backend; } + +#else + +struct imv_backend *imv_backend_librsvg(void) +{ + return NULL; +} + +#endif diff --git a/src/backend_rsvg.h b/src/backend_librsvg.h index 126892a..16dd6c8 100644 --- a/src/backend_rsvg.h +++ b/src/backend_librsvg.h @@ -4,6 +4,6 @@ struct imv_backend; /* Create an instance of the rsvg backend */ -struct imv_backend *imv_backend_rsvg(void); +struct imv_backend *imv_backend_librsvg(void); #endif @@ -1,9 +1,10 @@ #include "imv.h" #include "backend.h" + #include "backend_freeimage.h" #include "backend_libpng.h" -#include "backend_rsvg.h" +#include "backend_librsvg.h" int main(int argc, char** argv) { @@ -13,9 +14,17 @@ int main(int argc, char** argv) return 1; } - imv_install_backend(imv, imv_backend_rsvg()); +#ifdef IMV_BACKEND_FREEIMAGE imv_install_backend(imv, imv_backend_freeimage()); +#endif + +#ifdef IMV_BACKEND_LIBPNG imv_install_backend(imv, imv_backend_libpng()); +#endif + +#ifdef IMV_BACKEND_LIBRSVG + imv_install_backend(imv, imv_backend_librsvg()); +#endif if(!imv_load_config(imv)) { imv_free(imv); |