DESTDIR ?= /
PREFIX  ?= /usr/local

.PHONY: all
all: acmeleaf acmeleaf-mkaccount txt

.PHONY: txt
txt:
	$(MAKE) -C ./man/

.PHONY: acmeleaf
acmeleaf:
	go build $(GOFLAGS) -o acmeleaf ./cmd/acmeleaf/

.PHONY: acmeleaf-mkaccount
acmeleaf-mkaccount:
	go build $(GOFLAGS) -o acmeleaf-mkaccount ./cmd/acmeleaf-mkaccount/

.PHONY: install
install: all
	install -Dm755 acmeleaf 			-t ${DESTDIR}${PREFIX}/bin/
	install -Dm755 acmeleaf-mkaccount		-t ${DESTDIR}${PREFIX}/bin/
	install -Dm644 man/acmeleaf.1			-t ${DESTDIR}${PREFIX}/share/man/man1/
	install -Dm644 man/acmeleaf-mkaccount.1		-t ${DESTDIR}${PREFIX}/share/man/man1/

.PHONY: clean
clean:
	rm -f acmeleaf
