bombadillo/Makefile

46 lines
1.1 KiB
Makefile
Raw Normal View History

BINARY := bombadillo
PREFIX := /usr/local
MANPREFIX := ${PREFIX}/share/man
2019-10-14 23:29:40 +00:00
# Use a dateformat rather than -I flag since OSX
# does not support -I. It also doesn't support
# %:z - so settle for %z.
BUILD_TIME := ${shell date "+%Y-%m-%dT%H:%M%z"}
2019-10-14 23:29:40 +00:00
# If VERSION is empty or not deffined use the contents of the VERSION file
VERSION := ${shell git describe --tags 2> /dev/null}
2019-10-14 23:29:40 +00:00
ifndef VERSION
VERSION := ${shell cat ./VERSION}
2019-10-14 23:29:40 +00:00
endif
LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}"
2019-10-14 23:29:40 +00:00
.PHONY: build
build:
go build ${LDFLAGS} -o ${BINARY}
2019-10-14 23:29:40 +00:00
.PHONY: install
install: install-bin install-man clean
2019-10-14 23:29:40 +00:00
.PHONY: install-man
install-man: bombadillo.1
gzip -k ./bombadillo.1
install -d ${DESTDIR}${MANPREFIX}/man1
install -m 0644 ./bombadillo.1.gz ${DESTDIR}${MANPREFIX}/man1
.PHONY: install-bin
install-bin: build
install -d ${DESTDIR}${PREFIX}/bin
install -m 0755 ./${BINARY} ${DESTDIR}${PREFIX}/bin/${BINARY}
2019-10-14 23:29:40 +00:00
.PHONY: clean
clean:
go clean
rm -f ./bombadillo.1.gz 2> /dev/null
2019-10-14 23:29:40 +00:00
.PHONY: uninstall
uninstall: clean
rm -f ${DESTDIR}${MANPREFIX}/man1/bombadillo.1.gz
rm -f ${DESTDIR}${PREFIX}/bin/${BINARY}