From d6b5a64859ae2a7d0fd6171273f503c26d35ba38 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 28 Oct 2014 11:18:49 +0100 Subject: makefile: add install and unstall rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Makefile b/Makefile index be3eef1..44d9c23 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,10 @@ DOCDIR ?= $(DATADIR)/doc INFODIR ?= $(DATADIR)/info # The license base path including prefix LICENSEDIR ?= $(DATADIR)/licenses + +# The /dev directory that should be compiled into the program DEVDIR = /dev +# The /sys directory that should be compiled into the program SYSDIR = /sys # The name of the command as it should be installed @@ -48,6 +51,7 @@ STD = -std=gnu99 DEFS = -D'DEVDIR="$(DEVDIR)"' -D'SYSDIR="$(SYSDIR)"' + .PHONY: all all: cmd @@ -63,6 +67,42 @@ bin/scrotty: obj/scrotty.o $(CC) $(STD) $(OPTIMISE) $(WARN) $(LDFLAGS) -o $@ $^ +.PHONY: install +install: install-base + +.PHONY: install-all +install-all: install-base + +.PHONY: install-base +install-base: install-cmd install-copyright + +.PHONY: install-cmd +install-cmd: bin/scrotty + install -dm755 -- "$(DESTDIR)$(BINDIR)" + install -m755 $< -- "$(DESTDIR)$(BINDIR)/$(COMMAND)" + +.PHONY: install-copyright +install-copyright: install-copying install-license + +.PHONY: install-copying +install-copying: + install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PACKAGE)" + install -m644 COPYING -- "$(DESTDIR)$(LICENSEDIR)/$(PACKAGE)/COPYING" + +.PHONY: install-license +install-license: + install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PACKAGE)" + install -m644 LICENSE -- "$(DESTDIR)$(LICENSEDIR)/$(PACKAGE)/LICENSE" + + +.PHONY: uninstall +uninstall: + -rm -- "$(DESTDIR)$(BINDIR)/$(COMMAND)" + -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PACKAGE)/COPYING" + -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PACKAGE)/LICENSE" + -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PACKAGE)" + + .PHONY: clean clean: -rm -r bin obj scrotty.{info,pdf,ps,dvi} *.su src/*.su -- cgit v1.2.3-70-g09d2