CC ?= cc
CFLAGS := -std=c23 -O3 -Wall -Werror -fPIC -c

BUILD_DIR := build
TARGET := $(BUILD_DIR)/libsafec.a

SRCS := $(wildcard *.c)
OBJS := $(patsubst %.c,$(BUILD_DIR)/%.o,$(SRCS))

.PHONY: all clean

all: $(BUILD_DIR) $(TARGET)

$(BUILD_DIR):
	mkdir -p $(BUILD_DIR)

$(TARGET): $(OBJS)
	ar rcs $@ $^

$(BUILD_DIR)/%.o: %.c
	$(CC) $(CFLAGS) $< -o $@

clean:
	rm -rf $(BUILD_DIR)
