Makefile: Don't use $(wildcard)

This commit is contained in:
Harry Jeffery 2019-02-23 21:04:06 +00:00
parent 28eb7b50dc
commit cd0684a2cb
6 changed files with 27 additions and 62 deletions

View file

@ -16,40 +16,60 @@ override LIBS += -lSDL2_ttf -lfontconfig -lpthread
BUILDDIR ?= build
TARGET := $(BUILDDIR)/imv
SOURCES := $(wildcard src/*.c)
OBJECTS := $(patsubst src/%.c,$(BUILDDIR)/%.o,$(SOURCES))
TESTS := $(patsubst test/%.c,$(BUILDDIR)/test_%,$(wildcard test/*.c))
SOURCES := src/main.c
VERSION != git describe --dirty --always --tags 2> /dev/null || echo v3.0.0
override CPPFLAGS += -DIMV_VERSION=\""$(VERSION)"\"
SOURCES += src/binds.c
SOURCES += src/bitmap.c
SOURCES += src/commands.c
SOURCES += src/image.c
SOURCES += src/imv.c
SOURCES += src/ini.c
SOURCES += src/list.c
SOURCES += src/navigator.c
SOURCES += src/util.c
SOURCES += src/viewport.c
# Add backends to build as configured
ifeq ($(BACKEND_FREEIMAGE),yes)
SOURCES += src/backend_freeimage.c
override CPPFLAGS += -DIMV_BACKEND_FREEIMAGE
override LIBS += -lfreeimage
endif
ifeq ($(BACKEND_LIBTIFF),yes)
SOURCES += src/backend_libtiff.c
override CPPFLAGS += -DIMV_BACKEND_LIBTIFF
override LIBS += -ltiff
endif
ifeq ($(BACKEND_LIBPNG),yes)
SOURCES += src/backend_libpng.c
override CPPFLAGS += -DIMV_BACKEND_LIBPNG
override LIBS += -lpng
endif
ifeq ($(BACKEND_LIBJPEG),yes)
SOURCES += src/backend_libjpeg.c
override CPPFLAGS += -DIMV_BACKEND_LIBJPEG
override LIBS += -lturbojpeg
endif
ifeq ($(BACKEND_LIBRSVG),yes)
SOURCES += src/backend_librsvg.c
override CPPFLAGS += -DIMV_BACKEND_LIBRSVG $(shell pkg-config --cflags librsvg-2.0)
override LIBS += $(shell pkg-config --libs librsvg-2.0)
endif
TEST_SOURCES := test/list.c test/navigator.c
OBJECTS := $(patsubst src/%.c,$(BUILDDIR)/%.o,$(SOURCES))
TESTS := $(patsubst test/%.c,$(BUILDDIR)/test_%,$(TEST_SOURCES))
VERSION != git describe --dirty --always --tags 2> /dev/null || echo v3.0.0
override CPPFLAGS += -DIMV_VERSION=\""$(VERSION)"\"
TFLAGS ?= -g $(CFLAGS) $(CPPFLAGS) $(shell pkg-config --cflags cmocka)
TLIBS := $(LIBS) $(shell pkg-config --libs cmocka)
@ -69,7 +89,7 @@ $(BUILDDIR):
$(BUILDDIR)/%.o: src/%.c Makefile
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(BUILDDIR)/test_%: test/%.c $(filter-out src/main.c, $(wildcard src/*.c))
$(BUILDDIR)/test_%: test/%.c $(filter-out src/main.c, $(SOURCES))
$(CC) -o $@ -Isrc $(TFLAGS) $^ $(LDFLAGS) $(TLIBS)
check: $(BUILDDIR) $(TESTS)

View file

@ -6,8 +6,6 @@
#include <stdio.h>
#include <string.h>
#ifdef IMV_BACKEND_FREEIMAGE
#include <FreeImage.h>
struct private {
@ -342,12 +340,3 @@ const struct imv_backend *imv_backend_freeimage(void)
{
return &freeimage_backend;
}
#else
const struct imv_backend *imv_backend_freeimage(void)
{
return NULL;
}
#endif

View file

@ -8,8 +8,6 @@
#include <unistd.h>
#include <fcntl.h>
#ifdef IMV_BACKEND_LIBJPEG
#include <turbojpeg.h>
struct private {
@ -227,12 +225,3 @@ const struct imv_backend *imv_backend_libjpeg(void)
{
return &libjpeg_backend;
}
#else
const struct imv_backend *imv_backend_libjpeg(void)
{
return NULL;
}
#endif

View file

@ -5,8 +5,6 @@
#include <stdio.h>
#include <string.h>
#ifdef IMV_BACKEND_LIBPNG
#include <png.h>
struct private {
@ -206,12 +204,3 @@ const struct imv_backend *imv_backend_libpng(void)
{
return &libpng_backend;
}
#else
const struct imv_backend *imv_backend_libpng(void)
{
return NULL;
}
#endif

View file

@ -5,8 +5,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef IMV_BACKEND_LIBRSVG
#include <librsvg/rsvg.h>
/* Some systems like GNU/Hurd don't define PATH_MAX */
@ -210,12 +208,3 @@ const struct imv_backend *imv_backend_librsvg(void)
{
return &librsvg_backend;
}
#else
const struct imv_backend *imv_backend_librsvg(void)
{
return NULL;
}
#endif

View file

@ -8,8 +8,6 @@
#include <unistd.h>
#include <fcntl.h>
#ifdef IMV_BACKEND_LIBTIFF
#include <tiffio.h>
struct private {
@ -238,12 +236,3 @@ const struct imv_backend *imv_backend_libtiff(void)
{
return &libtiff_backend;
}
#else
const struct imv_backend *imv_backend_libtiff(void)
{
return NULL;
}
#endif