From 243709cee79cb29877660104dfc1fcc1b3ce6078 Mon Sep 17 00:00:00 2001
From: Paper <paper@tilde.institute>
Date: Tue, 4 Feb 2020 18:30:00 +0100
Subject: [PATCH 1/2] Fix makefile installing pb.d to root

On systems without bash completion, CPLDIR is empty, but the makefile
still tries to install the bash completion and fails.
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index d5bce0a..f1ad383 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ install:
 	@mkdir -p $(MANDIR)/man1
 	@cp -f pb.1 $(MANDIR)/man1/pb.1
 	@chmod 644 $(MANDIR)/man1/pb.1
-ifdef CPLDIR
+ifeq ($(CPLDIR),)
 	@echo Installing the command completion to $(CPLDIR)
 	@mkdir -p $(CPLDIR)
 	@cp -f pb.d $(CPLDIR)/pb
@@ -38,7 +38,7 @@ uninstall:
 	@rm -f $(BINDIR)/pb
 	@echo Removing the manual page from $(MANDIR)/man1
 	@rm -f $(BINDIR)/man1/pb.1
-ifdef CPLDIR
+ifeq ($(CPLDIR),)
 	@echo Removing the command completion from $(CPLDIR)
 	@rm -f $(CPLDIR)/pb
 endif

From 522324d1ed5bb2ace05e4d0394d98feffa9cc640 Mon Sep 17 00:00:00 2001
From: Paper <paper@tilde.institute>
Date: Tue, 4 Feb 2020 18:30:00 +0100
Subject: [PATCH 2/2] Use correct tools in makefile

---
 Makefile | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index f1ad383..c7667ed 100644
--- a/Makefile
+++ b/Makefile
@@ -19,13 +19,9 @@ endif
 
 install:
 	@echo Installing the executable to $(BINDIR)
-	@mkdir -p $(BINDIR)
-	@cp -f pb $(BINDIR)/pb
-	@chmod 755 $(BINDIR)/pb
+	@install -D -m 0755 pb $(BINDIR)/pb
 	@echo Installing the manual page to $(MANDIR)/man1
-	@mkdir -p $(MANDIR)/man1
-	@cp -f pb.1 $(MANDIR)/man1/pb.1
-	@chmod 644 $(MANDIR)/man1/pb.1
+	@install -D -m 0644 pb.1 $(MANDIR)/man1/pb.1
 ifeq ($(CPLDIR),)
 	@echo Installing the command completion to $(CPLDIR)
 	@mkdir -p $(CPLDIR)