GOCMD := wails
BINARY := goldberry
PREFIX := /usr/local
BINDIR := ${PREFIX}/bin
DATAROOTDIR := ${PREFIX}/share
MANDIR := ${DATAROOTDIR}/man
MAN1DIR := ${MANDIR}/man1

.PHONY: build
build:
	${GOCMD} build

.PHONY: install
install: install-bin install-man clean

.PHONY: install-man
install-man: ${BINARY}.1
	gzip -k ./${BINARY}.1
	install -d ${DESTDIR}${MAN1DIR}
	install -m 0644 ./${BINARY}.1.gz ${DESTDIR}${MAN1DIR}

.PHONY: install-bin
install-bin: build/goldberry
	install -d ${DESTDIR}${BINDIR}
	install -m 0755 ./build/${BINARY} ${DESTDIR}${BINDIR}

.PHONY: clean
clean: 
	rm -f ./${BINARY}.1.gz 2> /dev/null
	rm -f ./build/${BINARY} 2> /dev/null

.PHONY: uninstall
uninstall: clean
	rm -f ${DESTDIR}${MAN1DIR}/${BINARY}.1.gz
	rm -f ${DESTDIR}${BINDIR}/${BINARY}

