aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile38
-rw-r--r--README.md11
2 files changed, 34 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 861a237..ca917af 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,17 @@
.PHONY: clean check install uninstall
-prefix = /usr
+PREFIX ?= /usr
+BINPREFIX ?= $(PREFIX)/bin
+MANPREFIX ?= $(PREFIX)/share/man
+DATAPREFIX ?= $(PREFIX)/share
-CFLAGS = -W -Wall -Wpedantic -std=gnu11 `sdl2-config --cflags`
-LDFLAGS = `sdl2-config --libs` -lfreeimage -lSDL2_ttf -lfontconfig -lpthread
+ifeq ($(V),)
+MUTE := @
+endif
+
+CFLAGS ?= -W -Wall -Wpedantic
+CFLAGS += -std=gnu11 $(shell sdl2-config --cflags)
+LDFLAGS += $(shell sdl2-config --libs) -lfreeimage -lSDL2_ttf -lfontconfig -lpthread
TARGET = imv
BUILDDIR = build
@@ -18,33 +26,33 @@ CFLAGS += -DIMV_VERSION=\"$(VERSION)\"
$(TARGET): $(OBJECTS)
@echo "LINKING $@"
- @$(CC) -o $@ $^ $(LDLIBS) $(LDFLAGS)
+ $(MUTE)$(CC) -o $@ $^ $(LDLIBS) $(LDFLAGS)
debug: CFLAGS += -DDEBUG -g -pg
debug: $(TARGET)
$(BUILDDIR)/%.o: src/%.c
- @mkdir -p $(BUILDDIR)
+ $(MUTE)mkdir -p $(BUILDDIR)
@echo "COMPILING $@"
- @$(CC) -c $(CFLAGS) -o $@ $<
+ $(MUTE)$(CC) -c $(CFLAGS) -o $@ $<
test_%: test/%.c src/%.c
@echo "BUILDING $@"
- @$(CC) -o $@ -Isrc -W -Wall -std=gnu11 -lcmocka $^
+ $(MUTE)$(CC) -o $@ -Isrc -W -Wall -std=gnu11 -lcmocka $^
check: $(TESTS)
@echo "RUNNING TESTS"
- @for t in "$(TESTS)"; do ./$$t; done
+ $(MUTE)for t in "$(TESTS)"; do ./$$t; done
clean:
- @$(RM) $(TARGET) $(OBJECTS) $(TESTS)
+ $(MUTE)$(RM) $(TARGET) $(OBJECTS) $(TESTS)
install: $(TARGET)
- install -D -m 0755 $(TARGET) $(DESTDIR)$(prefix)/bin/imv
- install -D -m 0644 doc/imv.1 $(DESTDIR)$(prefix)/share/man/man1/imv.1
- install -D -m 0644 files/imv.desktop $(DESTDIR)$(prefix)/share/applications/imv.desktop
+ install -D -m 0755 $(TARGET) $(DESTDIR)$(BINPREFIX)/imv
+ install -D -m 0644 doc/imv.1 $(DESTDIR)$(MANPREFIX)/man1/imv.1
+ install -D -m 0644 files/imv.desktop $(DESTDIR)$(DATAPREFIX)/applications/imv.desktop
uninstall:
- $(RM) $(DESTDIR)$(prefix)/bin/imv
- $(RM) $(DESTDIR)$(prefix)/share/man/man1/imv.1
- $(RM) $(DESTDIR)$(prefix)/share/applications/imv.desktop
+ $(RM) $(DESTDIR)$(PREFIX)/bin/imv
+ $(RM) $(DESTDIR)$(PREFIX)/share/man/man1/imv.1
+ $(RM) $(DESTDIR)$(PREFIX)/share/applications/imv.desktop
diff --git a/README.md b/README.md
index 2a08f31..7ed1ff3 100644
--- a/README.md
+++ b/README.md
@@ -64,6 +64,17 @@ Installation
$ make
# make install
+Macro `PREFIX` controls installation prefix. If more control over installation
+paths is required, macros `BINPREFIX`, `MANPREFIX` and `DATAPREFIX` are
+available. Eg. to install `imv` to home directory, run:
+
+ $ BINPREFIX=~/bin PREFIX=~/.local make install
+
+In case something goes wrong during installation process you may use verbose
+mode to inspect commands issued by make:
+
+ $ V=1 make
+
Tests
-----