sparsemap/Makefile

107 lines
3.9 KiB
Makefile
Raw Permalink Normal View History

2024-04-10 20:13:48 +00:00
OBJS = sparsemap.o
STATIC_LIB = libsparsemap.a
SHARED_LIB = libsparsemap.so
2024-05-03 19:15:39 +00:00
LIBS = -lm
2024-05-09 19:57:31 +00:00
#CFLAGS = -Wall -Wextra -Wpedantic -Of -std=c11 -Iinclude/ -fPIC
2024-05-10 15:27:43 +00:00
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC
2024-05-13 16:46:25 +00:00
#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -fPIC
2024-05-21 15:59:07 +00:00
CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Ofast -g -std=c11 -Iinclude/ -fPIC
2024-05-09 19:57:31 +00:00
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC
#CFLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -fPIC
#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -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=c11 -Iinclude/ -fPIC
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -fsanitize=all -fhardened -std=c11 -Iinclude/ -fPIC
#TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -Itests/ -fPIC
2024-05-13 16:46:25 +00:00
TEST_FLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -Itests/ -fPIC
#TEST_FLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -Itests/ -fPIC
2024-05-09 19:57:31 +00:00
#TEST_FLAGS = -DDEBUG -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=c11 -Iinclude/ -fPIC
2024-05-03 19:15:39 +00:00
TESTS = tests/test tests/soak
TEST_OBJS = tests/test.o lib/munit.o lib/tdigest.o lib/common.o
LIB_OBJS = lib/munit.o lib/tdigest.o lib/common.o lib/roaring.o
EXAMPLES = examples/ex_1 examples/ex_2 examples/ex_3 examples/ex_4
2024-04-10 20:13:48 +00:00
.PHONY: all shared static clean test examples mls
all: static shared
static: $(STATIC_LIB)
shared: $(SHARED_LIB)
$(STATIC_LIB): $(OBJS)
ar rcs $(STATIC_LIB) $?
$(SHARED_LIB): $(OBJS)
$(CC) $(CFLAGS) -o $@ $? -shared
2024-05-03 19:15:39 +00:00
examples: $(STATIC_LIB) $(EXAMPLES) $(TEST_OBJS)
2024-04-10 20:13:48 +00:00
mls: examples/mls
2024-05-03 20:03:09 +00:00
tests: $(TESTS)
2024-04-10 20:13:48 +00:00
2024-05-03 20:03:09 +00:00
test: tests
2024-04-10 20:13:48 +00:00
env ASAN_OPTIONS=detect_leaks=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./tests/test
2024-05-03 20:03:09 +00:00
soak: tests
env ASAN_OPTIONS=detect_leaks=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./tests/soak
fuzzer: tests
env ASAN_OPTIONS=detect_leaks=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./tests/fuzzer ./crash.case
2024-05-03 19:15:39 +00:00
tests/test: $(TEST_OBJS) $(LIB_OBJS) $(STATIC_LIB)
2024-05-10 15:27:43 +00:00
$(CC) $^ $(LIBS) -o $@ $(TEST_FLAGS)
2024-04-10 20:13:48 +00:00
clean:
rm -f $(OBJS)
rm -f examples/main.c
rm -f $(STATIC_LIB) $(SHARED_LIB)
rm -f $(TESTS) tests/*.o
rm -f $(EXAMPLES) examples/*.o
format:
clang-format -i src/sparsemap.c include/sparsemap.h examples/ex_*.c tests/soak.c tests/test.c tests/midl.c lib/common.c include/common.h
2024-04-10 20:13:48 +00:00
# clang-format -i include/*.h src/*.c tests/*.c tests/*.h examples/*.c
%.o: src/%.c
$(CC) $(CFLAGS) -c -o $@ $^
2024-05-03 19:15:39 +00:00
lib/%.o: tests/%.c
2024-04-10 20:13:48 +00:00
$(CC) $(CFLAGS) -c -o $@ $^
2024-05-03 19:15:39 +00:00
tests/%.o: tests/%.c
2024-04-10 20:13:48 +00:00
$(CC) $(CFLAGS) -c -o $@ $^
2024-05-03 19:15:39 +00:00
examples/%.o: examples/%.c
2024-04-10 20:13:48 +00:00
$(CC) $(CFLAGS) -c -o $@ $^
2024-05-03 19:15:39 +00:00
examples/ex_1: $(LIB_OBJS) examples/ex_1.o $(STATIC_LIB)
2024-05-09 19:57:31 +00:00
$(CC) $^ $(LIBS) -o $@ $(TEST_FLAGS)
2024-04-10 20:13:48 +00:00
2024-05-03 19:15:39 +00:00
examples/ex_2: $(LIB_OBJS) examples/ex_2.o $(STATIC_LIB)
2024-05-09 19:57:31 +00:00
$(CC) $^ $(LIBS) -o $@ $(TEST_FLAGS)
2024-04-10 20:13:48 +00:00
2024-05-03 19:15:39 +00:00
examples/ex_3: $(LIB_OBJS) examples/ex_3.o $(STATIC_LIB)
2024-05-09 19:57:31 +00:00
$(CC) $^ $(LIBS) -o $@ $(TEST_FLAGS)
2024-04-10 20:13:48 +00:00
2024-05-03 19:15:39 +00:00
examples/ex_4: $(LIB_OBJS) examples/ex_4.o $(STATIC_LIB)
2024-05-09 19:57:31 +00:00
$(CC) $^ $(LIBS) -o $@ $(TEST_FLAGS)
2024-04-10 20:13:48 +00:00
2024-05-03 19:15:39 +00:00
tests/soak: $(LIB_OBJS) tests/soak.o $(STATIC_LIB)
2024-05-09 19:57:31 +00:00
$(CC) $^ $(LIBS) -o $@ $(TEST_FLAGS)
tests/fuzzer: $(LIB_OBJS) tests/fuzzer.o $(STATIC_LIB)
$(CC) $^ $(LIBS) -o $@ $(TEST_FLAGS) -DFUZZ_DEBUG
todo:
rg -i 'todo|gsb|abort'
2024-04-11 03:16:06 +00:00
# cp src/sparsemap.c /tmp && clang-tidy src/sparsemap.c -fix -fix-errors -checks="readability-braces-around-statements" -- -DDEBUG -DSPARSEMAP_DIAGNOSTIC -DSPARSEMAP_ASSERT -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC
2024-04-28 16:26:31 +00:00
# clear; make clean examples test && env ASAN_OPTIONS=detect_leaks=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./tests/test
2024-04-28 16:26:31 +00:00
# clear; make clean examples test && env ASAN_OPTIONS=detect_leaks=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./examples/soak