diff --git a/Makefile b/Makefile index cda7ed9..4e794e4 100644 --- a/Makefile +++ b/Makefile @@ -3,43 +3,66 @@ # Program name PROG = emrys_emotional_simulator +TEST_PROG = emrys_emotional_simulator_test -# Source files (relative to project root) -SRCS = main.c \ - emotional_simulator/emotional_simulator.c \ - emotional_simulator/internal/private_emotional_simulator.c +# 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 += -Iemotional_simulator -CFLAGS += -Iemotional_simulator/internal +CFLAGS += -Isrc +CFLAGS += -Isrc/MODULE_emotional_simulator +CFLAGS += -Isrc/MODULE_emotional_simulator/internal -# Common compiler flags (POSIX-compliant) +# Common compiler flags CFLAGS += -Wall -Wextra -std=c99 -# Debug build (optional) -# CFLAGS += -g -DDEBUG - -# Optimization (optional) -# CFLAGS += -O2 - -# Object files +# Generate object file list with proper paths OBJS = ${SRCS:.c=.o} +TEST_OBJS = ${TEST_SRCS:.c=.o} # Default target all: ${PROG} -# Link the program +# Link the main program ${PROG}: ${OBJS} - ${CC} ${LDFLAGS} -o ${PROG} ${OBJS} + ${CC} ${LDFLAGS} -o $@ ${OBJS} -# Compile C source files to object files -%.o: %.c +# 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} ${PROG} + rm -f ${OBJS} ${TEST_OBJS} + rm -f ${PROG} ${TEST_PROG} # Dist clean (remove all generated files) distclean: clean @@ -53,20 +76,15 @@ install: ${PROG} 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 " 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 tests" + @echo " test - Run test suite" @echo " help - Show this help" .PHONY: all clean distclean install uninstall test help diff --git a/emrys_emotional_simulator b/emrys_emotional_simulator new file mode 100755 index 0000000..d2f167b Binary files /dev/null and b/emrys_emotional_simulator differ diff --git a/src/MODULE_emotional_simulator/emotional_simulator.c b/src/MODULE_emotional_simulator/emotional_simulator.c index f9f077f..4efc14a 100644 --- a/src/MODULE_emotional_simulator/emotional_simulator.c +++ b/src/MODULE_emotional_simulator/emotional_simulator.c @@ -72,15 +72,14 @@ dump_emotion_vector_values(struct emotion_vector_struct* emotion_vector_to_dump) "surprise\0", }; + puts("================================================="); for(uint8_t i = 0; i < NUMBER_OF_EMOTIONS; i++) { - puts("================================================="); printf("| %s: %d\n", emotions_names[i], (int)emotion_vector_to_dump->values[i]); - puts("================================================="); - } + puts("================================================="); } void diff --git a/src/MODULE_emotional_simulator/emotional_simulator.o b/src/MODULE_emotional_simulator/emotional_simulator.o new file mode 100644 index 0000000..b31dbdc Binary files /dev/null and b/src/MODULE_emotional_simulator/emotional_simulator.o differ diff --git a/src/MODULE_emotional_simulator/internal/private_emotional_simulator.o b/src/MODULE_emotional_simulator/internal/private_emotional_simulator.o new file mode 100644 index 0000000..45a27f6 Binary files /dev/null and b/src/MODULE_emotional_simulator/internal/private_emotional_simulator.o differ diff --git a/src/main.c b/src/main.c index b6ccf7b..96a6caf 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ -#include "emotional_simulator/emotional_simulator.h" +#include "MODULE_emotional_simulator/emotional_simulator.h" #include diff --git a/src/main.o b/src/main.o new file mode 100644 index 0000000..a81c7bb Binary files /dev/null and b/src/main.o differ