-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
33 lines (28 loc) · 792 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
BINARY_NAME=ovsdb-mon
BINARY_MOD=./cmd/$(BINARY_NAME)
MODEL_GEN=$(GOPATH)/bin/modelgen
MODEL_PATH=model
BIN_PATH=bin
SCHEMA?=schemas/ovn-nb.ovsschema
.PHONY:all
all: build
$(MODEL_GEN):
ifeq ($(GOPATH),)
$(error GOPATH is not set)
endif
@go install github.com/ovn-org/libovsdb/cmd/modelgen
.PHONY: build
build: $(MODEL_GEN)
@echo "Generating model based on schema $(SCHEMA)"
@cp $(SCHEMA) model/db.ovsschema
@export PATH="$${PATH}:$${GOPATH}/bin"; go generate ./...
ifeq ($(STATIC),1)
@CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o $(BIN_PATH)/$(BINARY_NAME) $(BINARY_MOD)
else
@go build -o $(BIN_PATH)/$(BINARY_NAME) $(BINARY_MOD)
endif
.PHONY: clean
clean:
@rm -rf $(BIN_PATH)
@find model -name "*.go" -not -name "gen.go" | xargs rm -f
@rm -f model/db.ovsschema