EtherGuard-VPN/Makefile

70 lines
2.2 KiB
Makefile
Raw Permalink Normal View History

2018-05-15 02:15:16 +02:00
PREFIX ?= /usr
DESTDIR ?=
BINDIR ?= $(PREFIX)/bin
2021-12-27 11:58:42 +01:00
FULLTAG ?= $(shell git describe)
2018-10-12 01:45:33 +02:00
export GO111MODULE := on
2018-10-12 01:12:00 +02:00
2018-10-17 21:45:16 +02:00
all: generate-version-and-build
2018-05-15 02:15:16 +02:00
2018-10-12 01:12:00 +02:00
MAKEFLAGS += --no-print-directory
2018-10-12 01:12:00 +02:00
generate-version-and-build:
git config --global --add safe.directory "$(abspath .)"
2018-05-24 01:52:22 +02:00
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
2021-12-27 11:58:42 +01:00
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" ] && \
2021-12-27 11:21:34 +01:00
echo "$$ver" > version.go || true
2021-08-16 20:58:15 +02:00
@$(MAKE) etherguard-go
2018-05-24 01:52:22 +02:00
2021-08-16 20:58:15 +02:00
etherguard-go: $(wildcard *.go) $(wildcard */*.go)
2021-08-26 11:06:40 +02:00
go mod download && \
go mod tidy && \
go mod vendor && \
2021-12-27 11:58:42 +01:00
go build -v -ldflags '-X main.Version=$(FULLTAG)' -o "$@"
2021-08-26 11:06:40 +02:00
2021-12-18 19:23:59 +01:00
etherguard-go-static: $(wildcard *.go) $(wildcard */*.go)
go mod download && \
go mod tidy && \
go mod vendor && \
2021-12-27 11:58:42 +01:00
CGO_ENABLED=0 go build -a -trimpath -ldflags '-X main.Version=$(FULLTAG) -s -w -extldflags "-static"' -v -o "$@"
2021-12-18 19:23:59 +01:00
2021-08-26 11:06:40 +02:00
vpp:
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
2021-12-27 11:58:42 +01:00
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")" && \
2021-08-26 11:06:40 +02:00
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
2021-12-27 11:21:34 +01:00
echo "$$ver" > version.go || true
2021-08-26 11:06:40 +02:00
@$(MAKE) etherguard-go-vpp
2021-08-26 14:09:07 +02:00
etherguard-go-vpp: export CGO_CFLAGS ?= -I/usr/include/memif
2021-08-26 11:06:40 +02:00
etherguard-go-vpp: $(wildcard *.go) $(wildcard */*.go)
2021-08-24 20:16:21 +02:00
go mod download && \
go mod tidy && \
go mod vendor && \
patch -p0 -i govpp_remove_crcstring_check.patch && \
2021-12-27 11:58:42 +01:00
go build -v -tags vpp -ldflags '-X main.Version=$(FULLTAG)' -o "$@"
2018-05-15 02:15:16 +02:00
2021-12-18 19:23:59 +01:00
static:
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
2021-12-27 11:58:42 +01:00
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")" && \
2021-12-18 19:23:59 +01:00
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
2021-12-27 11:21:34 +01:00
echo "$$ver" > version.go || true
2021-12-18 19:23:59 +01:00
@$(MAKE) etherguard-go-static
2021-08-16 20:58:15 +02:00
install: etherguard-go
@install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 "$<" "$(DESTDIR)$(BINDIR)/etherguard-go"
test:
go test -v ./...
clean:
2021-08-16 20:58:15 +02:00
rm -f etherguard-go
2021-12-18 19:23:59 +01:00
rm -f etherguard-go-static
2021-08-26 14:09:07 +02:00
rm -f etherguard-go-vpp
.PHONY: all clean test install generate-version-and-build