skiplist/Makefile

80 lines
2.2 KiB
Makefile
Raw Normal View History

2024-03-15 18:35:47 +00:00
2024-04-08 15:18:36 +00:00
OBJS =
STATIC_LIB =
SHARED_LIB =
2024-03-14 18:45:04 +00:00
2024-04-01 18:26:44 +00:00
# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
#CFLAGS = -Wall -Wextra -Wpedantic -Of -std=c99 -Iinclude/ -fPIC
2024-04-03 19:40:39 +00:00
CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c99 -Iinclude/ -fPIC
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -fsanitize=address,leak,object-size,pointer-compare,pointer-subtract,null,return,bounds,pointer-overflow,undefined -fsanitize-address-use-after-scope -std=c99 -Iinclude/ -fPIC
2024-04-03 13:50:31 +00:00
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -fsanitize=all -fhardened -std=c99 -Iinclude/ -fPIC
#env ASAN_OPTIONS=detect_leaks=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./examples/mls
2024-03-17 14:40:59 +00:00
TEST_FLAGS = -Itests/
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
2024-04-08 13:24:00 +00:00
EXAMPLES = examples/ex1.c
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-04-01 01:22:04 +00:00
$(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -lm -pthread
2024-03-14 18:45:04 +00:00
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)
2024-04-08 13:24:00 +00:00
rm -f $(SHARED_LIB)
2024-03-14 18:45:04 +00:00
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 $@ $^
2024-04-08 13:24:00 +00:00
examples/mls.c: examples/ex1.c
$(CC) $(CFLAGS) -C -E examples/ex1.c | sed -e '1,7d' -e '/^# [0-9]* "/d' | clang-format > examples/mls.c
2024-03-26 00:17:40 +00:00
2024-03-17 14:40:59 +00:00
examples/mls: examples/mls.o $(STATIC_LIB)
2024-04-01 01:22:04 +00:00
$(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -lm -pthread
2024-03-19 01:19:26 +00:00
#dot:
# ./examples/mls
2024-04-08 15:18:36 +00:00
# dot -Tpdf /tmp/ex1.dot -o /tmp/ex1.pdf >/dev/null 2>&1
2024-04-08 13:24:00 +00:00
#re-write CPP line information comments, but keep them
# $(CC) $(CFLAGS) -C -E examples/ex1.c | sed -e '1,7d' -e 's/^#\( [0-9]* ".*$$\)/\/\* \1 \*\//' | clang-format > examples/mls.c
# workflow:
2024-04-08 15:18:36 +00:00
# clear; rm examples/mls.c; make examples/mls && env ASAN_OPTIONS=detect_leaks=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./examples/mls #&& dot -Tpdf /tmp/ex1.dot -o /tmp/ex1.pdf
2024-04-08 13:24:00 +00:00
# cp include/sl.h /tmp/foo; clang-format -i include/sl.h