-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (59 loc) · 2.6 KB
/
Makefile
File metadata and controls
66 lines (59 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
.PHONY: build build-voice install install-voice clean deps
PREFIX := $(CURDIR)/build/whisper
BUILD_DIR := $(CURDIR)/build/cmake
UNAME := $(shell uname)
PC_DIR := $(PREFIX)/lib/pkgconfig
# Default build: no voice/whisper support (works on all platforms)
build:
go build -o ccc
@if [ "$(UNAME)" = "Darwin" ]; then \
codesign -f -s - ccc 2>/dev/null || true; \
fi
# Build whisper.cpp C library (needed for voice support)
deps:
@if [ ! -f "$(PREFIX)/lib/libwhisper.a" ]; then \
echo "Building whisper.cpp..."; \
git submodule update --init --recursive; \
cmake -S third_party/whisper.cpp -B $(BUILD_DIR) \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_EXAMPLES=OFF \
-DWHISPER_BUILD_SERVER=OFF; \
cmake --build $(BUILD_DIR) --config Release -j$$(nproc 2>/dev/null || sysctl -n hw.ncpu); \
cmake --install $(BUILD_DIR) --prefix $(PREFIX); \
else \
echo "whisper.cpp already built"; \
fi
@# Generate pkg-config files matching go-whisper expectations
@mkdir -p "$(PC_DIR)"
@printf 'prefix=%s\nlibdir=$${prefix}/lib\nincludedir=$${prefix}/include\n\nName: libwhisper\nDescription: whisper.cpp\nVersion: 0.0.0\nCflags: -I$${includedir}\n' "$(PREFIX)" > "$(PC_DIR)/libwhisper.pc"
@if [ "$(UNAME)" = "Darwin" ]; then \
printf 'prefix=%s\nlibdir=$${prefix}/lib\n\nName: libwhisper-darwin\nDescription: whisper.cpp (darwin)\nVersion: 0.0.0\nLibs: -L$${libdir} -lwhisper -lggml -lggml-base -lggml-cpu -lggml-blas -lggml-metal -lstdc++ -framework Accelerate -framework Metal -framework Foundation -framework CoreGraphics\n' "$(PREFIX)" > "$(PC_DIR)/libwhisper-darwin.pc"; \
else \
printf 'prefix=%s\nlibdir=$${prefix}/lib\n\nName: libwhisper-linux\nDescription: whisper.cpp (linux)\nVersion: 0.0.0\nCflags: -fopenmp\nLibs: -L$${libdir} -lwhisper -lggml -lggml-base -lggml-cpu -lgomp -lm -lstdc++ -lpthread\n' "$(PREFIX)" > "$(PC_DIR)/libwhisper-linux.pc"; \
fi
# Build with voice/whisper support (requires FFmpeg 7.x + cmake)
build-voice: deps
PKG_CONFIG_PATH="$(PC_DIR)" CGO_LDFLAGS_ALLOW="-(W|D).*" \
go build -tags voice -o ccc
@if [ "$(UNAME)" = "Darwin" ]; then \
codesign -f -s - ccc 2>/dev/null || true; \
fi
install: build
mkdir -p ~/bin
install -m 755 ccc ~/bin/ccc
@if [ "$(UNAME)" = "Darwin" ]; then \
codesign -f -s - ~/bin/ccc 2>/dev/null || true; \
fi
@echo "✅ Installed to ~/bin/ccc"
install-voice: build-voice
mkdir -p ~/bin
install -m 755 ccc ~/bin/ccc
@if [ "$(UNAME)" = "Darwin" ]; then \
codesign -f -s - ~/bin/ccc 2>/dev/null || true; \
fi
@echo "✅ Installed to ~/bin/ccc (with voice support)"
clean:
rm -f ccc
rm -rf build/