Files
emrys_emotional_simulator/Makefile

91 lines
2.4 KiB
Makefile

# Makefile for emrys_emotional_simulator
# POSIX-compatible bmake build system
# Program name
PROG = emrys_emotional_simulator
TEST_PROG = emrys_emotional_simulator_test
# Source files
SRCS = src/main.c \
src/MODULE_emotional_simulator/emotional_simulator.c \
src/MODULE_emotional_simulator/internal/private_emotional_simulator.c
# Test source files
TEST_SRCS = src/main_test.c \
src/MODULE_emotional_simulator/tests/test_emotional_simulator.c
# Header search paths
CFLAGS += -I.
CFLAGS += -Isrc
CFLAGS += -Isrc/MODULE_emotional_simulator
CFLAGS += -Isrc/MODULE_emotional_simulator/internal
# Common compiler flags
CFLAGS += -Wall -Wextra -std=c99
# Generate object file list with proper paths
OBJS = ${SRCS:.c=.o}
TEST_OBJS = ${TEST_SRCS:.c=.o}
# Default target
all: ${PROG}
# Link the main program
${PROG}: ${OBJS}
${CC} ${LDFLAGS} -o $@ ${OBJS}
# Link the test program
${TEST_PROG}: ${TEST_OBJS}
${CC} ${LDFLAGS} -o $@ ${TEST_OBJS}
# Explicit rules for each source file to ensure .o goes with .c
src/main.o: src/main.c
${CC} ${CFLAGS} -c $< -o $@
src/MODULE_emotional_simulator/emotional_simulator.o: src/MODULE_emotional_simulator/emotional_simulator.c
${CC} ${CFLAGS} -c $< -o $@
src/MODULE_emotional_simulator/internal/private_emotional_simulator.o: src/MODULE_emotional_simulator/internal/private_emotional_simulator.c
${CC} ${CFLAGS} -c $< -o $@
src/main_test.o: src/main_test.c
${CC} ${CFLAGS} -c $< -o $@
src/MODULE_emotional_simulator/tests/test_emotional_simulator.o: src/MODULE_emotional_simulator/tests/test_emotional_simulator.c
${CC} ${CFLAGS} -c $< -o $@
# Run tests
test: ${TEST_PROG}
@echo "Running tests..."
./${TEST_PROG}
# Clean build artifacts
clean:
rm -f ${OBJS} ${TEST_OBJS}
rm -f ${PROG} ${TEST_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}
# Show help
help:
@echo "Available targets:"
@echo " all - Build the program (default)"
@echo " clean - Remove object files and binaries"
@echo " distclean - Remove all generated files"
@echo " install - Install to DESTDIR"
@echo " uninstall - Remove from DESTDIR"
@echo " test - Run test suite"
@echo " help - Show this help"
.PHONY: all clean distclean install uninstall test help