This repository was archived by the owner on Mar 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (55 loc) · 1.43 KB
/
Makefile
File metadata and controls
66 lines (55 loc) · 1.43 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
# Compiler and flags
CC := gcc
CFLAGS := -Wall -Wextra -Iinclude
LDFLAGS := -lncurses -lX11 -lXtst
DEBUGFLAGS := -g
RELEASEFLAGS := -O2
# Directories
SRC_DIR := src
INCLUDE_DIR := include
BUILD_DIR := build
BIN_DIR := bin
# Executable name
TARGET := autoclicker
# Automatically detect source and object files
SRCS := $(wildcard $(SRC_DIR)/*.c)
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
# Default target: release build
.PHONY: all
all: release
# -----------------------------
# Release build
# -----------------------------
.PHONY: release
release: CFLAGS += $(RELEASEFLAGS)
release: dirs $(BIN_DIR)/$(TARGET)
# -----------------------------
# Debug build
# -----------------------------
.PHONY: debug
debug: CFLAGS += $(DEBUGFLAGS)
debug: dirs $(BIN_DIR)/$(TARGET)
# -----------------------------
# Build executable
# -----------------------------
$(BIN_DIR)/$(TARGET): $(OBJS)
$(CC) $(OBJS) $(LDFLAGS) -o $@
# -----------------------------
# Build object files with dependency tracking
# -----------------------------
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
# Include dependency files
-include $(OBJS:.o=.d)
# -----------------------------
# Create necessary directories
# -----------------------------
.PHONY: dirs
dirs:
@mkdir -p $(BUILD_DIR) $(BIN_DIR)
# -----------------------------
# Clean build artifacts
# -----------------------------
.PHONY: clean
clean:
$(RM) -r $(BUILD_DIR)/* $(BIN_DIR)/*