Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update makefile to account for different arch #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,39 @@ else ifeq ("$(os)", "Darwin")
target_os = darwin
endif

.PHONY: all build check check-format check-os clean docker format install lint proto release-docker setup test vet
# Retrieve goarch
architecture=$(shell uname -m)
ifeq ("$(architecture)", "i386")
goarch="386"
else ifeq ("$(architecture)", "i686")
goarch="386"
else ifeq ("$(architecture)", "x86_64")
goarch="amd64"
else ifeq ("$(architecture)", "arm")
goarch="arm"
else ifeq ("$(architecture)", "arm64")
goarch="arm64"
else ifeq ("$(architecture)", "aarch64")
goarch="aarch64"
endif


.PHONY: all build check check-format check-os check-arch clean docker format install lint proto release-docker setup test vet

all : check install test
check : check-os check-format vet lint test
check : check-os check-arch check-format vet lint test
travis : clean setup check build test docker

check-os:
ifndef target_os
$(error Unsupported platform: ${os})
endif

check-arch:
ifndef goarch
$(error architecture=${architecture} has not been accounted for)
endif

setup:
@echo "== setup"
go install golang.org/x/lint/golint@latest
Expand All @@ -49,14 +71,15 @@ clean :
rm -rf build
rm -rf dist

build :
build : check-arch
@echo "== build"
GOOS=${target_os} GOARCH=amd64 go build -ldflags '-s $(ldflags)' -o ${build_dir}/${target_os}_amd64/osprey -v
@echo "Building binary for ${target_os} arch=${architecture} goarch=${goarch}"
GOOS=${target_os} GOARCH=${goarch} go build -ldflags '-s $(ldflags)' -o ${build_dir}/${target_os}_${goarch}/osprey -v .

install :
install : check-arch
@echo "== install"
@echo "Installing binary for ${target_os}"
GOOS=${target_os} GOARCH=amd64 go install -ldflags '$(ldflags)' -v
@echo "Installing binary for ${target_os} ${goarch}"
GOOS=${target_os} GOARCH=${goarch} go install -ldflags '$(ldflags)' -v

unformatted = $(shell goimports -l $(files))

Expand Down