# Makefile for emrys_emotional_simulator
# POSIX-compatible bmake build system

# Program name
PROG = emrys_emotional_simulator

# Source files (relative to project root)
SRCS = main.c \
       emotional_simulator/emotional_simulator.c \
       emotional_simulator/internal/private_emotional_simulator.c

# Header search paths
CFLAGS += -I.
CFLAGS += -Iemotional_simulator
CFLAGS += -Iemotional_simulator/internal

# Common compiler flags (POSIX-compliant)
CFLAGS += -Wall -Wextra -std=c99

# Debug build (optional)
# CFLAGS += -g -DDEBUG

# Optimization (optional)
# CFLAGS += -O2

# Object files
OBJS = ${SRCS:.c=.o}

# Default target
all: ${PROG}

# Link the program
${PROG}: ${OBJS}
	${CC} ${LDFLAGS} -o ${PROG} ${OBJS}

# Compile C source files to object files
%.o: %.c
	${CC} ${CFLAGS} -c $< -o $@

# Clean build artifacts
clean:
	rm -f ${OBJS} ${PROG}

# Dist clean (remove all generated files)
distclean: clean

# Install (optional)
install: ${PROG}
	install -d ${DESTDIR}/usr/local/bin
	install -m 755 ${PROG} ${DESTDIR}/usr/local/bin/

# Uninstall (optional)
uninstall:
	rm -f ${DESTDIR}/usr/local/bin/${PROG}

# Run tests (if tests exist)
test: ${PROG}
	@echo "Running tests..."
	@# Add test commands here when tests are implemented

# Show help
help:
	@echo "Available targets:"
	@echo "  all        - Build the program (default)"
	@echo "  clean      - Remove object files and binary"
	@echo "  distclean  - Remove all generated files"
	@echo "  install    - Install to DESTDIR"
	@echo "  uninstall  - Remove from DESTDIR"
	@echo "  test       - Run tests"
	@echo "  help       - Show this help"

.PHONY: all clean distclean install uninstall test help
