aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2015-12-26 02:58:08 +0000
committerHarry Jeffery <harry@exec64.co.uk>2015-12-26 02:58:08 +0000
commit1332a920f5a36dcdff5625bc703b0bba07fb83e7 (patch)
tree084e807da2f1e44a73aa1198e544846b4d4d7550
parent5f006803eeeb8fc65a68881cc83ef43d113715a5 (diff)
parent447e86d35d4a0a4aed50056a08c4361c7f903dd8 (diff)
downloadimv-1332a920f5a36dcdff5625bc703b0bba07fb83e7.tar.gz
Merge pull request #64 from czarkoff/master
Build infrastructure improvements
-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
-----