-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
58 lines (46 loc) · 1.28 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
# Go parameters
GOCMD=go
DEPCMD=dep
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=file-to-machineconfig
BINARY_UNIX=$(BINARY_NAME)-linux-amd64
BINARY_OSX=$(BINARY_NAME)-darwin-amd64
BINARY_WINDOWS=$(BINARY_NAME)-windows-amd64.exe
all: test build
build-all: build-linux build-osx build-windows
prepare:
sudo dnf install -y golang git
mkdir -p "${HOME}/go/bin"
echo 'export GOPATH=${HOME}/go' >> ${HOME}/.bashrc
echo 'export PATH=${GOPATH}/bin:${PATH}' >> ${HOME}/.bashrc
build:
$(GOBUILD) -o $(BINARY_NAME) -v
test:
$(GOTEST) -v ./...
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_UNIX)
rm -f $(BINARY_OSX)
rm -f $(BINARY_UNIX).sha256
rm -f $(BINARY_OSX).sha256
run:
$(GOBUILD) -o $(BINARY_NAME) -v ./...
./$(BINARY_NAME)
deps:
$(DEPCMD) ensure -v
deps-update:
$(DEPCMD) ensure -update -v
# Cross compilation
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v
sha256sum $(BINARY_UNIX) > $(BINARY_UNIX).sha256
build-osx:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINARY_OSX) -v
sha256sum $(BINARY_OSX) > $(BINARY_OSX).sha256
build-windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_WINDOWS) -v
sha256sum $(BINARY_WINDOWS) > $(BINARY_WINDOWS).sha256