Files
lazyntfy/Makefile
T

64 lines
1.6 KiB
Makefile
Raw Normal View History

BINARY := lazyntfy
PREFIX ?= $(HOME)/.local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man/man1
DOCDIR ?= $(PREFIX)/share/doc/$(BINARY)
DESTDIR ?=
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' | grep . || echo 0.1.0)
TOPIC ?= alerts
GO ?= go
GOFLAGS ?= -trimpath
LDFLAGS := -X main.version=$(VERSION)
.PHONY: all build install uninstall man test vet fmt run deb arch clean
all: build
build:
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BINARY) ./cmd/lazyntfy
# System-wide install: sudo make install PREFIX=/usr/local
# Staged install: make install DESTDIR=/tmp/pkg PREFIX=/usr
install: build
install -Dm755 $(BINARY) "$(DESTDIR)$(BINDIR)/$(BINARY)"
install -Dm644 man/lazyntfy.1 "$(DESTDIR)$(MANDIR)/lazyntfy.1"
install -Dm644 LICENSE "$(DESTDIR)$(DOCDIR)/copyright"
install -Dm644 README.md "$(DESTDIR)$(DOCDIR)/README.md"
uninstall:
rm -f "$(DESTDIR)$(BINDIR)/$(BINARY)" "$(DESTDIR)$(MANDIR)/lazyntfy.1"
rm -rf "$(DESTDIR)$(DOCDIR)"
man:
install -Dm644 man/lazyntfy.1 "$(DESTDIR)$(MANDIR)/lazyntfy.1"
test:
$(GO) test ./...
vet:
$(GO) vet ./...
fmt:
gofmt -w .
run: build
./$(BINARY) $(TOPIC)
# Build a Debian/Ubuntu package. -d skips build-dependency checks so the
# package can also be built on a machine without golang-go installed as a
# distro package.
deb:
dpkg-buildpackage -us -uc -b -d
mkdir -p dist
mv -f ../$(BINARY)_*_*.deb ../$(BINARY)_*_*.changes ../$(BINARY)_*_*.buildinfo dist/ 2>/dev/null || true
@echo " packages written to dist/"
arch:
cd packaging/archlinux && makepkg -f
clean:
rm -f $(BINARY)
rm -rf dist
-$(MAKE) -f debian/rules clean