-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
37 lines (29 loc) · 1.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Paths to packages
GO=$(shell which go)
# Paths to locations, etc
BUILD_DIR="build"
BUILD_MODULE="github.com/thevfxcoop/go-workable-api"
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitTag=$(shell git describe --tags)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitBranch=$(shell git name-rev HEAD --name-only --always)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitHash=$(shell git rev-parse HEAD)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GoBuildTime=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
BUILD_FLAGS = -ldflags "-s -w $(BUILD_LD_FLAGS)"
.PHONY: all production development dependencies mkdir clean
all: production
dependencies:
ifeq (,${GO})
$(error "Missing go binary")
endif
mkdir:
@install -d ${BUILD_DIR}
${GO} mod tidy
production: dependencies mkdir
@echo Build for production: ./build/workable
${GO} build -o ${BUILD_DIR}/workable ${BUILD_FLAGS} ./cmd/workable
development: dependencies mkdir
@echo Build for development: ./build/workable
${GO} build -tags debug -o ${BUILD_DIR}/workable ${BUILD_FLAGS} ./cmd/workable
clean:
rm -fr $(BUILD_DIR)
${GO} clean
${GO} mod tidy