mirror of
https://tildegit.org/tomasino/pb.git
synced 2024-11-20 03:25:54 +01:00
makefile using more standard variables and improved bash completion tests
This commit is contained in:
parent
f55024a950
commit
adbabea22a
58
Makefile
58
Makefile
@ -1,42 +1,50 @@
|
|||||||
PREFIX ?= /usr/local
|
# Install to /usr/local unless otherwise specified, such as `make PREFIX=/app`
|
||||||
BINDIR ?= $(PREFIX)/bin
|
PREFIX?=/usr/local
|
||||||
MANDIR ?= $(PREFIX)/share/man
|
|
||||||
|
# What to run to install various files
|
||||||
|
INSTALL?=install
|
||||||
|
# Run to install the actual binary
|
||||||
|
INSTALL_PROGRAM=$(INSTALL) -Dm 755
|
||||||
|
# Run to install application data, with differing permissions
|
||||||
|
INSTALL_DATA=$(INSTALL) -Dm 644
|
||||||
|
|
||||||
|
# Directories into which to install the various files
|
||||||
|
bindir=$(DESTDIR)$(PREFIX)/bin
|
||||||
|
sharedir=$(DESTDIR)$(PREFIX)/share
|
||||||
|
|
||||||
# Attempt to find bash completion dir in order of preference
|
# Attempt to find bash completion dir in order of preference
|
||||||
ifneq ($(wildcard /etc/bash_completion.d/.),)
|
ifneq ($(wildcard /etc/bash_completion.d/.),)
|
||||||
CPLDIR ?= /etc/bash_completion.d
|
cpldir ?= /etc/bash_completion.d
|
||||||
endif
|
endif
|
||||||
|
|
||||||
HAS_BREW := $(shell command -v brew 2> /dev/null)
|
HAS_BREW := $(shell command -v brew 2> /dev/null)
|
||||||
ifdef HAS_BREW
|
ifdef HAS_BREW
|
||||||
CPLDIR ?= $$(brew --prefix)/etc/bash_completion.d
|
cpldir ?= $$(brew --prefix)/etc/bash_completion.d
|
||||||
endif
|
endif
|
||||||
|
|
||||||
HAS_PKGCONFIG := $(shell command -v pkg-config 2> /dev/null)
|
HAS_PKGCONFIG := $(shell command -v pkg-config 2> /dev/null)
|
||||||
ifdef HAS_PKGCONFIG
|
ifdef HAS_PKGCONFIG
|
||||||
CPLDIR ?= $$(pkg-config --variable=completionsdir bash-completion 2> /dev/null)
|
cpldir ?= $$(pkg-config --variable=completionsdir bash-completion 2> /dev/null)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
install:
|
help:
|
||||||
@echo Installing the executable to $(BINDIR)
|
@echo "targets:"
|
||||||
@install -D -m 0755 pb $(BINDIR)/pb
|
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
|
||||||
@echo Installing the manual page to $(MANDIR)/man1
|
| sed -n 's/^\(.*\): \(.*\)##\(.*\)/ \1|\3/p' \
|
||||||
@install -D -m 0644 pb.1 $(MANDIR)/man1/pb.1
|
| column -t -s '|'
|
||||||
ifeq ($(CPLDIR),)
|
|
||||||
@echo Installing the command completion to $(CPLDIR)
|
install: pb pb.1 ## system install
|
||||||
@mkdir -p $(CPLDIR)
|
$(INSTALL_PROGRAM) pb $(bindir)/pb
|
||||||
@cp -f pb.d $(CPLDIR)/pb
|
$(INSTALL_DATA) pb.1 $(sharedir)/man/man1/pb.1
|
||||||
@chmod 644 $(CPLDIR)/pb
|
ifdef cpldir
|
||||||
|
$(INSTALL_DATA) pb.d $(cpldir)/pb
|
||||||
endif
|
endif
|
||||||
|
|
||||||
uninstall:
|
uninstall: ## system uninstall
|
||||||
@echo Removing the executable from $(BINDIR)
|
rm -f $(bindir)/pb
|
||||||
@rm -f $(BINDIR)/pb
|
rm -f $(sharedir)/man/man1/pb.1
|
||||||
@echo Removing the manual page from $(MANDIR)/man1
|
ifdef cpldir
|
||||||
@rm -f $(BINDIR)/man1/pb.1
|
rm -f $(cpldir)/pb
|
||||||
ifeq ($(CPLDIR),)
|
|
||||||
@echo Removing the command completion from $(CPLDIR)
|
|
||||||
@rm -f $(CPLDIR)/pb
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: install uninstall
|
.PHONY: install uninstall help
|
||||||
|
Loading…
Reference in New Issue
Block a user