forked from lf-edge/eve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (54 loc) · 1.65 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
70
71
72
73
74
75
# Copyright (c) 2018 Zededa, Inc.
# SPDX-License-Identifier: Apache-2.0
# Goals
# 1. Build go provision binaries for arm64 and amd64
# 2. Build on Linux as well on Mac
ARCH ?= amd64
#ARCH ?= arm64
DISTDIR := dist/$(ARCH)
BUILD_VERSION=$(shell scripts/getversion.sh 2>/dev/null)
DOCKER_ARGS=
DOCKER_TAG=lfedge/eve-pillar:local
ifneq ($(GOARCH),)
DOCKER_ARGS:=--build-arg GOARCH=$(GOARCH)
DOCKER_TAG:=$(DOCKER_TAG)-$(GOARCH)
endif
APPS = zedbox
APPS1 = $(notdir $(wildcard cmd/*))
# find all GOFILES
GOFILES = $(shell find . -path ./vendor -prune -o -name '*go' -print)
.PHONY: all clean build test build-docker build-docker-git shell
all: build
$(DISTDIR):
mkdir -p $(DISTDIR)
build: $(APPS) $(APPS1)
$(APPS): $(DISTDIR)/$(APPS)
$(DISTDIR)/$(APPS): $(DISTDIR)
@echo "Building $@"
GO111MODULE=on GOOS=linux CGO_ENABLED=0 go build -mod=vendor -ldflags -X=main.Version=$(BUILD_VERSION) -o $@ ./$(@F)
$(APPS1): $(DISTDIR)
@echo $@
@rm -f $(DISTDIR)/$@
@ln -s $(APPS) $(DISTDIR)/$@
shell:
make -C ../.. shell
build-docker-$(APPS): $(DISTDIR)
docker build -f Dockerfile.in --target=build -t $(APPS)-builder .
# all of this goes away when we switch to full buildkit-based docker builds
docker container create --name $(APPS)-extract $(APPS)-builder
docker container cp $(APPS)-extract:/dist/$(APPS) $(DISTDIR)/$(APPS)
docker container rm -f $(APPS)-extract
build-docker:
docker build $(DOCKER_ARGS) -t $(DOCKER_TAG) .
build-docker-git:
git archive HEAD | docker build $(DOCKER_ARGS) -t $(DOCKER_TAG) -
test:
go test -mod=vendor ./...
clean:
@rm -rf $(DISTDIR)
fmt:
@gofmt -w -s $(GOFILES)
fmt-check:
@gofmt -l $(GOFILES)
vet:
go vet ./...