# Go parameters GOCMD := go GOBUILD := $(GOCMD) build GOCLEAN := $(GOCMD) clean GOLINT := golint GOVET := $(GOCMD) vet GOCOVER := gocov GO_LDFLAGS := -ldflags '-extldflags "-static"' # Target parameters BIN_DIR := $(BASE_DIR)/bin BINARY_FILE := edge-orchestration EXEC_SRC_DIR := GoMain OBJ_SRC_DIR := interface PKG_DIRS := devicemgr discoverymgr interface restapi/v1 servicemgr # CMain target ORG_HEADER_FILE_C := liborchestration.h HEADER_FILE_C := orchestration.h OBJECT_FILE_C := liborchestration.a CMAIN_DIR := $(BASE_DIR)/src/CMain CMAIN_INC_DIR := $(CMAIN_DIR)/inc CMAIN_BIN_DIR := $(CMAIN_DIR)/bin CMAIN_LIB_DIR := $(CMAIN_DIR)/lib .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) $(MAKE) -C $(CMAIN_DIR) ## edge-orchestration shared object build build-object: CGO_ENABLED=1 $(GOBUILD) -o $(CMAIN_LIB_DIR)/$(OBJECT_FILE_C) -buildmode=c-archive $(OBJ_SRC_DIR) || exit 1 mv $(CMAIN_LIB_DIR)/$(ORG_HEADER_FILE_C) $(CMAIN_INC_DIR)/$(HEADER_FILE_C) ## 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 $(CMAIN_INC_DIR)/$(HEADER_FILE_C) -rm -f $(CMAIN_LIB_DIR)/$(OBJECT_FILE_C) -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