From b97b89efb80ce3e6919221f4d6f8e477dafae0bf Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 9 Dec 2024 23:08:29 +0100 Subject: [PATCH] addet makefile for easy installation --- Makefile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f329532 --- /dev/null +++ b/Makefile @@ -0,0 +1,68 @@ +# 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" \ No newline at end of file