forked from confidential-containers/cloud-api-adaptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (32 loc) · 919 Bytes
/
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
#
# (C) Copyright IBM Corp. 2022.
# SPDX-License-Identifier: Apache-2.0
#
.PHONY: all build check fmt vet clean
ifndef CLOUD_PROVIDER
$(error CLOUD_PROVIDER is not set)
endif
GOFLAGS ?= -tags=$(CLOUD_PROVIDER)
BINARIES := cloud-api-adaptor agent-protocol-forwarder
SOURCEDIRS := ./cmd ./pkg
PACKAGES := $(shell go list $(addsuffix /...,$(SOURCEDIRS)))
SOURCES := $(shell find $(SOURCEDIRS) -name '*.go' -print)
all: build
build: $(BINARIES)
$(BINARIES): $(SOURCES)
ifeq ($(CLOUD_PROVIDER),libvirt)
go build $(GOFLAGS) -o "$@" "cmd/$@/main.go"
else
CGO_ENABLED=0 go build $(GOFLAGS) -o "$@" "cmd/$@/main.go"
endif
test:
# Note: sending stderr to stdout so that tools like go-junit-report can
# parse build errors.
go test -v $(GOFLAGS) -cover $(PACKAGES) 2>&1
check: fmt vet
fmt:
find $(SOURCEDIRS) -name '*.go' -print0 | xargs -0 gofmt -l -d
vet:
go vet $(PACKAGES)
clean:
rm -fr $(BINARIES)