-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (36 loc) · 1.08 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Variables
BINARY_NAME = gt
SOURCE_FILES = $(wildcard *.go)
MAN_DIR = /usr/local/share/man/man1
MAN_PAGE = $(BINARY_NAME).1
# Default target
all: build
# Build the Go binary
build: $(SOURCE_FILES)
@echo "Building $(BINARY_NAME)..."
@go build -o $(BINARY_NAME)
# Install the binary and the man page
install: build
@echo "Installing $(BINARY_NAME) to /usr/local/bin..."
@sudo install -m 0755 $(BINARY_NAME) /usr/local/bin/$(BINARY_NAME)
@echo "Installing man page to $(MAN_DIR)..."
@sudo install -m 0644 $(MAN_PAGE) $(MAN_DIR)/$(MAN_PAGE)
@echo "Installation complete."
# Uninstall the binary and the man page
uninstall:
@echo "Uninstalling $(BINARY_NAME) from /usr/local/bin..."
@sudo rm -f /usr/local/bin/$(BINARY_NAME)
@echo "Uninstalling man page from $(MAN_DIR)..."
@sudo rm -f $(MAN_DIR)/$(MAN_PAGE)
@echo "Uninstallation complete."
# Clean up build artifacts
clean:
@echo "Cleaning up..."
@rm -f $(BINARY_NAME)
@echo "Cleanup complete."
# Generate the man page
man:
@echo "Generating man page..."
@man ./$(MAN_PAGE)
# Phony targets
.PHONY: all build install uninstall clean man