diff --git a/Makefile b/Makefile index dace9fec7f..17b773a564 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ GO_BUILD_INSTALL_DEPS=-i GO_BUILD_TAGS='netgo unsafe' GO_BUILD_FLAGS=$(GO_BUILD_INSTALL_DEPS) -ldflags "-extldflags \"-static\" -X main.version=$(SCOPE_VERSION)" -tags $(GO_BUILD_TAGS) + all: $(SCOPE_EXPORT) $(DOCKER_DISTRIB): @@ -67,6 +68,15 @@ $(SCOPE_EXE) $(RUNSVINIT) lint tests shell prog/static.go: $(SCOPE_BACKEND_BUILD else +UNAME := $(shell uname) +ifeq ($(UNAME), Darwin) + UNSET_GOARCH_GOOS=unset GOARCH GOOS; + UNSET_GOGC=unset GOGC; +else + UNSET_GOARCH_GOOS=env -u GOGC -u GOOS + UNSET_GOGC=env -u GOGC +endif + $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D) @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ @@ -79,12 +89,12 @@ $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) } %.codecgen.go: $(CODECGEN_EXE) - rm -f $@ && env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145 - cd $(@D) && env -u GOARCH -u GOOS $(GO_ENVS) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) + rm -f $@ && $(UNSET_GOARCH_GOOS) $(GO) build -i -tags $(GO_BUILD_TAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145 + cd $(@D) && $(UNSET_GOARCH_GOOS) $(GO_ENVS) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D))) $(CODECGEN_EXE): $(CODECGEN_DIR)/*.go mkdir -p $(@D) - env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR) + $(UNSET_GOARCH_GOOS) $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR) $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE) time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D) @@ -93,7 +103,7 @@ shell: $(SCOPE_BACKEND_BUILD_UPTODATE) /bin/bash tests: $(SCOPE_BACKEND_BUILD_UPTODATE) - env -u GOGC $(GO_ENVS) ./tools/test -no-go-get + $(UNSET_GOGC) $(GO_ENVS) ./tools/test -no-go-get lint: $(SCOPE_BACKEND_BUILD_UPTODATE) ./tools/lint .