This repository has been archived by the owner on Apr 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added make target for prebuilding binary for mutliple targets
- Loading branch information
Showing
2 changed files
with
24 additions
and
7 deletions.
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
/bin | ||
/release | ||
/build |
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 |
---|---|---|
@@ -1,20 +1,35 @@ | ||
SOURCEDIR=. | ||
SOURCES := $(shell find $(SOURCEDIR) -name '*.go') | ||
|
||
BINARY=bin/terraform-provider-zabbix | ||
BUILD_PATH=build | ||
BINARY=terraform-provider-zabbix | ||
BIN=bin | ||
TARGETS=darwin linux windows | ||
VERSION=0.0.2 | ||
RELEASE_DIR=release | ||
RELEASE=terraform-provider-zabbix_$(VERSION).tar.gz | ||
|
||
VERSION=1.0.0 | ||
BUILD_TIME=`date +%FT%T%z` | ||
build=GOOS=$(1) GOARCH=$(2) go build -o ${BUILD_PATH}/$(BINARY)/$(1)_$(2)/${BINARY}`if [ "$(1)" = "windows" ]; then echo ".exe"; fi` main.go | ||
|
||
.DEFAULT_GOAL: $(BINARY) | ||
|
||
$(BINARY): $(SOURCES) | ||
go build ${LDFLAGS} -o ${BINARY} main.go | ||
$(BIN)/$(BINARY): $(SOURCES) | ||
go build -o $(BIN)/${BINARY} main.go | ||
|
||
$(TARGETS): $(SOURCES) | ||
$(call build,$@,amd64,$(ext)) | ||
$(call build,$@,386,$(ext)) | ||
|
||
release: $(TARGETS) | ||
mkdir -p $(RELEASE_DIR) | ||
tar -czvf $(RELEASE_DIR)/$(RELEASE) -C $(BUILD_PATH) $(BINARY) | ||
|
||
install: | ||
go install ./... | ||
|
||
clean: | ||
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi | ||
@if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi | ||
@if [ -d ${BUILD_PATH} ]; then rm -r ${BUILD_PATH} ; fi | ||
@if [ -d ${RELEASE_DIR} ]; then rm -r $(RELEASE_DIR) ; fi | ||
|
||
.PHONY: clean install | ||
.PHONY: clean install build release $(TARGETS) |