-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (46 loc) · 1.37 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
CC = gcc
CFLAGS = -Iinclude
LDFLAGS = -lsqlite3 -lyaml -lcjson -lm
SRC_DIR = src
INCLUDE_DIR = include
BUILD_DIR = build
ifdef SANITIZE
CFLAGS += -fsanitize=address,undefined
LDFLAGS += -fsanitize=address,undefined
endif
ifndef RELEASE
CFLAGS += -DDEBUG -ggdb -Wall
else
CFLAGS += -O3
endif
# List all the source files
SRC_FILES := $(shell find $(SRC_DIR) -name '*.c')
# Generate the corresponding object file names
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRC_FILES))
# Target: the final executable
TARGET = changelogger
# Default target, build the executable
all: $(BUILD_DIR) $(TARGET)
# Rule to create the build directory
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/commands
# Rule to build the executable
$(TARGET): $(OBJ_FILES)
$(CC) -o $@ $^ $(LDFLAGS)
# Rule to build object files from source files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
# Clean rule to remove generated files
clean:
rm -rf $(BUILD_DIR) $(TARGET)
compile_commands.json: $(SRC_FILES)
bear -- make
install:
./config.sh install
autocomplete:
complgen aot ./docs/changelogger.usage --zsh-script ./docs/_changelogger.zsh
complgen aot ./docs/changelogger.usage --bash-script ./docs/_changelogger.bash
complgen aot ./docs/changelogger.usage --fish-script ./docs/_changelogger.fish
# Phony target to avoid conflicts with file names
.PHONY: all clean