From 8a25b5175bdc2d669d33e757751c3dd21c481e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Sat, 7 Mar 2020 20:28:59 +0100 Subject: [PATCH] Follow GNU coding standards --- Makefile | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index ce3046e..4a2af5e 100644 --- a/Makefile +++ b/Makefile @@ -21,43 +21,46 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # -ifneq ($(PREFIX),) -prefix ?= $(PREFIX) -endif -ifneq ($(DESTDIR),) -prefix ?= /usr -endif -ifneq ($(shell id -u),0) +ifneq ($(if $(DESTDIR),0,$(shell id -u)),0) +# If the current user is not root and DESTDIR is not set, install to user home prefix ?= $(HOME)/.local else prefix ?= /usr/local endif - -bindir ?= bin -mandir ?= share/man/man1 +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/bin +mandir ?= $(prefix)/share/man +man1dir ?= $(mandir)/man1 help: @echo - @echo "* Run 'make install' to install the script to $(prefix)/$(bindir)" + @echo "* Run 'make install' to install the script to $(bindir)" @echo "* Run 'make uninstall' to uninstall the script again." @echo "* You can pick a different install prefix than $(prefix) with" @echo " make prefix=/other/prefix install" @echo -install: $(DESTDIR)$(prefix)/$(bindir)/git-archive-all $(DESTDIR)$(prefix)/$(mandir)/git-archive-all.1.gz +all: + +clean: + +install: $(DESTDIR)$(bindir)/git-archive-all $(DESTDIR)$(man1dir)/git-archive-all.1.gz uninstall: - rm $(DESTDIR)$(prefix)/$(bindir)/git-archive-all - rm -f $(DESTDIR)$(prefix)/$(mandir)/git-archive-all.1.gz + rm $(DESTDIR)$(bindir)/git-archive-all + rm -f $(DESTDIR)$(man1dir)/git-archive-all.1* + +check: + ./test.bats -$(DESTDIR)$(prefix)/$(bindir)/git-archive-all: git-archive-all $(DESTDIR)$(prefix)/$(bindir) - install -m755 $< $(DESTDIR)$(prefix)/$(bindir) +$(DESTDIR)$(bindir)/git-archive-all: git-archive-all $(DESTDIR)$(bindir) + install -m755 $< $(DESTDIR)$(bindir) -$(DESTDIR)$(prefix)/$(mandir)/git-archive-all.1.gz: git-archive-all $(DESTDIR)$(prefix)/$(mandir) +$(DESTDIR)$(man1dir)/git-archive-all.1.gz: git-archive-all $(DESTDIR)$(man1dir) pod2man -r "" -c "Git Manual" $< > $(basename $@) && gzip -9fn $(basename $@) -$(DESTDIR)$(prefix)/$(bindir) $(DESTDIR)$(prefix)/$(mandir): +$(DESTDIR)$(bindir) $(DESTDIR)$(man1dir): mkdir -p $@ -.PHONY: install uninstall +.PHONY: all check clean help install uninstall