# Basic variables BINARY_NAME=ytgo GO=go INSTALL_PATH=/usr/local/bin # Build flags LDFLAGS=-s -w BUILD_FLAGS=-ldflags="$(LDFLAGS)" # Get the current git commit hash GIT_HASH=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") VERSION?=1.0.0 .PHONY: all build clean install uninstall deps test # Default target all: clean build # Build the application build: @echo "Building $(BINARY_NAME)..." $(GO) build $(BUILD_FLAGS) -o $(BINARY_NAME) # Install dependencies deps: @echo "Installing dependencies..." $(GO) mod download @echo "Checking for mpv..." @which mpv > /dev/null || (echo "mpv not found. Please install mpv player." && exit 1) # Clean build artifacts clean: @echo "Cleaning..." rm -f $(BINARY_NAME) $(GO) clean # Install the application install: deps build @echo "Installing $(BINARY_NAME) to $(INSTALL_PATH)..." sudo mv $(BINARY_NAME) $(INSTALL_PATH)/$(BINARY_NAME) @echo "Installation complete! You can now run '$(BINARY_NAME)' from anywhere." # Uninstall the application uninstall: @echo "Uninstalling $(BINARY_NAME)..." sudo rm -f $(INSTALL_PATH)/$(BINARY_NAME) @echo "Uninstall complete!" # Run tests test: $(GO) test ./... # Run the application run: build ./$(BINARY_NAME) # Help target help: @echo "Available targets:" @echo " make - Clean and build the application" @echo " make build - Build the application" @echo " make clean - Remove build artifacts" @echo " make deps - Install dependencies" @echo " make install - Install the application to $(INSTALL_PATH)" @echo " make uninstall- Remove the installed application" @echo " make test - Run tests" @echo " make run - Build and run the application" @echo " make help - Show this help message"