40 lines
938 B
Makefile
40 lines
938 B
Makefile
# shellcheck disable=SC2046,SC2035,SC2215,SC2285,SC2276,SC2068
|
|
CC ?= cc
|
|
CFLAGS ?= -std=c17 -Wall -Wextra -Wpedantic -Werror -g
|
|
CPPFLAGS += -Iinclude -MMD -MP
|
|
SANFLAGS := -fsanitize=address,undefined -fno-omit-frame-pointer
|
|
|
|
SRC := $(wildcard src/*.c)
|
|
OBJ := $(SRC:src/%.c=build/%.o)
|
|
DEP := $(OBJ:.o=.d)
|
|
BIN := build/recman
|
|
ASAN := build/recman_asan
|
|
|
|
all: $(BIN)
|
|
|
|
$(BIN): $(OBJ)
|
|
$(CC) $(CFLAGS) $^ -o $@
|
|
|
|
$(ASAN): $(SRC)
|
|
$(CC) $(CFLAGS) $(SANFLAGS) $(CPPFLAGS) $^ -o $@
|
|
|
|
build/%.o: src/%.c | build
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
|
|
|
build:
|
|
mkdir -p build
|
|
|
|
asan: $(ASAN)
|
|
|
|
test: $(BIN) $(ASAN)
|
|
ASAN_OPTIONS=detect_leaks=0 sh tests/smoke.sh $(BIN)
|
|
ASAN_OPTIONS=detect_leaks=0 sh tests/smoke.sh $(ASAN)
|
|
$(CC) $(CFLAGS) $(SANFLAGS) $(CPPFLAGS) -Itests tests/unit.c $(filter-out src/main.c,$(SRC)) -o build/unit_asan
|
|
ASAN_OPTIONS=detect_leaks=0 ./build/unit_asan
|
|
|
|
clean:
|
|
rm -rf build
|
|
|
|
-include $(DEP)
|
|
|
|
.PHONY: all asan test clean
|