Makefile 544 B

123456789101112131415161718192021222324252627
  1. # Go parameters
  2. GOCMD=go
  3. GOBUILD=$(GOCMD) build
  4. GOCLEAN=$(GOCMD) clean
  5. GOTEST=$(GOCMD) test
  6. GOGET=$(GOCMD) get
  7. SERVICE_NAME = $(shell pwd |sed 's/^\(.*\)[/]//' )
  8. PROJECT_NAME=${SERVICE_NAME}
  9. BIN_DIR=/usr/sbin
  10. CP_CMD=/usr/bin/cp
  11. COMMAND=${SERVICE_NAME}
  12. all: build-go
  13. build-go:
  14. go build -o $(PROJECT_NAME) -v -ldflags "-X main.Version=$(version) -X main.GitCommit=`git rev-parse HEAD`"
  15. test:
  16. $(GOTEST) -v ./...
  17. install:build
  18. $(CP_CMD) $(COMMAND) $(DESTDIR)$(BIN_DIR)
  19. clean:
  20. $(GOCLEAN)
  21. rm -f $(PROJECT_NAME)