Support DESTDIR and PREFIX variables in Makefile

* Add support for DESTDIR and PREFIX variables in Makefile.
  PREFIX defaults to /usr and DESTDIR is not defined by default.
* Redefine MANDIR and BINDIR in function of PREFIX and DESTDIR. Note
  that DESTDIR for overriden variables (variables defined via make
  VAR=value construct)
This commit is contained in:
Thomas Preud'homme 2011-10-03 21:47:55 +02:00
parent ee32fa3624
commit 27599168da
1 changed files with 12 additions and 4 deletions

View File

@ -18,6 +18,14 @@ VERSION = $(shell awk 'END { print $$1 }' VERSION)
CFLAGS ?= -Wall -Wextra
CFLAGS += -DVERSION=\"$(VERSION)\"
# Note: assignments are ignored for variable overriden on command line VAR=value
# so DESTDIR is ignored for overriden variables
PREFIX ?= /usr
BINDIR ?= $(PREFIX)/bin
BINDIR := $(DESTDIR)$(BINDIR)
MANDIR ?= $(PREFIX)/share/man
MANDIR := $(DESTDIR)$(MANDIR)
pstack : pstack.c
$(CC) $(CFLAGS) -o pstack pstack.c
@ -26,10 +34,10 @@ clean:
rm -f pstack
install : pstack
mkdir -p $(BINDIR)
install -m 755 pstack $(BINDIR)
mkdir -p $(MANDIR)/man1
install -m 644 man1/pstack.1 $(MANDIR)/man1
mkdir -p "$(BINDIR)"
install -m 755 pstack "$(BINDIR)"
mkdir -p "$(MANDIR)/man1"
install -m 644 man1/pstack.1 "$(MANDIR)/man1"
cvstag:
cvs tag -F $(CVSTAG) .