From 4266e06e1c0962715ee98f79675d6a4c459ddeef Mon Sep 17 00:00:00 2001 From: Malfurious Date: Mon, 2 Aug 2021 16:48:24 -0400 Subject: Rewrite Makefile The Makefile is updated to deal with the single 'git-sonar' file only, now that the others have been merged into it. Additionally, several issues have been fixed with the file, including: * Now easier to override the PREFIX variable (install location) * PWD works properly when running make with sudo * Install now default to system-wide * bin directory now explicitly created if it doesn't exist A specific problem corrected by this patch is that `PREFIX=$HOME/.local make install` on a fresh system will no longer result in the script being copied to the _regular file_ $HOME/.local/bin, because bin did not exist. Signed-off-by: Malfurious --- Makefile | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 7a7e9ec..ef233c9 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,27 @@ -SOURCES=git-sonar sonar-base.sh prompt.zsh prompt.bash fetch.sh -PREFIX=$(HOME)/.local +SOURCE=git-sonar +PREFIX?=/usr/local +PWD=$(shell pwd) + +.PHONY: all install develop all: - @echo 'Simple Install script for *git-sonar* ' - @echo 'For a normal installation for your user only use:' - @echo ' make install' - @echo '' - @echo 'If you want to install *git-sonar* system wide you should change' - @echo 'the prefix' + @echo 'Simple install script for *git-sonar*' @echo '' - @echo ' PREFIX=/usr/local/bin make install' + @echo 'For a normal installation into /usr/local, use:' + @echo ' make install' @echo '' - @echo 'For a development install (symlinking files) do:' + @echo 'For a development install (symlinked files), use:' + @echo ' make develop' @echo '' - @echo ' make develop' - -.PHONY: install develop - -install: $(SOURCES) - @echo 'Installing in ' $(PREFIX)/bin - cp git-sonar $(PREFIX)/bin - cp sonar-base.sh $(PREFIX)/bin - cp prompt.zsh $(PREFIX)/bin - cp prompt.bash $(PREFIX)/bin - cp fetch.sh $(PREFIX)/bin + @echo 'If you want to install *git-sonar* for your user only:' + @echo ' PREFIX=$$HOME/.local make install' +install: $(SOURCE) + @echo 'Installing in' $(PREFIX)/bin '...' + mkdir -p $(PREFIX)/bin + cp $(PWD)/$(SOURCE) $(PREFIX)/bin -develop: $(SOURCES) - @echo 'Symlinking in ' $(PREFIX)/bin - ln -s $(PWD)/git-sonar $(PREFIX)/bin/git-sonar - ln -s $(PWD)/sonar-base.sh $(PREFIX)/bin/sonar-base.sh - ln -s $(PWD)/prompt.zsh $(PREFIX)/bin/prompt.zsh - ln -s $(PWD)/prompt.bash $(PREFIX)/bin/prompt.bash - ln -s $(PWD)/fetch.sh $(PREFIX)/bin/fetch.sh +develop: $(SOURCE) + @echo 'Symlinking in' $(PREFIX)/bin '...' + mkdir -p $(PREFIX)/bin + ln -sf $(PWD)/$(SOURCE) $(PREFIX)/bin -- cgit v1.2.3