Something went wrong. Try again.
Something went wrong. Try again.
voice-assistant Makefile
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116# Voice Assistant Client Makefile
BINARY_NAME = voice-clientINSTALL_DIR = $(HOME)/.local/binSYSTEMD_DIR = $(HOME)/.config/systemd/userGO_FILES = cmd/client/main.goGO_MOD = cmd/client/go.mod
# Server IP - pass as IP=xxx or set defaultIP ?= localhost
.PHONY: all build install clean run test
# Default target: build binaryall: build
# Build the Go binarybuild: @echo "Building $(BINARY_NAME)..." @mkdir -p out @cd cmd/client && go build -o ../../out/$(BINARY_NAME) . @echo "Built: out/$(BINARY_NAME)"
# Build for different platformsbuild-linux-amd64: @mkdir -p out @cd cmd/client && GOOS=linux GOARCH=amd64 go build -o ../../out/$(BINARY_NAME)-linux-amd64 . @echo "Built: out/$(BINARY_NAME)-linux-amd64"
build-linux-arm64: @mkdir -p out @cd cmd/client && GOOS=linux GOARCH=arm64 go build -o ../../out/$(BINARY_NAME)-linux-arm64 . @echo "Built: out/$(BINARY_NAME)-linux-arm64"
# Install binary and systemd unitinstall: build @echo "Installing to $(INSTALL_DIR)..." @mkdir -p $(INSTALL_DIR) @cp out/$(BINARY_NAME) $(INSTALL_DIR)/
@echo "Installing systemd service (server: $(IP))..." @mkdir -p $(SYSTEMD_DIR) @sed -e 's|ws://10.2.0.184:8888|ws://$(IP):8888|g' \ -e 's|%h/voice-assistant/out/voice-client|$(INSTALL_DIR)/$(BINARY_NAME)|g' \ voice-client-go.service > $(SYSTEMD_DIR)/voice-client.service
@echo "Reloading systemd..." @systemctl --user daemon-reload
@echo "Done! Run 'make enable' to start the service."
# Enable and start the serviceenable: @echo "Enabling and starting voice-client service..." @systemctl --user enable --now voice-client @echo "Service started. Check status with: systemctl --user status voice-client"
# Disable and stop the servicedisable: @echo "Stopping and disabling voice-client service..." @systemctl --user stop voice-client @systemctl --user disable voice-client
# Uninstalluninstall: @echo "Uninstalling..." @systemctl --user stop voice-client || true @systemctl --user disable voice-client || true @rm -f $(INSTALL_DIR)/$(BINARY_NAME) @rm -f $(SYSTEMD_DIR)/voice-client-go.service @systemctl --user daemon-reload @echo "Uninstalled."
# Run the binary directly (for testing)run: build @./out/$(BINARY_NAME) --server ws://$(IP):8888
# Show statusstatus: @systemctl --user status voice-client || echo "Service not running"
# Show logslogs: @journalctl --user -u voice-client -f
# Clean build artifactsclean: @rm -rf out/ @cd cmd/client && rm -f $(BINARY_NAME) @echo "Cleaned."
# Show helphelp: @echo "Voice Assistant Client Makefile" @echo "" @echo "Usage:" @echo " make IP=10.2.0.184 install # Install with specific server IP" @echo " make IP=10.2.0.184 run # Run with specific server IP" @echo "" @echo "Targets:" @echo " make build Build the binary (default)" @echo " make install Install binary and systemd unit" @echo " make enable Start the service" @echo " make disable Stop the service" @echo " make uninstall Remove binary and service" @echo " make status Show service status" @echo " make logs Show service logs" @echo " make clean Remove build artifacts" @echo " make run Build and run locally" @echo " make help Show this help" @echo "" @echo "Examples:" @echo " make install # Install with default IP (localhost)" @echo " make IP=192.168.1.100 install # Install with custom IP" @echo " make IP=10.2.0.184 run # Run with custom IP"