skiplist/Makefile

53 lines
1 KiB
Makefile
Raw Normal View History

2024-03-15 18:35:47 +00:00
2024-03-14 18:45:04 +00:00
CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c99 -Iinclude/ -fPIC
2024-03-15 20:24:08 +00:00
TEST_FLAGS = -Itests/
#-fsanitize=address,undefined
2024-03-14 18:45:04 +00:00
OBJS = skiplist.o
STATIC_LIB = libskiplist.a
SHARED_LIB = libskiplist.so
TESTS = tests/test
EXAMPLES = examples/example
.PHONY: all shared static clean tests examples
%.o: src/%.c
$(CC) $(CFLAGS) -c -o $@ $^
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-15 18:35:47 +00:00
tests/%.o: tests/%.c
$(CC) $(CFLAGS) -c -o $@ $^
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-15 18:35:47 +00:00
tests/test: tests/test.o tests/munit.o $(STATIC_LIB)
$(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -pthread
2024-03-14 18:45:04 +00:00
examples: $(EXAMPLES)
examples/example: examples/example.c $(STATIC_LIB)
$(CC) $^ -o $@ $(CFLAGS) $(TEST_FLAGS) -pthread
clean:
2024-03-15 18:40:01 +00:00
rm -f $(OBJS) munit.o test.o
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-15 20:24:08 +00:00
clang-format -i include/*.h src/*.c tests/*.c tests/*.h