Makefile 1.2 KB
Newer Older
Lukas Burgey's avatar
Add CI    
Lukas Burgey committed
1
2
3
4
PROJECT_NAME := "feudalClient"
PKG := "git.scc.kit.edu/feudal/$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
5
6
7
VERSION := $(shell git describe --tags)
SCRIPT_VERSION := $(shell cat go.mod | grep feudalScripts | awk '{print $$2}')
LDFLAGS := "-X 'main.version=$(VERSION)' -X 'main.scriptsVersion=$(SCRIPT_VERSION)'"
Lukas Burgey's avatar
Add CI    
Lukas Burgey committed
8

Lukas Burgey's avatar
Lukas Burgey committed
9
.PHONY: all dep build clean test  lint
Lukas Burgey's avatar
Add CI    
Lukas Burgey committed
10
11
12

all: build

Lukas Burgey's avatar
Lukas Burgey committed
13
14
15
16
dep: ## Get the dependencies
	@go get -v -d ./...

lint: dep ## Lint the files
Lukas Burgey's avatar
Lukas Burgey committed
17
	@go get -u golang.org/x/lint/golint
Lukas Burgey's avatar
Add CI    
Lukas Burgey committed
18
19
20
21
22
	@golint -set_exit_status ${PKG_LIST}

test: ## Run unittests
	@go test -short ${PKG_LIST}

Lukas Burgey's avatar
Lukas Burgey committed
23
# link dynamically
24
25
build: dep go.mod ## Build the binary file
	go build -i -v -ldflags=$(LDFLAGS) $(PKG)
Lukas Burgey's avatar
Add CI    
Lukas Burgey committed
26

Lukas Burgey's avatar
Lukas Burgey committed
27
# link statically
28
29
build-static: dep go.mod ## Build the binary file
	@CGO_ENABLED=0 GOOS=linux go build -v -ldflags='$(LDFLAGS) -extldflags -static' $(PKG)
Lukas Burgey's avatar
Lukas Burgey committed
30

Lukas Burgey's avatar
Add CI    
Lukas Burgey committed
31
32
33
34
35
clean: ## Remove previous build
	@rm -f $(PROJECT_NAME)

help: ## Display this help screen
	@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Lukas Burgey's avatar
Lukas Burgey committed
36

Lukas Burgey's avatar
Lukas Burgey committed
37
install: dep
Lukas Burgey's avatar
Lukas Burgey committed
38
	@go install ./...
Lukas Burgey's avatar
Lukas Burgey committed
39
40
41

tidy:
	@go mod tidy