aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-12-01 15:15:38 +0100
committerMattias Andrée <maandree@kth.se>2016-12-01 15:15:38 +0100
commit35365a06c3f842afe47a9eef67b1d2dde7a20bb3 (patch)
tree487d54cdc0e41ffaded46604d4fd6aab61ad9519
parentFix bugs (diff)
downloadcg-tools-35365a06c3f842afe47a9eef67b1d2dde7a20bb3.tar.gz
cg-tools-35365a06c3f842afe47a9eef67b1d2dde7a20bb3.tar.bz2
cg-tools-35365a06c3f842afe47a9eef67b1d2dde7a20bb3.tar.xz
Add install and uninstall rules
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--Makefile67
1 files changed, 66 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index c58d5c9..e3d1412 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,12 @@
+PREFIX = /usr
+BINDIR = $(PREFIX)/bin
+DATADIR = $(PREFIX)/share
+MANDIR = $(DATADIR)/man
+MAN1DIR = $(MANDIR)/man1
+MAN7DIR = $(MANDIR)/man7
+LICENSEDIR = $(DATADIR)/licenses
+
+
PKGNAME = cg-tools
@@ -12,6 +21,20 @@ BIN = bin/cg-brilliance \
bin/cg-remove \
bin/cg-sleepmode
+MAN1 = man/cg-brilliance.1 \
+ man/cg-darkroom.1 \
+ man/cg-gamma.1 \
+ man/cg-icc.1 \
+ man/cg-limits.1 \
+ man/cg-negative.1 \
+ man/cg-query.1 \
+ man/cg-rainbow.1 \
+ man/cg-remove.1 \
+ man/cg-sleepmode.1
+
+MAN7 = man/cg-tools.7
+
+
OPTIMISE = -O2
WARN = -Wall -Wextra
@@ -37,7 +60,49 @@ obj/%.o: src/%.c src/*.h
@mkdir -p -- "$$(dirname -- "$@")"
$(CC) -std=c99 $(OPTIMISE) $(WARN) $(DEF) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+install: install-base install-doc
+
+install-base: install-cmd install-copyright
+
+install-copyright: install-license install-copying
+
+install-doc: install-man
+
+install-man: install-man1 install-man7
+
+install-cmd: $(BIN)
+ mkdir -p -- "$(DESTDIR)$(BINDIR)"
+ install -m755 -- $(BIN) "$(DESTDIR)$(BINDIR)"
+
+install-license:
+ mkdir -p -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
+ install -m644 -- LICENSE "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
+
+install-copying:
+ mkdir -p -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
+ install -m644 -- COPYING "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
+
+install-man1:
+ mkdir -p -- "$(DESTDIR)$(MAN1DIR)"
+ install -m644 -- $(MAN1) "$(DESTDIR)$(MAN1DIR)"
+
+install-man7:
+ mkdir -p -- "$(DESTDIR)$(MAN7DIR)"
+ install -m644 -- $(MAN7) "$(DESTDIR)$(MAN7DIR)"
+
+
+uninstall:
+ -cd "$(DESTDIR)$(BINDIR)" && rm -- $$(printf -- '%s\n' $(BIN) | cut -d / -f 2-)
+ -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
+ -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
+ -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
+ -cd "$(DESTDIR)$(MAN1DIR)" && rm -- $$(printf -- '%s\n' $(MAN1) | cut -d / -f 2-)
+ -cd "$(DESTDIR)$(MAN7DIR)" && rm -- $$(printf -- '%s\n' $(MAN7) | cut -d / -f 2-)
+
+
clean:
-rm -r -- bin obj
-.PHONY: all clean
+.PHONY: all clean install install-base install-doc install-cmd install-copyright \
+ install-license install-copying install-man install-man1 install-man7 uninstall