11# Makefile for ML Notes
22
33# Variables
4- BINARY_NAME := ml-notes
4+ CLI_BINARY_NAME := ml-notes-cli
5+ GUI_BINARY_NAME := ml-notes
56VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
67BUILD_TIME := $(shell date -u '+% Y-% m-% d_% H:% M:% S')
78GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
@@ -12,6 +13,19 @@ LDFLAGS := -ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)
1213CGO_ENABLED := 1
1314GOFLAGS := -v
1415
16+ # Go binary paths
17+ GOPATH := $(shell go env GOPATH)
18+ GOBIN := $(shell go env GOBIN)
19+ ifeq ($(GOBIN ) ,)
20+ GOBIN := $(GOPATH)/bin
21+ endif
22+
23+ # Add Go bin to PATH for this Makefile
24+ export PATH := $(PATH ) :$(GOBIN )
25+
26+ # Check if Wails is available (after adding GOBIN to PATH)
27+ WAILS_AVAILABLE := $(shell command -v wails 2> /dev/null)
28+
1529# Directories
1630PREFIX := /usr/local
1731BINDIR := $(PREFIX ) /bin
@@ -41,37 +55,78 @@ endif
4155
4256# Default target
4357.PHONY : all
44- all : build install
58+ all : build-cli build-gui install
4559
46- # Build the binary
60+ # Build both CLI and GUI binaries
4761.PHONY : build
48- build :
49- @echo " Building $( BINARY_NAME) $( VERSION) for $( PLATFORM) /$( ARCH) ..."
62+ build : build-cli build-gui
63+
64+ # Build the CLI binary
65+ .PHONY : build-cli
66+ build-cli :
67+ @echo " Building $( CLI_BINARY_NAME) $( VERSION) for $( PLATFORM) /$( ARCH) ..."
68+ @echo " Go version: $( GO_VERSION) "
69+ @echo " Git commit: $( GIT_COMMIT) "
70+ CGO_ENABLED=$(CGO_ENABLED ) go build $(GOFLAGS ) $(LDFLAGS ) -o $(CLI_BINARY_NAME ) ./app/cli
71+ @echo " CLI build complete: ./$( CLI_BINARY_NAME) "
72+
73+ # Build the GUI binary using Wails
74+ .PHONY : build-gui
75+ build-gui :
76+ ifdef WAILS_AVAILABLE
77+ @echo "Building $(GUI_BINARY_NAME) $(VERSION) using Wails..."
5078 @echo "Go version: $(GO_VERSION)"
5179 @echo "Git commit: $(GIT_COMMIT)"
52- CGO_ENABLED=$(CGO_ENABLED ) go build $(GOFLAGS ) $(LDFLAGS ) -o $(BINARY_NAME ) .
53- @echo " Build complete: ./$( BINARY_NAME) "
80+ wails build -clean -o $(GUI_BINARY_NAME)
81+ @echo "GUI build complete: ./build/bin/$(GUI_BINARY_NAME)"
82+ else
83+ @echo "⚠️ Wails not found. Skipping GUI build."
84+ @echo " Install Wails with: go install github.com/wailsapp/wails/v2/cmd/wails@latest"
85+ endif
86+
87+ # Development build with race detector for CLI
88+ .PHONY : dev-cli
89+ dev-cli :
90+ @echo " Building CLI development version with race detector..."
91+ CGO_ENABLED=1 go build -race $(LDFLAGS ) -o $(CLI_BINARY_NAME ) -dev ./app/cli
92+ @echo " CLI development build complete: ./$( CLI_BINARY_NAME) -dev"
93+
94+ # Development build for GUI using Wails
95+ .PHONY : dev-gui
96+ dev-gui :
97+ ifdef WAILS_AVAILABLE
98+ @echo "Starting Wails development server..."
99+ wails dev
100+ else
101+ @echo "⚠️ Wails not found. Cannot start development server."
102+ @echo " Install Wails with: go install github.com/wailsapp/wails/v2/cmd/wails@latest"
103+ endif
54104
55- # Development build with race detector
105+ # Development build for both
56106.PHONY : dev
57- dev :
58- @echo " Building development version with race detector..."
59- CGO_ENABLED=1 go build -race $(LDFLAGS ) -o $(BINARY_NAME ) -dev .
60- @echo " Development build complete: ./$( BINARY_NAME) -dev"
107+ dev : dev-cli dev-gui
61108
62- # Install the binary to system PATH
109+ # Install binaries to system PATH
63110.PHONY : install
64- install : $(BINARY_NAME )
65- @echo " Installing $( BINARY_NAME) to $( BINDIR) ..."
66- @$(INSTALL_PROGRAM ) $(BINARY_NAME ) $(BINDIR ) /
111+ install : $(CLI_BINARY_NAME ) $(GUI_BINARY_NAME )
112+ @echo " Installing $( CLI_BINARY_NAME) to $( BINDIR) ..."
113+ @$(INSTALL_PROGRAM ) $(CLI_BINARY_NAME ) $(BINDIR ) /
114+ ifdef WAILS_AVAILABLE
115+ @if [ -f "./build/bin/$(GUI_BINARY_NAME)" ]; then \
116+ echo "Installing $(GUI_BINARY_NAME) to $(BINDIR)..."; \
117+ $(INSTALL_PROGRAM) ./build/bin/$(GUI_BINARY_NAME) $(BINDIR)/; \
118+ fi
119+ endif
67120 @echo "Installation complete!"
68- @echo " Run 'ml-notes init' to set up your configuration."
121+ @echo "Run '$(CLI_BINARY_NAME) init' to set up your configuration."
122+ @echo "Run '$(GUI_BINARY_NAME)' to start the desktop application."
69123
70- # Uninstall the binary
124+ # Uninstall the binaries
71125.PHONY : uninstall
72126uninstall :
73- @echo " Removing $( BINARY_NAME) from $( BINDIR) ..."
74- @rm -f $(BINDIR ) /$(BINARY_NAME )
127+ @echo " Removing binaries from $( BINDIR) ..."
128+ @rm -f $(BINDIR ) /$(CLI_BINARY_NAME )
129+ @rm -f $(BINDIR ) /$(GUI_BINARY_NAME )
75130 @echo " Uninstall complete."
76131
77132# Run tests
111166.PHONY : clean
112167clean :
113168 @echo " Cleaning build artifacts..."
114- @rm -f $(BINARY_NAME ) $(BINARY_NAME ) -dev
169+ @rm -f $(CLI_BINARY_NAME ) $(CLI_BINARY_NAME ) -dev
170+ @rm -f $(GUI_BINARY_NAME ) $(GUI_BINARY_NAME ) -dev
171+ @rm -rf build/
115172 @rm -f coverage.out coverage.html
116173 @rm -rf dist/
117174 @echo " Clean complete."
@@ -218,7 +275,9 @@ help:
218275 @echo " ML Notes - Makefile targets:"
219276 @echo " "
220277 @echo " 🏗️ Build targets:"
221- @echo " make build - Build the binary for current platform"
278+ @echo " make build - Build both CLI and GUI binaries"
279+ @echo " make build-cli - Build the CLI binary only"
280+ @echo " make build-gui - Build the GUI binary using Wails"
222281 @echo " make build-native - Build for native platform (auto-detect)"
223282 @echo " make build-linux - Build for Linux AMD64"
224283 @echo " make build-darwin - Build for macOS (Intel & Apple Silicon)"
@@ -229,9 +288,11 @@ help:
229288 @echo " make release - Create release packages for all platforms"
230289 @echo " "
231290 @echo " 🛠️ Development targets:"
232- @echo " make install - Build and install to $( BINDIR) "
233- @echo " make uninstall - Remove from $( BINDIR) "
234- @echo " make dev - Build with race detector"
291+ @echo " make install - Build and install both binaries to $( BINDIR) "
292+ @echo " make uninstall - Remove both binaries from $( BINDIR) "
293+ @echo " make dev - Build CLI with race detector"
294+ @echo " make dev-cli - Build CLI with race detector"
295+ @echo " make dev-gui - Start Wails development server"
235296 @echo " make test - Run tests"
236297 @echo " make test-coverage - Run tests with coverage"
237298 @echo " make lint - Run linters"
@@ -242,16 +303,29 @@ help:
242303 @echo " "
243304 @echo " ℹ️ Information:"
244305 @echo " VERSION=$( VERSION) "
306+ @echo " CLI_BINARY_NAME=$( CLI_BINARY_NAME) "
307+ @echo " GUI_BINARY_NAME=$( GUI_BINARY_NAME) "
245308 @echo " PLATFORM=$( PLATFORM) /$( ARCH) "
246309 @echo " PREFIX=$( PREFIX) "
310+ ifdef WAILS_AVAILABLE
311+ @echo " WAILS=available"
312+ else
313+ @echo " WAILS=not available (GUI builds disabled)"
314+ endif
247315 @echo ""
248316 @echo "📝 Notes:"
317+ @echo " - The CLI binary provides all command-line functionality"
318+ @echo " - The GUI binary is a desktop app built with Wails"
319+ @echo " - Wails is required for GUI builds: go install github.com/wailsapp/wails/v2/cmd/wails@latest"
249320 @echo " - Cross-compilation for macOS/Windows requires appropriate toolchains"
250321 @echo " - For best results, build natively on target platforms"
251322 @echo " - CGO is required for sqlite-vec support"
252323
253- # Ensure binary exists for install target
254- $(BINARY_NAME ) :
255- @$(MAKE ) build
324+ # Ensure binaries exist for install target
325+ $(CLI_BINARY_NAME ) :
326+ @$(MAKE ) build-cli
327+
328+ $(GUI_BINARY_NAME ) :
329+ @$(MAKE ) build-gui
256330
257331.DEFAULT_GOAL := help
0 commit comments