Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

update Makefile add the help print information. #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,65 @@ OUTPUT_GOFLOW_LIGHT_NF := $(DIST_DIR)goflow-netflow-$(GOFLOW_VERSION)-$(GOOS)
OUTPUT_GOFLOW_LIGHT_NFV5 := $(DIST_DIR)goflow-nflegacy-$(GOFLOW_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)

.PHONY: all
all: test-race vet test
all: test-race vet test ## Run all tests and checks.

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Development

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: vet


.PHONY: proto
proto:
@echo generating protobuf
protoc --go_out=. --plugin=$(PROTOCPATH)protoc-gen-go pb/*.proto

.PHONY: test
test:
test: ## Run unit tests.
@echo testing code
go test ./...

.PHONY: vet
vet:
vet: ## Run go vet to check for potential issues.
@echo checking code is vetted
go vet $(shell go list ./...)

.PHONY: test-race
test-race:
test-race: ## Run tests with race condition detection.
@echo testing code for races
go test -race ./...

.PHONY: prepare
prepare:
prepare: ## Prepare necessary directories for build output.
mkdir -p $(DIST_DIR)

.PHONY: clean
clean:
clean: ## Clean build artifacts.
rm -rf $(DIST_DIR)

.PHONY: build-goflow
build-goflow: prepare
build-goflow: prepare ## Build the goflow binary.
go build -ldflags $(LDFLAGS) -o $(OUTPUT_GOFLOW) cmd/goflow/goflow.go

.PHONY: docker-goflow
docker-goflow: ## Build the Docker image for goflow.
docker build -t $(DOCKER_REPO)$(GOFLOW_NAME):$(GOFLOW_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile .

.PHONY: build-goflow-light
build-goflow-light: prepare
build-goflow-light: prepare ## Build the lightweight goflow binaries.
go build -ldflags $(LDFLAGS) -o $(OUTPUT_GOFLOW_LIGHT_SFLOW) cmd/csflow/csflow.go
go build -ldflags $(LDFLAGS) -o $(OUTPUT_GOFLOW_LIGHT_NF) cmd/cnetflow/cnetflow.go
go build -ldflags $(LDFLAGS) -o $(OUTPUT_GOFLOW_LIGHT_NFV5) cmd/cnflegacy/cnflegacy.go

.PHONY: docker-goflow
docker-goflow:
docker build -t $(DOCKER_REPO)$(GOFLOW_NAME):$(GOFLOW_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile .

.PHONY: package-deb-goflow
package-deb-goflow: prepare
package-deb-goflow: prepare ## Package goflow as a Debian package.
fpm -s dir -t deb -n $(GOFLOW_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--url "$(URL)" \
Expand All @@ -80,7 +93,7 @@ package-deb-goflow: prepare
package/goflow.env=/etc/default/goflow

.PHONY: package-rpm-goflow
package-rpm-goflow: prepare
package-rpm-goflow: prepare ## Package goflow as an RPM package.
fpm -s dir -t rpm -n $(GOFLOW_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--url "$(URL)" \
Expand Down