-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
50 lines (40 loc) · 1.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
VERSION = 0.1.1
BUILDDIR ?= build
BINDIR ?= /usr/local/bin
DOCKER_IMAGE ?= banviktor/asnlookup
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
DATE = $(shell date -u +%Y%m%d)
.PHONY: build
build: $(BUILDDIR)/asnlookup $(BUILDDIR)/asnlookup-utils
.PHONY: clean
clean:
rm -f $(BUILDDIR)/*
.PHONY: deps
deps:
go mod download
$(BUILDDIR)/asnlookup: deps
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags '-extldflags "-static"' -o $(BUILDDIR)/asnlookup ./cmd/asnlookup
$(BUILDDIR)/asnlookup-utils: deps
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags '-extldflags "-static"' -o $(BUILDDIR)/asnlookup-utils ./cmd/asnlookup-utils
.PHONY: release
release:
$(MAKE) clean
$(MAKE)
tar -zcf asnlookup-$(GOOS)-$(GOARCH)-v$(VERSION).tar.gz -C $(BUILDDIR) .
release-all:
$(MAKE) release GOOS=linux GOARCH=amd64
$(MAKE) release GOOS=linux GOARCH=arm64
$(MAKE) release GOOS=linux GOARCH=386
$(MAKE) release GOOS=darwin GOARCH=amd64
$(MAKE) release GOOS=darwin GOARCH=arm64
.PHONY: test
test:
go test -race ./...
.PHONY: install
install:
cp -f $(BUILDDIR)/asnlookup $(BINDIR)/
cp -f $(BUILDDIR)/asnlookup-utils $(BINDIR)/
.PHONY: uninstall
uninstall:
rm -f $(BINDIR)/asnlookup $(BINDIR)/asnlookup-utils