-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
60 lines (45 loc) · 1.56 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# This how we want to name the binary output
APP_NAME ?= scheduler
# These are the values we want to pass for VERSION and BUILD
# git tag 1.0.1
# git commit -am "One more change after the tags"
VERSION ?= `./scripts/genver` (dev)
MODULE ?= github.com/cloudfoundry-community/ocf-scheduler
CMD_PATH ?= cmd/scheduler
CGO_ENABLED ?= 0
BUILD_PATH=builds
BUILD=${APP_NAME}-${VERSION}
TESTFILES=`go list ./... | grep -v /vendor/`
# Setup the -ldflags option for go build here, interpolate the variable values
LDFLAGS := -w -s -X main.Version=$(VERSION)
ifeq ($(CGO_ENABLED),0)
LDFLAGS += -extldflags '-static'
endif
# Build for the current platform
all: clean build
# Build a new release
release: distclean distbuild linux package
# Builds the project
build:
go build -ldflags="${LDFLAGS}" -o "${APP_NAME}" "${MODULE}/${CMD_PATH}"
cli:
$(MAKE) build APP_NAME=sch CMD_PATH=cmd/cli
# Builds the project for all possible platforms
distbuild:
mkdir -p ${BUILD_PATH}
# Installs our project: copies binaries
install:
go install -ldflags="${LDFLAGS}"
# Cleans our project: deletes binaries
clean:
rm -rf ${APP_NAME}
# Cleans release files
distclean:
rm -rf ${BUILD_PATH} ${APP_NAME}-*.tar.gz
test:
./scripts/blanket
linux:
CGO_ENABLED=${CGO_ENABLED} GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o "${BUILD_PATH}/${BUILD}-linux-amd64" "${MODULE}/${CMD_PATH}"
CGO_ENABLED=${CGO_ENABLED} GOOS=linux GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o "${BUILD_PATH}/${BUILD}-linux-arm64" "${MODULE}/${CMD_PATH}"
package:
cd builds && tar -z -c -v -f ../${BUILD}.tar.gz "${BUILD}"-*