imv/Makefile

178 lines
5.2 KiB
Makefile
Raw Normal View History

2019-01-31 01:02:06 +01:00
.PHONY: imv debug clean check install uninstall doc
2015-11-06 17:57:40 +01:00
2019-01-21 23:19:16 +01:00
include config.mk
PREFIX ?= /usr
BINPREFIX ?= $(PREFIX)/bin
MANPREFIX ?= $(PREFIX)/share/man
DATAPREFIX ?= $(PREFIX)/share
2017-11-23 23:17:40 +01:00
CONFIGPREFIX ?= /etc
2015-11-05 20:57:24 +01:00
INSTALL_DATA ?= install -m 0644
INSTALL_MAN ?= install -m 0644
INSTALL_PROGRAM ?= install -m 0755
override CFLAGS += -std=c99 -W -Wall -Wpedantic -Wextra $(shell pkg-config --cflags pangocairo)
override CPPFLAGS += -D_XOPEN_SOURCE=700
2019-07-13 12:02:37 +02:00
override LIBS := -lGL -lpthread -lxkbcommon $(shell pkg-config --libs pangocairo)
2015-11-05 20:57:24 +01:00
BUILDDIR ?= build
2019-08-18 15:36:57 +02:00
TARGET_WAYLAND = $(BUILDDIR)/imv-wayland
TARGET_X11 = $(BUILDDIR)/imv-x11
2019-08-12 21:10:48 +02:00
TARGET_MSG = $(BUILDDIR)/imv-msg
ifeq ($(WINDOWS),wayland)
2019-08-18 15:36:57 +02:00
TARGETS := $(TARGET_WAYLAND) $(TARGET_MSG)
else ifeq ($(WINDOWS),x11)
2019-08-12 21:10:48 +02:00
TARGETS := $(TARGET_X11) $(TARGET_MSG)
else ifeq ($(WINDOWS),all)
2019-08-18 15:36:57 +02:00
TARGETS := $(TARGET_WAYLAND) $(TARGET_X11) $(TARGET_MSG)
endif
2019-02-23 22:04:06 +01:00
SOURCES := src/main.c
SOURCES += src/binds.c
SOURCES += src/bitmap.c
SOURCES += src/canvas.c
2019-02-23 22:04:06 +01:00
SOURCES += src/commands.c
SOURCES += src/console.c
2019-02-23 22:04:06 +01:00
SOURCES += src/image.c
SOURCES += src/imv.c
SOURCES += src/ini.c
2019-08-08 00:20:37 +02:00
SOURCES += src/ipc.c
2019-08-12 21:10:48 +02:00
SOURCES += src/ipc_common.c
SOURCES += src/keyboard.c
2019-02-23 22:04:06 +01:00
SOURCES += src/list.c
2019-06-13 23:08:29 +02:00
SOURCES += src/log.c
2019-02-23 22:04:06 +01:00
SOURCES += src/navigator.c
SOURCES += src/viewport.c
2019-07-13 12:02:37 +02:00
WL_SOURCES = src/wl_window.c src/xdg-shell-protocol.c
WL_LIBS = -lwayland-client -lwayland-egl -lEGL
2015-11-11 21:40:59 +01:00
X11_SOURCES = src/x11_window.c
2019-08-18 01:46:57 +02:00
X11_LIBS = -lX11 -lGL -lGLU -lxcb -lxkbcommon-x11
2019-07-13 12:38:26 +02:00
2019-08-12 21:10:48 +02:00
MSG_SOURCES = src/imv_msg.c src/ipc_common.c
MSG_LIBS =
2019-01-21 23:19:16 +01:00
# Add backends to build as configured
ifeq ($(BACKEND_FREEIMAGE),yes)
2019-02-23 22:04:06 +01:00
SOURCES += src/backend_freeimage.c
2019-01-31 01:02:06 +01:00
override CPPFLAGS += -DIMV_BACKEND_FREEIMAGE
override LIBS += -lfreeimage
2019-01-21 23:19:16 +01:00
endif
2019-02-02 23:32:39 +01:00
ifeq ($(BACKEND_LIBTIFF),yes)
2019-02-23 22:04:06 +01:00
SOURCES += src/backend_libtiff.c
2019-02-02 23:32:39 +01:00
override CPPFLAGS += -DIMV_BACKEND_LIBTIFF
override LIBS += -ltiff
endif
2019-01-21 23:19:16 +01:00
ifeq ($(BACKEND_LIBPNG),yes)
2019-02-23 22:04:06 +01:00
SOURCES += src/backend_libpng.c
2019-01-31 01:02:06 +01:00
override CPPFLAGS += -DIMV_BACKEND_LIBPNG
override LIBS += -lpng
2019-01-21 23:19:16 +01:00
endif
2019-01-31 22:40:28 +01:00
ifeq ($(BACKEND_LIBJPEG),yes)
2019-02-23 22:04:06 +01:00
SOURCES += src/backend_libjpeg.c
2019-01-31 22:40:28 +01:00
override CPPFLAGS += -DIMV_BACKEND_LIBJPEG
override LIBS += -lturbojpeg
endif
2019-01-21 23:19:16 +01:00
ifeq ($(BACKEND_LIBRSVG),yes)
2019-02-23 22:04:06 +01:00
SOURCES += src/backend_librsvg.c
2019-01-31 01:02:06 +01:00
override CPPFLAGS += -DIMV_BACKEND_LIBRSVG $(shell pkg-config --cflags librsvg-2.0)
override LIBS += $(shell pkg-config --libs librsvg-2.0)
2019-01-21 23:19:16 +01:00
endif
2019-02-23 22:04:06 +01:00
TEST_SOURCES := test/list.c test/navigator.c
OBJECTS := $(patsubst src/%.c,$(BUILDDIR)/%.o,$(SOURCES))
WL_OBJECTS := $(patsubst src/%.c,$(BUILDDIR)/%.o,$(WL_SOURCES))
X11_OBJECTS := $(patsubst src/%.c,$(BUILDDIR)/%.o,$(X11_SOURCES))
2019-08-12 21:10:48 +02:00
MSG_OBJECTS := $(patsubst src/%.c,$(BUILDDIR)/%.o,$(MSG_SOURCES))
2019-02-23 22:04:06 +01:00
TESTS := $(patsubst test/%.c,$(BUILDDIR)/test_%,$(TEST_SOURCES))
2019-08-20 20:28:03 +02:00
VERSION != git describe --dirty --always --tags 2> /dev/null || echo v4.0.0-rc1
2019-02-23 22:04:06 +01:00
override CPPFLAGS += -DIMV_VERSION=\""$(VERSION)"\"
2019-01-31 00:15:14 +01:00
TFLAGS ?= -g $(CFLAGS) $(CPPFLAGS) $(shell pkg-config --cflags cmocka)
TLIBS := $(LIBS) $(shell pkg-config --libs cmocka)
imv: $(TARGETS)
2019-08-18 15:36:57 +02:00
$(TARGET_WAYLAND): $(OBJECTS) $(WL_OBJECTS)
$(CC) -o $@ $^ $(LIBS) $(WL_LIBS) $(LDFLAGS)
2019-08-12 21:10:48 +02:00
$(TARGET_X11): $(OBJECTS) $(X11_OBJECTS)
$(CC) -o $@ $^ $(LIBS) $(X11_LIBS) $(LDFLAGS)
2015-11-05 20:57:24 +01:00
2019-08-12 21:10:48 +02:00
$(TARGET_MSG): $(MSG_OBJECTS)
$(CC) -o $@ $^ $(MSG_LIBS) $(LDFLAGS)
debug: CFLAGS += -DDEBUG -g -pg
debug: $(TARGETS)
2015-11-10 21:50:10 +01:00
$(OBJECTS): | $(BUILDDIR)
$(BUILDDIR):
2016-11-22 15:50:49 +01:00
mkdir -p $(BUILDDIR)
2019-01-31 01:02:06 +01:00
$(BUILDDIR)/%.o: src/%.c Makefile
2016-11-22 15:50:49 +01:00
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
2019-08-12 01:28:24 +02:00
$(BUILDDIR)/test_%: test/%.c src/dummy_window.c $(filter-out src/main.c, $(SOURCES))
2016-11-22 15:50:49 +01:00
$(CC) -o $@ -Isrc $(TFLAGS) $^ $(LDFLAGS) $(TLIBS)
2015-12-08 17:36:26 +01:00
check: $(BUILDDIR) $(TESTS)
2016-11-22 15:50:49 +01:00
for t in $(TESTS); do $$t; done
2015-12-08 17:36:26 +01:00
2015-11-05 20:57:24 +01:00
clean:
2016-11-22 15:50:49 +01:00
$(RM) -Rf $(BUILDDIR)
2019-08-12 21:41:27 +02:00
$(RM) doc/imv.1 doc/imv-msg.1 doc/imv.5
2015-11-06 17:57:40 +01:00
2019-08-12 21:41:27 +02:00
doc: doc/imv.1 doc/imv-msg.1 doc/imv.5
2017-11-30 22:49:13 +01:00
doc/%: doc/%.txt
a2x --no-xmllint --doctype manpage --format manpage $<
install: $(TARGETS) doc
mkdir -p $(DESTDIR)$(BINPREFIX)
2019-08-12 02:01:18 +02:00
ifeq ($(WINDOWS),wayland)
2019-08-18 15:36:57 +02:00
$(INSTALL_PROGRAM) $(TARGET_WAYLAND) $(DESTDIR)$(BINPREFIX)/imv
2019-08-12 02:01:18 +02:00
else ifeq ($(WINDOWS),x11)
$(INSTALL_PROGRAM) $(TARGET_X11) $(DESTDIR)$(BINPREFIX)/imv
2019-08-12 02:01:18 +02:00
else ifeq ($(WINDOWS),all)
2019-08-18 15:36:57 +02:00
$(INSTALL_PROGRAM) $(TARGET_WAYLAND) $(DESTDIR)$(BINPREFIX)/imv-wayland
$(INSTALL_PROGRAM) $(TARGET_X11) $(DESTDIR)$(BINPREFIX)/imv-x11
2019-08-18 15:20:28 +02:00
$(INSTALL_PROGRAM) files/imv $(DESTDIR)$(BINPREFIX)/imv
2019-08-12 02:01:18 +02:00
endif
2019-08-12 21:10:48 +02:00
$(INSTALL_PROGRAM) $(TARGET_MSG) $(DESTDIR)$(BINPREFIX)/imv-msg
2019-06-24 09:07:29 +02:00
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
$(INSTALL_MAN) doc/imv.1 $(DESTDIR)$(MANPREFIX)/man1/imv.1
2019-08-12 21:41:27 +02:00
$(INSTALL_MAN) doc/imv-msg.1 $(DESTDIR)$(MANPREFIX)/man1/imv-msg.1
2019-06-24 09:07:29 +02:00
mkdir -p $(DESTDIR)$(MANPREFIX)/man5
$(INSTALL_MAN) doc/imv.5 $(DESTDIR)$(MANPREFIX)/man5/imv.5
mkdir -p $(DESTDIR)$(DATAPREFIX)/applications
$(INSTALL_DATA) files/imv.desktop $(DESTDIR)$(DATAPREFIX)/applications/imv.desktop
mkdir -p $(DESTDIR)$(CONFIGPREFIX)
$(INSTALL_DATA) files/imv_config $(DESTDIR)$(CONFIGPREFIX)/imv_config
2015-11-22 21:32:04 +01:00
uninstall:
2019-08-12 02:01:18 +02:00
ifeq ($(WINDOWS),all)
2019-08-18 15:36:57 +02:00
$(RM) $(DESTDIR)$(BINPREFIX)/imv-wayland
$(RM) $(DESTDIR)$(BINPREFIX)/imv-x11
2019-08-12 02:01:18 +02:00
endif
$(RM) $(DESTDIR)$(BINPREFIX)/imv
2019-08-12 21:10:48 +02:00
$(RM) $(DESTDIR)$(BINPREFIX)/imv-msg
$(RM) $(DESTDIR)$(MANPREFIX)/man1/imv.1
2019-08-12 21:41:27 +02:00
$(RM) $(DESTDIR)$(MANPREFIX)/man1/imv-msg.1
2017-11-29 22:57:24 +01:00
$(RM) $(DESTDIR)$(MANPREFIX)/man5/imv.5
$(RM) $(DESTDIR)$(DATAPREFIX)/applications/imv.desktop
2017-11-23 23:17:40 +01:00
@echo "$(DESTDIR)$(CONFIGPREFIX)/imv_config has not been removed. Please remove it manually."