Skip to content

Commit da56227

Browse files
committed
Added initial Makefile
1 parent d6a9ca6 commit da56227

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
LAST_TAG := $(shell git describe --abbrev=0 --always --tags)
2+
BUILD := $(shell git rev-parse $(LAST_TAG))
3+
4+
BINARY := ip-range-to-cidr
5+
UNIXBINARY := $(BINARY)
6+
WINBINARY := $(UNIXBINARY).exe
7+
BUILDDIR := build
8+
9+
LINUXRELEASE := $(BINARY)-$(LAST_TAG)-linux-x64.tar.gz
10+
WINRELEASE := $(BINARY)-$(LAST_TAG)-windows-x64.zip
11+
12+
LDFLAGS := -ldflags "-s -w -X=main.VERSION=$(LAST_TAG) -X=main.BUILD=$(BUILD)"
13+
14+
bin:
15+
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -v -o $(BUILDDIR)/$(UNIXBINARY)
16+
upx -v -9 $(BUILDDIR)/$(UNIXBINARY)
17+
18+
bin-windows:
19+
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -v -o $(BUILDDIR)/$(WINBINARY)
20+
upx -v -9 $(BUILDDIR)/$(WINBINARY)
21+
22+
release:
23+
cd $(BUILDDIR); tar cvzf $(LINUXRELEASE) $(UNIXBINARY)
24+
25+
release-windows:
26+
cd $(BUILDDIR); zip -v -9 $(WINRELEASE) $(WINBINARY)
27+
28+
.PHONY: all clean test

0 commit comments

Comments
 (0)