From 228dc1e234b2da31e75899fe378f60c204c06c27 Mon Sep 17 00:00:00 2001 From: Stelios Tsampas Date: Fri, 1 Mar 2024 13:52:12 +0200 Subject: [PATCH] Add `uninstall` target and remove makefile if options where invalid * Use `builddir` instead of `build` as the build directory --- .gitignore | 2 +- Makefile.in | 18 +++++++++++++++--- configure.sh | 16 ++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 117f66df1..95bd9cc29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ var -build +builddir __pycache__ .ref diff --git a/Makefile.in b/Makefile.in index 62ca7522f..6fdd2dd98 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,8 @@ +# This is different from ULWGL to facilitate user installations +# If this is changed to ULWGL (uppercase), `uninstall` target will also remove the SLR directory PROJECT := ulwgl -OBJDIR := build +OBJDIR := builddir PREFIX ?= /usr BINDIR := $(PREFIX)/bin @@ -89,13 +91,23 @@ $(OBJDIR): .PHONY: clean clean: - rm -rf $(OBJDIR) + $(info Cleaning "$(OBJDIR)" build directory) + @rm -rf -v $(OBJDIR) + + +.PHONY: uninstall +# NEVER use a wildcard here +uninstall: + $(info Removing $(PROJECT) files in $(DESTDIR)$(BINDIR)) + @rm -rf -v --preserve-root=all $(DESTDIR)$(BINDIR)/ulwgl-run + $(info Removing $(PROJECT) directory in $(DESTDIR)$(DATADIR)) + @rm -rf -v --preserve-root=all $(DESTDIR)$(DATADIR)/$(PROJECT) .PHONY: user-install user-install: $(info :: ---) - $(info :: Installed under user-only location $(DATADIR)/$(PROJECT)) + $(info :: Installed under user-only location "$(DATADIR)/$(PROJECT)") $(info :: To run you need to make sure "$(BINDIR)" is in your PATH) diff --git a/configure.sh b/configure.sh index 81cf08777..976ee8686 100755 --- a/configure.sh +++ b/configure.sh @@ -48,8 +48,16 @@ function escape_for_make() { } function configure() { + ## Checks before writing config + if [[ -n "$arg_user_install" ]]; then + arg_prefix="$HOME/.local" + fi + + if [[ $arg_prefix != $(realpath "$arg_prefix") ]]; then + die "PREFIX needs to be an absolute path" + fi + ## Write out config - # Don't die after this point or we'll have rather unhelpfully deleted the Makefile [[ ! -e "$MAKEFILE" ]] || rm "$MAKEFILE" { @@ -58,7 +66,6 @@ function configure() { echo "" if [[ -n "$arg_user_install" ]]; then echo "USERINSTALL := xtrue" - arg_prefix="$HOME/.local" fi # Prefix was specified, baking it into the Makefile @@ -120,9 +127,6 @@ function parse_args() { if [[ -n $arg_user_install ]]; then die "--prefix cannot be used with --user-install" fi - if [[ $val != $(realpath "$val") ]]; then - die "PREFIX needs to be an absolute path" - fi arg_prefix="$val" val_used=1 elif [[ $arg = --user-install ]]; then @@ -173,7 +177,7 @@ usage() { "$1" "" "$1" " --prefix=PREFIX Install architecture-independent files in PREFIX" "$1" " [/usr]" - "$1" " --user-install Install under user-only location" + "$1" " --user-install Install under user-only location. Incompatible with --prefix" "$1" " [$HOME/.local]" "$1" "" exit 1;