-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (35 loc) · 1.7 KB
/
Copy pathMakefile
File metadata and controls
48 lines (35 loc) · 1.7 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
PROG = exodus
CC = gcc
SRC_DIR = src
BUILD_DIR = build
PREFIX = /usr/local
CFLAGS = $(shell pkg-config --cflags sqlite3)
LIBS = $(shell pkg-config --libs sqlite3)
KIK_DEV_CFLAGS ?= -std=c23 -D_POSIX_C_SOURCE=200809L -O0 -Wall -Wextra -Wpedantic -Wformat=2 -Werror -g3 -ggdb3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address,undefined,pointer-compare -fno-stack-clash-protection -fstack-check
KIK_PROD_CFLAGS ?= -std=c23 -D_POSIX_C_SOURCE=200809L -O2 -pipe -march=native
FILES = $(wildcard $(SRC_DIR)/**/*.c) $(wildcard $(SRC_DIR)/*.c)
OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(FILES))
OBJDEV = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o-dev, $(FILES))
.PHONY: all dev install clean analyze
all: $(BUILD_DIR)/$(PROG)
$(BUILD_DIR)/$(PROG): $(OBJ)
@mkdir -p $(dir $@)
$(CC) $(KIK_PROD_CFLAGS) $(CFLAGS) $^ -o $@ $(LIBS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(KIK_PROD_CFLAGS) $(CFLAGS) -c $< -o $@
dev: $(BUILD_DIR)/$(PROG)-dev
@which ctags &>/dev/null && ctags --kinds-C=+p $(FILES) $(wildcard $(SRC_DIR)/**/*.h) $(wildcard $(SRC_DIR)/*.h) $(shell gcc -M $(FILES) $(CFLAGS) $(LIBS) | sed -e 's/[\\ ]/\n/g' | sed -e '/^$$/d' -e '/\.o:[ \t]*$$/d' | sort | uniq) || exit 0
$(BUILD_DIR)/$(PROG)-dev: $(OBJDEV)
@mkdir -p $(dir $@)
$(CC) $(KIK_DEV_CFLAGS) $(CFLAGS) $^ -o $@ $(LIBS)
$(BUILD_DIR)/%.o-dev: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(KIK_DEV_CFLAGS) $(CFLAGS) -c $< -o $@
install: $(BUILD_DIR)/$(PROG)
install -D $< $(PREFIX)/bin/$(PROG)
install -D ./share/exodus.1 $(PREFIX)/share/man/man1/exodus.1
clean:
rm -rf $(BUILD_DIR)
analyze:
scan-build clang $(KIK_PROD_CFLAGS) $(CFLAGS) $(FILES) -o /dev/null $(LIBS)