-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (27 loc) · 777 Bytes
/
Makefile
File metadata and controls
35 lines (27 loc) · 777 Bytes
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
CC = clang
BUILD_DIR = build
SRC_FILES = src/*.c
TARGET = $(BUILD_DIR)/timer
CFLAGS = -Wall -Wextra -std=c11 -Iheader
CLANGD_FILE = compile_commands.json
.PHONY: all clean run clangd_gen
all: $(TARGET)
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
$(TARGET): $(SRC_FILES) | $(BUILD_DIR)
@echo "Building $(TARGET)..."
$(CC) $(CFLAGS) $(SRC_FILES) -o $(TARGET)
run: $(TARGET)
@echo "Running $(TARGET)..."
@./$(TARGET)
clangd_gen:
@echo "Generating $(CLANGD_FILE) for clangd..."
@if ! command -v bear &> /dev/null; then \
echo "Error: 'bear' command not found. Please install it (e.g., 'sudo apt install bear' or 'brew install bear')."; \
exit 1; \
fi
@bear -- $(MAKE) $(TARGET)
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@rm -f $(CLANGD_FILE)