31 lines
964 B
Makefile
31 lines
964 B
Makefile
.PHONY: all build test clean install sync-version pkg-deb
|
|
|
|
BINARY_NAME=bird-exporter
|
|
INSTALL_PATH=/usr/local/bin
|
|
|
|
all: test build
|
|
|
|
build:
|
|
go build -o $(BINARY_NAME) ./cmd/bird-exporter/
|
|
|
|
test:
|
|
go test -v ./cmd/bird-exporter/
|
|
|
|
clean:
|
|
rm -f $(BINARY_NAME)
|
|
[ -d debian/go ] && chmod -R +w debian/go || true
|
|
rm -rf debian/.debhelper debian/.gocache debian/go debian/$(BINARY_NAME) debian/files debian/*.substvars debian/debhelper-build-stamp
|
|
rm -f ../$(BINARY_NAME)_*.deb ../$(BINARY_NAME)_*.changes ../$(BINARY_NAME)_*.buildinfo
|
|
|
|
install: build
|
|
install -m 755 $(BINARY_NAME) $(INSTALL_PATH)/$(BINARY_NAME)
|
|
|
|
sync-version:
|
|
@echo "Syncing version from debian/changelog to main.go..."
|
|
@VERSION=$$(head -1 debian/changelog | sed -n 's/.*(\([^)]*\)).*/\1/p'); \
|
|
sed -i 's/^const Version = ".*"/const Version = "'"$$VERSION"'"/' cmd/bird-exporter/main.go; \
|
|
echo "Updated Version const to: $$VERSION"
|
|
|
|
pkg-deb: sync-version
|
|
fakeroot dpkg-buildpackage -us -uc -b
|