skiplist/Makefile

67 lines
1.4 KiB
Makefile
Raw Normal View History

2024-03-15 18:35:47 +00:00
2024-03-14 18:45:04 +00:00
OBJS = skiplist.o
STATIC_LIB = libskiplist.a
SHARED_LIB = libskiplist.so
2024-03-17 14:40:59 +00:00
CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c99 -Iinclude/ -fPIC
TEST_FLAGS = -Itests/
#-fsanitize=address,undefined
2024-03-14 18:45:04 +00:00
2024-03-17 14:40:59 +00:00
TESTS = tests/test
TEST_OBJS = tests/test.o tests/munit.o
EXAMPLES = examples/skip examples/slm
2024-03-14 18:45:04 +00:00
2024-03-17 14:40:59 +00:00
.PHONY: all shared static clean test examples mls
2024-03-14 18:45:04 +00:00
all: static shared
static: $(STATIC_LIB)
shared: $(SHARED_LIB)
$(STATIC_LIB): $(OBJS)
ar rcs $(STATIC_LIB) $?
$(SHARED_LIB): $(OBJS)
$(CC) $(CFLAGS) -o $@ $? -shared
2024-03-17 14:40:59 +00:00
examples: $(EXAMPLES)
mls: examples/mls
2024-03-15 18:35:47 +00:00
2024-03-15 18:40:01 +00:00
test: $(TESTS)
2024-03-14 18:45:04 +00:00
./tests/test
2024-03-15 20:24:08 +00:00
# env LSAN_OPTIONS=verbosity=1:log_threads=1 ./tests/test
2024-03-14 18:45:04 +00:00
2024-03-17 14:40:59 +00:00
tests/test: $(TEST_OBJS) $(STATIC_LIB)
2024-03-14 18:45:04 +00:00
$(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -pthread
clean:
2024-03-15 18:40:01 +00:00
rm -f $(OBJS) munit.o test.o
2024-03-17 14:40:59 +00:00
rm -f examples/mls.c
2024-03-14 18:45:04 +00:00
rm -f $(STATIC_LIB)
rm -f $(TESTS)
rm -f $(EXAMPLES)
2024-03-15 18:35:47 +00:00
2024-03-14 18:45:04 +00:00
format:
2024-03-19 01:19:26 +00:00
clang-format -i include/*.h src/*.c tests/*.c tests/*.h examples/*.c
2024-03-17 14:40:59 +00:00
%.o: src/%.c
$(CC) $(CFLAGS) -c -o $@ $^
tests/%.o: tests/%.c
$(CC) $(CFLAGS) -c -o $@ $^
examples/%.o: examples/%.c
$(CC) $(CFLAGS) -c -o $@ $^
examples/mls.c: examples/slm.c
$(CC) $(CFLAGS) -C -E examples/slm.c | sed -e '1,7d' -e '/^# [0-9]* "/d' | clang-format > examples/mls.c
examples/mls: examples/mls.o $(STATIC_LIB)
$(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -pthread
2024-03-19 01:19:26 +00:00
#dot:
# ./examples/mls
# dot -Tpdf /tmp/slm.dot -o /tmp/slm.pdf >/dev/null 2>&1