-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
69 lines (57 loc) · 2.24 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
63
64
65
66
67
68
69
PREFIX ?= /usr
DESTDIR ?=
BINDIR ?= $(PREFIX)/bin
FULLTAG ?= $(shell git describe)
export GO111MODULE := on
all: generate-version-and-build
MAKEFLAGS += --no-print-directory
generate-version-and-build:
git config --global --add safe.directory "$(abspath .)"
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
tag="$$(git describe --tags --abbrev=0 2>/dev/null)" && \
ver="$$(printf 'package main\n\nvar Version = "%s"\n' "$$tag")" && \
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
echo "$$ver" > version.go || true
@$(MAKE) etherguard-go
etherguard-go: $(wildcard *.go) $(wildcard */*.go)
go mod download && \
go mod tidy && \
go mod vendor && \
go build -v -ldflags '-X main.Version=$(FULLTAG)' -o "$@"
etherguard-go-static: $(wildcard *.go) $(wildcard */*.go)
go mod download && \
go mod tidy && \
go mod vendor && \
CGO_ENABLED=0 go build -a -trimpath -ldflags '-X main.Version=$(FULLTAG) -s -w -extldflags "-static"' -v -o "$@"
vpp:
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
tag="$$(git describe --tags --abbrev=0 2>/dev/null)" && \
fulltag="$$(git describe 2>/dev/null)" && \
ver="$$(printf 'package main\n\nvar Version = "%s"\n' "$$tag")" && \
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
echo "$$ver" > version.go || true
@$(MAKE) etherguard-go-vpp
etherguard-go-vpp: export CGO_CFLAGS ?= -I/usr/include/memif
etherguard-go-vpp: $(wildcard *.go) $(wildcard */*.go)
go mod download && \
go mod tidy && \
go mod vendor && \
patch -p0 -i govpp_remove_crcstring_check.patch && \
go build -v -tags vpp -ldflags '-X main.Version=$(FULLTAG)' -o "$@"
static:
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
tag="$$(git describe --tags --abbrev=0 2>/dev/null)" && \
fulltag="$$(git describe 2>/dev/null)" && \
ver="$$(printf 'package main\n\nvar Version = "%s"\n' "$$tag")" && \
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
echo "$$ver" > version.go || true
@$(MAKE) etherguard-go-static
install: etherguard-go
@install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 "$<" "$(DESTDIR)$(BINDIR)/etherguard-go"
test:
go test -v ./...
clean:
rm -f etherguard-go
rm -f etherguard-go-static
rm -f etherguard-go-vpp
.PHONY: all clean test install generate-version-and-build