diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-02-26 18:48:14 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-02-26 18:52:16 +0100 |
commit | 505542e73e230df4cc0c1c9cab874fcb4d6ba4ef (patch) | |
tree | 7f5341f27649d27e129be07d23edc32faa96d4bc /Makefile | |
parent | a604073ded8a1baf30877fa5914bad903adfdcd9 (diff) | |
download | pass-505542e73e230df4cc0c1c9cab874fcb4d6ba4ef.tar.gz pass-505542e73e230df4cc0c1c9cab874fcb4d6ba4ef.tar.bz2 pass-505542e73e230df4cc0c1c9cab874fcb4d6ba4ef.zip |
Modernize makefile
Diffstat (limited to '')
-rw-r--r-- | Makefile | 59 |
1 files changed, 32 insertions, 27 deletions
@@ -6,23 +6,29 @@ MANDIR ?= $(PREFIX)/share/man PLATFORMFILE := src/platform/$(shell uname | cut -d _ -f 1 | tr '[:upper:]' '[:lower:]').sh -BASHCOMP_PATH ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions -ZSHCOMP_PATH ?= $(DESTDIR)$(PREFIX)/share/zsh/site-functions -FISHCOMP_PATH ?= $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d +BASHCOMPDIR ?= $(PREFIX)/share/bash-completion/completions +ZSHCOMPDIR ?= $(PREFIX)/share/zsh/site-functions +FISHCOMPDIR ?= $(PREFIX)/share/fish/vendor_completions.d -ifeq ($(FORCE_ALL),1) -FORCE_BASHCOMP := 1 -FORCE_ZSHCOMP := 1 -FORCE_FISHCOMP := 1 +ifneq ($(WITH_ALLCOMP),) +WITH_BASHCOMP := $(WITH_ALLCOMP) +WITH_ZSHCOMP := $(WITH_ALLCOMP) +WITH_FISHCOMP := $(WITH_ALLCOMP) endif -ifneq ($(strip $(wildcard $(BASHCOMP_PATH))),) -FORCE_BASHCOMP := 1 +ifeq ($(WITH_BASHCOMP),) +ifneq ($(strip $(wildcard $(BASHCOMPDIR))),) +WITH_BASHCOMP := yes endif -ifneq ($(strip $(wildcard $(ZSHCOMP_PATH))),) -FORCE_ZSHCOMP := 1 endif -ifneq ($(strip $(wildcard $(FISHCOMP_PATH))),) -FORCE_FISHCOMP := 1 +ifeq ($(WITH_ZSHCOMP),) +ifneq ($(strip $(wildcard $(ZSHCOMPDIR))),) +WITH_ZSHCOMP := yes +endif +endif +ifeq ($(WITH_FISHCOMP),) +ifneq ($(strip $(wildcard $(FISHCOMPDIR))),) +WITH_FISHCOMP := yes +endif endif all: @@ -30,34 +36,33 @@ all: install-common: @install -v -d "$(DESTDIR)$(MANDIR)/man1" && install -m 0644 -v man/pass.1 "$(DESTDIR)$(MANDIR)/man1/pass.1" - - @[ "$(FORCE_BASHCOMP)" = "1" ] && install -v -d "$(DESTDIR)$(BASHCOMP_PATH)" && install -m 0644 -v src/completion/pass.bash-completion "$(DESTDIR)$(BASHCOMP_PATH)/pass" || true - @[ "$(FORCE_ZSHCOMP)" = "1" ] && install -v -d "$(DESTDIR)$(ZSHCOMP_PATH)" && install -m 0644 -v src/completion/pass.zsh-completion "$(DESTDIR)$(ZSHCOMP_PATH)/_pass" || true - @[ "$(FORCE_FISHCOMP)" = "1" ] && install -v -d "$(DESTDIR)$(FISHCOMP_PATH)" && install -m 0644 -v src/completion/pass.fish-completion "$(DESTDIR)$(FISHCOMP_PATH)/pass.fish" || true + @[ "$(WITH_BASHCOMP)" = "yes" ] || exit 0; install -v -d "$(DESTDIR)$(BASHCOMPDIR)" && install -m 0644 -v src/completion/pass.bash-completion "$(DESTDIR)$(BASHCOMPDIR)/pass" + @[ "$(WITH_ZSHCOMP)" = "yes" ] || exit 0; install -v -d "$(DESTDIR)$(ZSHCOMPDIR)" && install -m 0644 -v src/completion/pass.zsh-completion "$(DESTDIR)$(ZSHCOMPDIR)/_pass" + @[ "$(WITH_FISHCOMP)" = "yes" ] || exit 0; install -v -d "$(DESTDIR)$(FISHCOMPDIR)" && install -m 0644 -v src/completion/pass.fish-completion "$(DESTDIR)$(FISHCOMPDIR)/pass.fish" ifneq ($(strip $(wildcard $(PLATFORMFILE))),) install: install-common @install -v -d "$(DESTDIR)$(LIBDIR)/password-store" && install -m 0644 -v "$(PLATFORMFILE)" "$(DESTDIR)$(LIBDIR)/password-store/platform.sh" + @install -v -d "$(DESTDIR)$(LIBDIR)/password-store/extensions" @install -v -d "$(DESTDIR)$(BINDIR)/" - sed 's:.*PLATFORM_FUNCTION_FILE.*:source "$(LIBDIR)/password-store/platform.sh":;s:^SYSTEM_EXTENSION_DIR=.*:SYSTEM_EXTENSION_DIR="$(LIBDIR)/password-store/extensions":' src/password-store.sh > "$(DESTDIR)$(BINDIR)/pass" - @chmod 0755 "$(DESTDIR)$(BINDIR)/pass" + @trap 'rm -f src/.pass' EXIT; sed 's:.*PLATFORM_FUNCTION_FILE.*:source "$(LIBDIR)/password-store/platform.sh":;s:^SYSTEM_EXTENSION_DIR=.*:SYSTEM_EXTENSION_DIR="$(LIBDIR)/password-store/extensions":' src/password-store.sh > src/.pass && \ + install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v src/.pass "$(DESTDIR)$(BINDIR)/pass" else install: install-common - @install -v -d "$(DESTDIR)$(BINDIR)/" - sed '/PLATFORM_FUNCTION_FILE/d;s:^SYSTEM_EXTENSION_DIR=.*:SYSTEM_EXTENSION_DIR="$(LIBDIR)/password-store/extensions":' src/password-store.sh > "$(DESTDIR)$(BINDIR)/pass" - @chmod 0755 "$(DESTDIR)$(BINDIR)/pass" + @install -v -d "$(DESTDIR)$(LIBDIR)/password-store/extensions" + @trap 'rm -f src/.pass' EXIT; sed '/PLATFORM_FUNCTION_FILE/d;s:^SYSTEM_EXTENSION_DIR=.*:SYSTEM_EXTENSION_DIR="$(LIBDIR)/password-store/extensions":' src/password-store.sh > src/.pass && \ + install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v src/.pass "$(DESTDIR)$(BINDIR)/pass" endif uninstall: @rm -vrf \ "$(DESTDIR)$(BINDIR)/pass" \ - "$(DESTDIR)$(LIBDIR)/password-store/" \ + "$(DESTDIR)$(LIBDIR)/password-store" \ "$(DESTDIR)$(MANDIR)/man1/pass.1" \ - "$(DESTDIR)$(BASHCOMP_PATH)/pass" \ - "$(DESTDIR)$(ZSHCOMP_PATH)/_pass" \ - "$(DESTDIR)$(FISHCOMP_PATH)/pass.fish" - @rmdir "$(DESTDIR)$(LIBDIR)/password-store/" 2>/dev/null || true + "$(DESTDIR)$(BASHCOMPDIR)/pass" \ + "$(DESTDIR)$(ZSHCOMPDIR)/_pass" \ + "$(DESTDIR)$(FISHCOMPDIR)/pass.fish" TESTS = $(sort $(wildcard tests/t[0-9][0-9][0-9][0-9]-*.sh)) |