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-15 01:00:02 +00:00
|
|
|
CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -fPIC
|
|
|
|
#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -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
|
|
|
|
|
2024-05-15 01:00:02 +00:00
|
|
|
TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -Itests/ -fPIC
|
|
|
|
#TEST_FLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -Itests/ -fPIC
|
2024-05-13 16:46:25 +00:00
|
|
|
#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
|
|
|
|
|
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:
|
2024-05-03 19:15:39 +00:00
|
|
|
clang-format -i src/sparsemap.c include/sparsemap.h examples/ex_*.c tests/soak.c tests/test.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)
|
2024-04-26 20:25:17 +00:00
|
|
|
|
2024-04-24 20:32:09 +00:00
|
|
|
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
|
|
|
|
2024-04-26 20:25:17 +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
|