jdkman 0.5.3

Personalised sdkman frontend specialized for Java
Documentation
# https://tech.davis-hansson.com/p/make/
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules

ifeq ($(origin .RECIPEPREFIX), undefined)
  $(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >

APP := jdkman

DESTDIR ?=
PREFIX  ?= /usr/local
CARGOFLAGS ?=


# generate release build
all: build
build: target/release/$(APP)

# install release build to local cargo bin directory
install: $(DESTDIR)$(PREFIX)/bin/$(APP)

# Remove installed binary
uninstall:
> -rm -- "$(DESTDIR)$(PREFIX)/bin/$(APP)"

# development builds
check: target/debug/$(APP)
test: .cargoinstalled
> cargo test --all --all-targets --all-features

# clean build output
clean: .cargoinstalled
> cargo clean

.PHONY: all build clean install uninstall check test

### build targets

target/debug/$(APP): .cargoinstalled Cargo.toml Cargo.lock $(shell find . \( -path './src*' -or -path './crates*' \) -type f)
> cargo build --bin $(APP)

target/release/$(APP): .cargoinstalled Cargo.toml Cargo.lock $(shell find . \( -path './src*' -or -path './crates*' \) -type f)
> RUSTFLAGS="-C link-arg=-s -C opt-level=3 -C target-cpu=native --emit=asm" cargo build $(CARGOFLAGS) --package $(APP) --release

$(DESTDIR)$(PREFIX)/bin/$(APP): target/release/$(APP)
> install -m755 -- target/release/$(APP) "$(DESTDIR)$(PREFIX)/bin/"

.cargoinstalled:
> @if ! command -v cargo 2> /dev/null
> @then
>   @echo "Cargo is not installed. Please visit 'https://rustup.rs/' and follow their instructions, or try to run 'curl --proto \"=https\" --tlsv1.2 -sSf https://sh.rustup.rs | sh'"
>   @exit 1
> @fi
> touch .cargoinstalled