Skip to content

Commit

Permalink
Add uninstall target and remove makefile if options where invalid
Browse files Browse the repository at this point in the history
* Use `builddir` instead of `build` as the build directory
  • Loading branch information
loathingKernel committed Mar 1, 2024
1 parent 211f5f1 commit 228dc1e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var
build
builddir
__pycache__
.ref
18 changes: 15 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)


Expand Down
16 changes: 10 additions & 6 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

{
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 228dc1e

Please sign in to comment.