build: Add cross building option
Added a cross build option using a buildrelease function Signed-off-by: Toshaan Bharvani <toshaan@vantosh.com> build: Add gitignore entry for mgmt-* binaries Signed-off-by: Toshaan Bharvani <toshaan@vantosh.com> build: Update makefile based upon feed back * rename cross to crossbuild * added crossbuild to PHONY Signed-off-by: Toshaan Bharvani <toshaan@vantosh.com> build: Change the order of .PHONY as per the rest of the file Signed-off-by: Toshaan Bharvani <toshaan@vantosh.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,5 +9,6 @@ tmp/
|
||||
bindata/*.go
|
||||
mgmt
|
||||
mgmt.static
|
||||
mgmt-*
|
||||
mgmt.iml
|
||||
rpmbuild/
|
||||
|
||||
11
Makefile
11
Makefile
@@ -16,7 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
SHELL = /usr/bin/env bash
|
||||
.PHONY: all art cleanart version program path deps run race bindata generate build clean test gofmt yamlfmt format docs rpmbuild mkdirs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms copr
|
||||
.PHONY: all art cleanart version program path deps run race bindata generate build crossbuild clean test gofmt yamlfmt format docs rpmbuild mkdirs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms copr
|
||||
.SILENT: clean bindata
|
||||
|
||||
GO_FILES := $(shell find . -name '*.go')
|
||||
@@ -40,6 +40,7 @@ REMOTE_PATH = 'pub/alt/$(USERNAME)/$(PROGRAM)'
|
||||
ifneq ($(GOTAGS),)
|
||||
BUILD_FLAGS = -tags '$(GOTAGS)'
|
||||
endif
|
||||
GOOSARCHES = linux/amd64 linux/ppc64 linux/ppc64le linux/arm64
|
||||
|
||||
default: build
|
||||
|
||||
@@ -114,6 +115,14 @@ $(PROGRAM): $(GO_FILES)
|
||||
@echo "Building: $(PROGRAM), version: $(SVERSION)..."
|
||||
time go build -i -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o $(PROGRAM) $(BUILD_FLAGS);
|
||||
|
||||
define buildrelease
|
||||
GOOS=$(1) GOARCH=$(2) go build -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION) -s -w" -o $(PROGRAM)-$(1)-$(2) $(BUILD_FLAGS);
|
||||
endef
|
||||
|
||||
crossbuild:
|
||||
@echo "Building: $(PROGRAM), version: $(SVERSION), arches: $(GOOSARCHES) ..."
|
||||
$(foreach GOOSARCH,$(GOOSARCHES), $(call buildrelease,$(subst /,,$(dir $(GOOSARCH))),$(notdir $(GOOSARCH))))
|
||||
|
||||
$(PROGRAM).static: $(GO_FILES)
|
||||
@echo "Building: $(PROGRAM).static, version: $(SVERSION)..."
|
||||
go generate
|
||||
|
||||
Reference in New Issue
Block a user