addet makefile for easy installation
This commit is contained in:
parent
348e32a551
commit
b97b89efb8
1 changed files with 68 additions and 0 deletions
68
Makefile
Normal file
68
Makefile
Normal file
|
@ -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"
|
Loading…
Add table
Add a link
Reference in a new issue