# Makefile for tuxrecord2
#
# tuxrecord2 is written in Rust and built with Cargo; this Makefile is a
# convenience wrapper around the common Cargo commands and provides
# system-wide install/uninstall targets.

CARGO   ?= cargo

PREFIX  ?= /usr/local
BINDIR   = $(PREFIX)/bin

BINARY   = tuxrecord2
RELEASE  = target/release/$(BINARY)

all: release

release:
	$(CARGO) build --release

debug:
	$(CARGO) build

test:
	$(CARGO) test

fmt:
	$(CARGO) fmt

lint:
	$(CARGO) clippy -- -D warnings

install: release
	install -d $(DESTDIR)$(BINDIR)
	install -m 755 $(RELEASE) $(DESTDIR)$(BINDIR)/$(BINARY)

uninstall:
	rm -f $(DESTDIR)$(BINDIR)/$(BINARY)

clean:
	$(CARGO) clean

.PHONY: all release debug test fmt lint install uninstall clean
