skiplist/Makefile

51 lines
958 B
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 18:35:47 +00:00
TEST_FLAGS = -std=c99 -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-14 18:45:04 +00:00
tests: $(TESTS)
./tests/test
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:
rm -f $(OBJS)
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:
clang-format -i include/*.h src/*.c tests/*.c