2023-11-22 16:08:11 +00:00
i f n d e f U N A M E _ S
UNAME_S := $( shell uname -s)
e n d i f
i f n d e f U N A M E _ P
UNAME_P := $( shell uname -p)
e n d i f
i f n d e f U N A M E _ M
UNAME_M := $( shell uname -m)
e n d i f
GGML_METAL_PATH_RESOURCES := $( abspath ../..)
2023-01-06 17:32:28 +00:00
BUILD_DIR := build
MODELS_DIR := models
2022-12-20 06:54:33 +00:00
EXAMPLES_DIR := $( wildcard examples/*)
2024-08-28 14:09:01 +00:00
INCLUDE_PATH := $( abspath ../../include) :$( abspath ../../ggml/include)
2023-01-06 17:32:28 +00:00
LIBRARY_PATH := $( abspath ../..)
2022-12-20 06:54:33 +00:00
2023-11-22 16:08:11 +00:00
i f e q ( $( UNAME_S ) , D a r w i n )
EXT_LDFLAGS := -framework Foundation -framework Metal -framework MetalKit
e n d i f
2022-12-20 06:54:33 +00:00
all : clean whisper examples
whisper : mkdir
@echo Build whisper
2023-01-06 17:32:28 +00:00
@${ MAKE } -C ../.. libwhisper.a
2022-12-20 06:54:33 +00:00
2022-12-22 14:34:20 +00:00
test : model -small whisper modtidy
2023-11-22 16:08:11 +00:00
i f e q ( $( UNAME_S ) , D a r w i n )
@C_INCLUDE_PATH= ${ INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } GGML_METAL_PATH_RESOURCES = ${ GGML_METAL_PATH_RESOURCES } go test -ldflags " -extldflags ' $( EXT_LDFLAGS) ' " -v .
@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/...
e l s e
2023-01-06 17:32:28 +00:00
@C_INCLUDE_PATH= ${ INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } go test -v .
@C_INCLUDE_PATH= ${ INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } go test -v ./pkg/whisper/...
2023-11-22 16:08:11 +00:00
e n d i f
2022-12-20 06:54:33 +00:00
examples : $( EXAMPLES_DIR )
model-small : mkdir examples /go -model -download
2023-01-06 17:32:28 +00:00
@${ BUILD_DIR } /go-model-download -out models ggml-small.en.bin
2022-12-20 06:54:33 +00:00
2022-12-22 14:34:20 +00:00
$(EXAMPLES_DIR) : mkdir whisper modtidy
2022-12-20 06:54:33 +00:00
@echo Build example $( notdir $@ )
2023-11-22 16:08:11 +00:00
i f e q ( $( UNAME_S ) , D a r w i n )
@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 $@ ) ./$@
e l s e
2023-01-06 17:32:28 +00:00
@C_INCLUDE_PATH= ${ INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } go build ${ BUILD_FLAGS } -o ${ BUILD_DIR } /$( notdir $@ ) ./$@
2023-11-22 16:08:11 +00:00
e n d i f
2022-12-20 06:54:33 +00:00
mkdir :
@echo Mkdir ${ BUILD_DIR }
@install -d ${ BUILD_DIR }
@echo Mkdir ${ MODELS_DIR }
@install -d ${ MODELS_DIR }
2022-12-22 14:34:20 +00:00
modtidy :
@go mod tidy
2023-06-25 11:07:55 +00:00
clean :
2022-12-20 06:54:33 +00:00
@echo Clean
@rm -fr $( BUILD_DIR)
@go clean