-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (45 loc) · 1.46 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
51
52
53
54
55
56
57
58
59
60
61
62
# Makefile for building dns
# Project binaries
COMMANDS=ludns resolvcache resolvcheck resolvcollect
BINARIES=$(addprefix bin/,$(COMMANDS))
# Used to populate version in binaries
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always | sed 's/^v//')
REVISION=$(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)
DATEBUILD=$(shell date +%FT%T%z)
# Compilation opts
GOPATH?=$(HOME)/go
SYSTEM:=
CGO_ENABLED:=0
BUILDOPTS:=-v
BUILDLDFLAGS=-ldflags '-s -w $(EXTRA_LDFLAGS)'
# Print output
WHALE = "+"
.PHONY: all binaries clean docker
all: binaries
FORCE:
# Build a binary from a cmd.
bin/%: cmd/% FORCE
@echo "$(WHALE) $@${BINARY_SUFFIX}"
GO111MODULE=on CGO_ENABLED=$(CGO_ENABLED) $(SYSTEM) \
go build $(BUILDOPTS) -o $@${BINARY_SUFFIX} ${BUILDLDFLAGS} ./$<
binaries: $(BINARIES)
@echo "$(WHALE) $@"
clean:
@echo "$(WHALE) $@"
@rm -f $(BINARIES)
@rmdir bin
docker:
@echo "$(WHALE) $@"
DOCKER_BUILDKIT=1 docker build --progress=plain -t ludns -f Dockerfile.ludns .
DOCKER_BUILDKIT=1 docker build --progress=plain -t resolvcache -f Dockerfile.resolvcache .
## Targets for Makefile.release
.PHONY: release
release:
@$(if $(value BINARY),, $(error Undefined BINARY))
@$(if $(value COMMAND),, $(error Undefined COMMAND))
@echo "$(WHALE) $@"
GO111MODULE=on CGO_ENABLED=$(CGO_ENABLED) $(SYSTEM) \
go build $(BUILDOPTS) ${BUILDLDFLAGS} -o $(BINARY) ./cmd/$(COMMAND)
.PHONY: test
test:
@echo "$(WHALE) $@"