# Go parameters GOCMD := go GOBUILD := $(GOCMD) build GOCLEAN := $(GOCMD) clean GOLINT := golint GOVET := $(GOCMD) vet GOCOVER := gocov GO_LDFLAGS := -ldflags '-extldflags "-static"' # Target parameters BINARY_FILE := edge-orchestration OBJECT_FILE := liborchestration.so HEADER_FILE := orchestration.h EXEC_SRC_DIR := GoMain OBJ_SRC_DIR := interface BIN_DIR := $(BASE_DIR)/bin CMAIN_DIR := $(BASE_DIR)/src/CMain PKG_DIRS := devicemgr discoverymgr interface restapi/v1 servicemgr .DEFAULT_GOAL := help ## test and build all: build ## edge-orchestration binary build build-binary: $(GOBUILD) -a $(GO_LDFLAGS) -o $(BIN_DIR)/$(BINARY_FILE) $(EXEC_SRC_DIR) || exit 1 ls -al $(BIN_DIR) ## edge-orchestration shared object build build-object: CGO_ENABLED=1 $(GOBUILD) -o $(BIN_DIR)/$(OBJECT_FILE) -buildmode=c-shared -linkshared $(OBJ_SRC_DIR) || exit 1 ls -al $(BIN_DIR) rm -f $(CMAIN_DIR)/$(OBJECT_FILE) rm -f $(CMAIN_DIR)/$(HEADER_FILE) cp $(BIN_DIR)/$(OBJECT_FILE) $(CMAIN_DIR) cp $(BIN_DIR)/$(HEADER_FILE) $(CMAIN_DIR) ## go test and coverage test: $(GOCOVER) test $(PKG_DIRS) > coverage.out $(GOCOVER) report coverage.out $(GOCOVER)-html coverage.out > coverage.html firefox coverage.html & ## build clean clean: $(GOCLEAN) rm -f $(BIN_DIR)/* ## check go style and static analysis lint: $(GOLINT) ./src/... $(GOVET) ./src/... ## show help help: @make2help $(MAKEFILE_LIST) ## define build target not a file .PHONY: all build test clean lint help