CC ?= clang
CFLAGS ?= -O3 -Wall -Wextra -std=c11
CPPFLAGS += -Inative
ARCH := $(shell uname -m)
.PHONY: all test clean bench asm-check docker-test rust-test rust-docker-test rust-bench
all: native/tests/test_hashmap
native/hashmap.o: native/hashmap.c native/hashmap.h native/hashmap_impl.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
ifeq ($(ARCH),x86_64)
native/hashmap_ops.o: native/hashmap.S native/hashmap.h
$(CC) $(CFLAGS) -c $< -o $@
else
native/hashmap_ops.o: native/hashmap_ops.c native/hashmap.h native/hashmap_impl.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
endif
native/tests/test_hashmap: native/tests/test_hashmap.c native/hashmap.o native/hashmap_ops.o
$(CC) $(CFLAGS) $(CPPFLAGS) $^ -o $@
native/tests/bench_hashmap: native/tests/bench_hashmap.c native/hashmap.o native/hashmap_ops.o
$(CC) $(CFLAGS) $(CPPFLAGS) $^ -o $@
test: native/tests/test_hashmap
./native/tests/test_hashmap
bench: native/tests/bench_hashmap
./native/tests/bench_hashmap
asm-check:
$(CC) -target x86_64-unknown-linux-gnu -c native/hashmap.S -o /tmp/hashmap_asm.o
docker-test:
docker run --rm --platform linux/amd64 -v "$(CURDIR)":/src:ro alpine:3.20 sh -c \
'apk add --no-cache build-base >/dev/null 2>&1 && cp -r /src /work && cd /work && make clean >/dev/null && make test'
rust-test:
cargo test
rust-docker-test:
docker run --rm --platform linux/amd64 -v "$(CURDIR)":/src:ro rust:1.94-alpine3.23 sh -c \
'apk add --no-cache build-base >/dev/null 2>&1 && cp -r /src /work && cd /work && cargo test --release'
rust-bench:
cargo run --release --example bench
clean:
rm -f native/hashmap.o native/hashmap_ops.o native/tests/test_hashmap native/tests/bench_hashmap