Skip to content

Commit 4221ddf

Browse files
gleiconggerganov
authored andcommitted
go : fixed Makefile for MacOS ARM 64 (ggml-org#1530)
* Fixed Makefile for MacOS ARM 64 based on ggml-org#1344 + proper ggml-metal env var setting * conditional to fix broken non-macos compilation * spaces -> tab * make : fix whitespaces --------- Co-authored-by: Georgi Gerganov <[email protected]>
1 parent 702064a commit 4221ddf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

bindings/go/Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1+
ifndef UNAME_S
2+
UNAME_S := $(shell uname -s)
3+
endif
4+
5+
ifndef UNAME_P
6+
UNAME_P := $(shell uname -p)
7+
endif
8+
9+
ifndef UNAME_M
10+
UNAME_M := $(shell uname -m)
11+
endif
12+
13+
GGML_METAL_PATH_RESOURCES := $(abspath ../..)
114
BUILD_DIR := build
215
MODELS_DIR := models
316
EXAMPLES_DIR := $(wildcard examples/*)
417
INCLUDE_PATH := $(abspath ../..)
518
LIBRARY_PATH := $(abspath ../..)
619

20+
ifeq ($(UNAME_S),Darwin)
21+
EXT_LDFLAGS := -framework Foundation -framework Metal -framework MetalKit
22+
endif
23+
724
all: clean whisper examples
825

926
whisper: mkdir
1027
@echo Build whisper
1128
@${MAKE} -C ../.. libwhisper.a
1229

1330
test: model-small whisper modtidy
31+
ifeq ($(UNAME_S),Darwin)
32+
@C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} GGML_METAL_PATH_RESOURCES=${GGML_METAL_PATH_RESOURCES} go test -ldflags "-extldflags '$(EXT_LDFLAGS)'" -v .
33+
@C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} GGML_METAL_PATH_RESOURCES=${GGML_METAL_PATH_RESOURCES} go test -ldflags "-extldflags '$(EXT_LDFLAGS)'" -v ./pkg/whisper/...
34+
else
1435
@C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} go test -v .
1536
@C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} go test -v ./pkg/whisper/...
37+
endif
1638

1739
examples: $(EXAMPLES_DIR)
1840

@@ -21,7 +43,11 @@ model-small: mkdir examples/go-model-download
2143

2244
$(EXAMPLES_DIR): mkdir whisper modtidy
2345
@echo Build example $(notdir $@)
46+
ifeq ($(UNAME_S),Darwin)
47+
@C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} GGML_METAL_PATH_RESOURCES=${GGML_METAL_PATH_RESOURCES} go build ${BUILD_FLAGS} -ldflags "-extldflags '$(EXT_LDFLAGS)'" -o ${BUILD_DIR}/$(notdir $@) ./$@
48+
else
2449
@C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} go build ${BUILD_FLAGS} -o ${BUILD_DIR}/$(notdir $@) ./$@
50+
endif
2551

2652
mkdir:
2753
@echo Mkdir ${BUILD_DIR}

0 commit comments

Comments
 (0)