This repository has been archived by the owner on Jan 12, 2021. It is now read-only.
forked from goodhosts/cli
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from praveenkumar/master
Add Makefile
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
goodhosts | ||
goodhosts.exe | ||
.idea | ||
dist | ||
dist | ||
out | ||
release |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Go and compilation related variables | ||
BUILD_DIR ?= out | ||
|
||
BINARY_NAME := goodhosts | ||
RELEASE_DIR ?= release | ||
|
||
# Add default target | ||
.PHONY: all | ||
all: build | ||
|
||
vendor: | ||
go mod vendor | ||
|
||
$(BUILD_DIR): | ||
mkdir -p $(BUILD_DIR) | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(BUILD_DIR) | ||
rm -rf vendor | ||
rm -fr release | ||
|
||
$(BUILD_DIR)/macos-amd64/$(BINARY_NAME): | ||
GOARCH=amd64 GOOS=darwin go build -o $(BUILD_DIR)/macos-amd64/$(BINARY_NAME) ./main.go | ||
|
||
$(BUILD_DIR)/linux-amd64/$(BINARY_NAME): | ||
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/linux-amd64/$(BINARY_NAME) ./main.go | ||
|
||
$(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe: | ||
GOARCH=amd64 GOOS=windows go build -o $(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe ./main.go | ||
|
||
.PHONY: cross ## Cross compiles all binaries | ||
cross: $(BUILD_DIR)/macos-amd64/$(BINARY_NAME) $(BUILD_DIR)/linux-amd64/$(BINARY_NAME) $(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe | ||
|
||
.PHONY: release | ||
release: clean cross | ||
mkdir $(RELEASE_DIR) | ||
tar cJSf $(RELEASE_DIR)/goodhosts-cli-macos-amd64.tar.xz -C $(BUILD_DIR)/macos-amd64 $(BINARY_NAME) | ||
tar cJSf $(RELEASE_DIR)/goodhosts-cli-linux-amd64.tar.xz -C $(BUILD_DIR)/linux-amd64 $(BINARY_NAME) | ||
tar cJSf $(RELEASE_DIR)/goodhosts-cli-windows-amd64.tar.xz -C $(BUILD_DIR)/windows-amd64 $(BINARY_NAME).exe | ||
|
||
pushd $(RELEASE_DIR) && sha256sum * > sha256sum.txt && popd | ||
|
||
.PHONY: build | ||
build: | ||
go build -o $(BINARY_NAME) ./main.go | ||
|