diff --git a/Makefile b/Makefile index 611b1c3..4f796dd 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,18 @@ +# Common prefix for installation directories, following GNU conventions. +# See https://www.gnu.org/prep/standards/html_node/Directory-Variables.html for details. + +# Installation prefix +PREFIX = /usr/local +DATAROOTDIR = $(PREFIX)/share + +# Where to put the executable. +BINDIR = $(PREFIX)/bin +# Where to put the manual pages. +MANDIR = $(DATAROOTDIR)/man + TARGET = kabmat SRC_DIR = src BUILD_DIR = bin -INSTALL_DIR = /usr/bin/ DATA_DIR = ~/.local/share/kabmat CFLAGS = -std=c++17 -Wall -Wextra @@ -31,7 +42,14 @@ clean: .PHONY: install install: - $(MAKE) - sudo cp ./$(TARGET) $(INSTALL_DIR) - sudo mkdir -p /usr/local/man/man1 - sudo cp ./doc/kabmat.1 /usr/local/man/man1/ + mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 + cp ./$(TARGET) $(DESTDIR)$(BINDIR) + chmod 0755 $(DESTDIR)$(BINDIR)/$(TARGET) + cp ./doc/kabmat.1 $(DESTDIR)$(MANDIR)/man1 + chmod 0644 $(DESTDIR)$(MANDIR)/man1/kabmat.1 + $(MAKE) clean + +.PHONY: uninstall +uninstall: + rm $(DESTDIR)$(BINDIR)/$(TARGET) + rm $(DESTDIR)$(MANDIR)/man1/kabmat.1