-
-
Save shangzongyu/2de7d0635c0cfd3ca2a5a6fb80e36766 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Go parameters | |
GOCMD=go | |
GOBUILD=$(GOCMD) build | |
GOCLEAN=$(GOCMD) clean | |
GOTEST=$(GOCMD) test | |
GOGET=$(GOCMD) get | |
GOMODE=$(GOCMD) mod | |
BINARY_NAME=mybinary | |
BINARY_UNIX=$(BINARY_NAME)_unix | |
BINARY_MACOS=$(BINARY_NAME)_darwin | |
BINARY_WINDOWS=$(BINARY_NAME).exe | |
all: test build | |
build: | |
$(GOBUILD) -o $(BINARY_NAME) -v | |
test: | |
$(GOTEST) -v ./... | |
clean: | |
$(GOCLEAN) | |
rm -f $(BINARY_NAME) | |
rm -f $(BINARY_UNIX) | |
rm -f $(BINARY_MACOS) | |
rm -f $(BINARY_WINDOWS) | |
run: | |
$(GOBUILD) -o $(BINARY_NAME) -v ./... | |
./$(BINARY_NAME) | |
deps: | |
$(GOCMD) init | |
# Cross compilation | |
build-linux: | |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v | |
build-macos: | |
CGO_ENABLED=0 GOOS=linux GOARCH=darwin $(GOBUILD) -o $(BINARY_MACOS) -v | |
build-windows: | |
CGO_ENABLED=0 GOOS=linux GOARCH=windows $(GOBUILD) -o $(BINARY_WINDOWS) -v | |
docker-build: | |
docker run --rm -it -v "$(GOPATH)":/go -w /go/src/bitbucket.org/rsohlich/makepost golang:latest go build -o "$(BINARY_UNIX)" -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment