-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (56 loc) · 1.41 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
61
62
63
64
65
66
67
# Set Variables
FOLDERPATH=$(shell pwd)
FOLDERNAME=$(shell basename "$(PWD)")
GOFILES=$(find . -type f -name '*.go')
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOFMT=$(GOCMD) fmt
BINARY_WIN=$(FOLDERNAME).exe
BINARY_UNIX=$(FOLDERNAME)
# Set default binary name based on operating system
ifeq ($(OS), Windows_NT)
BINARY_NAME=$(BINARY_WIN)
else
BINARY_NAME=$(BINARY_UNIX)
endif
# Make is verbose. Make it silent.
MAKEFLAGS += --silent
# Define help output
.PHONY: help
all: help
help: Makefile
@echo
@echo " Choose a command run:"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo
## build: Builds the binary.
build:
$(GOBUILD) -o $(BINARY_NAME) -v
#test:
# $(GOTEST) -v ./...
# clean: Cleans up.
#clean:
# $(GOCLEAN)
# rm -f $(BINARY_NAME)
# rm -f $(BINARY_UNIX)
## run: Builds then runs the binary.
run:
$(MAKE) build && ./$(BINARY_NAME)
# deps: Installs any missing dependencies.
#deps:
# $(GOGET) github.com/markbates/goth
# $(GOGET) github.com/markbates/pop
## fmt: Formats all .go files found.
fmt:
$(GOFMT) ./...
# Cross compilation
## build-linux: Builds the binary for linux.
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v
# build-docker: Builds a docker image.
#build-docker:
# docker run --rm -it -v "$(GOPATH)":/go -w /go/src/bitbucket.org/rsohlich/makepost golang:latest go build -o "$(BINARY_UNIX)" -v