diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2015-12-26 02:58:08 +0000 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2015-12-26 02:58:08 +0000 |
commit | 1332a920f5a36dcdff5625bc703b0bba07fb83e7 (patch) | |
tree | 084e807da2f1e44a73aa1198e544846b4d4d7550 | |
parent | 5f006803eeeb8fc65a68881cc83ef43d113715a5 (diff) | |
parent | 447e86d35d4a0a4aed50056a08c4361c7f903dd8 (diff) | |
download | imv-1332a920f5a36dcdff5625bc703b0bba07fb83e7.tar.gz |
Merge pull request #64 from czarkoff/master
Build infrastructure improvements
-rw-r--r-- | Makefile | 38 | ||||
-rw-r--r-- | README.md | 11 |
2 files changed, 34 insertions, 15 deletions
@@ -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 @@ -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 ----- |