.POSIX:
.SUFFIXES: .tmpl.ha .ha
HARE=hare

DESTDIR=
PREFIX=/usr/local
SRCDIR=$(PREFIX)/src
HARESRCDIR=$(SRCDIR)/hare
THIRDPARTYDIR=$(HARESRCDIR)/third-party

default: templates bootstrap subcommand

bootstrap:
	$(HARE) build cmd/bootstrap
.PHONY: bootstrap
subcommand:
	$(HARE) build cmd/subcommand
.PHONY: subcommand

templates: \
	getopt/completion/bash.tmpl.ha

.ha.tmpl.ha:
	hare tool gentmpl -o $@ $<

check:
	$(HARE) test

install: templates
	mkdir -p $(DESTDIR)$(THIRDPARTYDIR)/getopt/completion
	install -m644 getopt/completion/*.ha $(DESTDIR)$(THIRDPARTYDIR)/getopt/completion

uninstall:
	rm -rf $(DESTDIR)$(THIRDPARTYDIR)/getopt/completion
