-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (54 loc) · 1.67 KB
/
Copy pathMakefile
File metadata and controls
66 lines (54 loc) · 1.67 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -D_GNU_SOURCE
LIBS = -lutil
TARGET = tmux
SOURCES = src/tmux.c
SOCKET_PATH = /tmp/tmux_socket
# Default target
all: $(TARGET)
# Build the main executable
$(TARGET): $(SOURCES)
@echo "Building $(TARGET)..."
$(CC) $(CFLAGS) -o $(TARGET) $(SOURCES) $(LIBS)
@echo "Build complete!"
# Clean build artifacts
clean:
@echo "Cleaning builds..."
rm -f $(TARGET)
rm -f $(SOCKET_PATH)
@echo "Clean complete!"
# Build
build: clean $(TARGET)
# Install system-wide (requires sudo)
install: $(TARGET)
@echo "Installing $(TARGET) to /usr/local/bin/..."
sudo cp $(TARGET) /usr/local/bin/
@echo "Installation complete!"
# Uninstall from system
uninstall:
@echo "Removing $(TARGET) from /usr/local/bin/..."
sudo rm -f /usr/local/bin/$(TARGET)
@echo "Uninstall complete!"
# Debug build with debugging symbols
debug: CFLAGS += -g -DDEBUG
debug: clean $(TARGET)
@echo "Debug build complete with debugging symbols"
# Release build with optimizations
release: CFLAGS += -O2 -DNDEBUG
release: clean $(TARGET)
@echo "Release build complete with optimizations"
# Show help
help:
@echo "Available targets:"
@echo " all - Build the executable (default)"
@echo " clean - Remove build artifacts and socket file"
@echo " build - Clean and build"
@echo " debug - Build with debugging symbols"
@echo " release - Optimized release build"
@echo " install - Install system-wide (requires sudo)"
@echo " uninstall - Remove from system (requires sudo)"
@echo " help - Show this help message"
# Phony targets (don't correspond to files)
.PHONY: all clean build install uninstall debug release help
# Dependency tracking
$(TARGET): $(SOURCES)