Skip to content

Commit fcc7421

Browse files
committed
Makefile: Fix native darwin/macOS builds with forced CGO
1 parent 6722cc8 commit fcc7421

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ VERSION = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH
55
HASH = $(shell git rev-parse --short HEAD)
66
DATE = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \
77
go run tools/build-date.go)
8-
ADDITIONAL_GO_LINKER_FLAGS = $(shell GOOS=$(shell go env GOHOSTOS) \
9-
GOARCH=$(shell go env GOHOSTARCH) \
10-
go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)")
118
GOBIN ?= $(shell go env GOPATH)/bin
129
GOVARS = -X github.com/zyedidia/micro/v2/internal/util.Version=$(VERSION) -X github.com/zyedidia/micro/v2/internal/util.CommitHash=$(HASH) -X 'github.com/zyedidia/micro/v2/internal/util.CompileDate=$(DATE)'
13-
CGO_ENABLED := $(if $(CGO_ENABLED),$(CGO_ENABLED),0)
1410
DEBUGVAR = -X github.com/zyedidia/micro/v2/internal/util.Debug=ON
1511
VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/'
12+
CGO_ENABLED := $(if $(CGO_ENABLED),$(CGO_ENABLED),0)
13+
14+
ADDITIONAL_GO_LINKER_FLAGS := ""
15+
GOHOSTOS = $(shell go env GOHOSTOS)
16+
ifeq ($(GOHOSTOS), darwin)
17+
# Native darwin resp. macOS builds need external and dynamic linking
18+
ADDITIONAL_GO_LINKER_FLAGS += $(shell GOOS=$(GOHOSTOS) \
19+
GOARCH=$(shell go env GOHOSTARCH) \
20+
go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)")
21+
CGO_ENABLED = 1
22+
endif
1623

1724
build: generate build-quick
1825

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ CGO_ENABLED=1 make build
191191

192192
Afterwards the micro binary will dynamically link with the present core system libraries.
193193

194+
**Note for Mac:**
195+
Native macOS builds are done with `CGO_ENABLED=1` forced set to support adding the "Information Property List" in the linker step.
196+
194197
### macOS terminal
195198

196199
If you are using macOS, you should consider using [iTerm2](http://iterm2.com/) instead of the default terminal (Terminal.app). The iTerm2 terminal has much better mouse support as well as better handling of key events. For best keybinding behavior, choose `xterm defaults` under `Preferences->Profiles->Keys->Presets...`, and select `Esc+` for `Left Option Key` in the same menu. The newest versions also support true color.

0 commit comments

Comments
 (0)