Skip to content

Commit

Permalink
Makefile: add target for building release archive
Browse files Browse the repository at this point in the history
  • Loading branch information
tierpod committed Apr 24, 2018
1 parent 99e3636 commit 5a6ee67
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.swp
*.retry
bin
tmp
/bin
/tmp
/release
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
BINARIES := bin/sd-dbus-hooks
NAME := sd-dbus-hooks
DESTDIR := /opt
INSTALLDIR := $(DESTDIR)/$(NAME)

VERSION := $(shell git describe --tags)

LDFLAGS := -ldflags "-X main.version=$(VERSION)"

.PHONY: lint
Expand All @@ -12,10 +13,10 @@ lint:
#go test ./cmd/... ./pkg/...

.PHONY: build
build: lint $(BINARIES)
build: lint bin/$(NAME)

$(BINARIES):
go build -v $(LDFLAGS) -o $@ cmd/$(notdir $@)/*.go
bin/$(NAME):
go build -v $(LDFLAGS) -o $@ cmd/$(NAME)/*.go

.PHONY: clean
clean:
Expand All @@ -26,3 +27,15 @@ clean:
.PHONY: doc
doc:
godoc -http :6060

.PHONY: install
install: $(INSTALLDIR)
install -m 0755 bin/$(NAME) $(INSTALLDIR)
install -m 0600 config/config.dist.yaml $(INSTALLDIR)/config.dist.yaml

$(INSTALLDIR) release:
mkdir -p $@

release/$(NAME)_linux_amd64.tar.gz: release
make DESTDIR=./tmp install
tar -cvzf $@ --owner=0 --group=0 -C./tmp $(NAME)

0 comments on commit 5a6ee67

Please sign in to comment.