From e516aa01229530b7de278040bcd1b9c944d1d8a2 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 3 May 2013 01:56:30 +0400 Subject: [PATCH] Makefiles: add install target Note to package maintainers: 1 Yes we do support DESTDIR. 2 From packaging scripts, use something like this: make install DESTDIR=$RPM_BUILD_ROOT PREFIX=/usr (v2: add PREFIX, install to /usr/local not /usr by default) (v3: fix criu man section -- it is 8 not 1) Signed-off-by: Kir Kolyshkin Signed-off-by: Pavel Emelyanov --- Documentation/Makefile | 8 +++++++- Makefile | 11 +++++++++++ Makefile.inc | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 011439345..132be6bf0 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -6,6 +6,7 @@ XMLTO := xmlto SRC += criu.txt MANS := $(patsubst %.txt,%.8,$(SRC)) +MAN8DIR := $(MANDIR)/man8 all: $(MANS) @@ -19,4 +20,9 @@ clean: $(Q) rm -f ./*.xml $(Q) rm -f ./*.1 -.PHONY: clean +install: $(MANS) + $(E) " INSTALL " $(MANS) + $(Q) mkdir -p $(DESTDIR)$(MAN8DIR) + $(Q) install $(MANS) $(DESTDIR)$(MAN8DIR) + +.PHONY: clean install diff --git a/Makefile b/Makefile index c459ce5b8..cbe5a9732 100644 --- a/Makefile +++ b/Makefile @@ -201,12 +201,23 @@ criu-$(CRTOOLSVERSION).tar.bz2: v$(CRTOOLSVERSION) | bzip2 > $@ .PHONY: dist tar +install: $(PROGRAM) install-man + $(E) " INSTALL " $(PROGRAM) + $(Q) mkdir -p $(DESTDIR)$(SBINDIR) + $(Q) install -m 755 $(PROGRAM) $(DESTDIR)$(SBINDIR) + +install-man: + $(Q) $(MAKE) -C Documentation install + +.PHONY: install install-man + help: @echo ' Targets:' @echo ' all - Build all [*] targets' @echo ' * criu - Build criu' @echo ' zdtm - Build zdtm test-suite' @echo ' docs - Build documentation' + @echo ' install - Install binary and man page' @echo ' clean - Clean everything' @echo ' tags - Generate tags file (ctags)' @echo ' cscope - Generate cscope database' diff --git a/Makefile.inc b/Makefile.inc index f11cdcccd..23b4d9e97 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -9,3 +9,8 @@ else endif export E Q + +# Installation paths +PREFIX := /usr/local +SBINDIR := $(PREFIX)/sbin +MANDIR := $(PREFIX)/share/man