From 12a1b2269c64bfbe61490a9a2a8eaa84ec3b41de Mon Sep 17 00:00:00 2001
From: Christian C <cc@localhost>
Date: Fri, 7 Mar 2025 21:55:05 -0800
Subject: Source File Building

---
 Makefile | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

(limited to 'Makefile')

diff --git a/Makefile b/Makefile
index 74e89e2..53bf441 100644
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,23 @@ PKGS=libtiff-4 libpng
 DEFINES=
 EXE=prog
 BUILD_DIR=build/
-OBJ_DIR=$(BUILD_DIR)obj/
-SRC_DIR=src/
 INC_DIR=include/
-SRCS=$(shell find $(SRC_DIR) -iname \*.c)
-OBJS_sub=$(subst $(SRC_DIR),$(OBJ_DIR),$(SRCS))
-OBJS=$(OBJS_sub:.c=.o)
-OBJ_DIRS_sub=$(shell find $(SRC_DIR) -type d)
-OBJ_DIRS=$(subst $(SRC_DIR),$(OBJ_DIR),$(OBJ_DIRS_sub))
+
+# Source files
+SRC_DIR=src/
+SRC_OBJ_DIR=$(BUILD_DIR)obj/src/
+SRC_SRCS=$(shell find $(SRC_DIR) -iname \*.c)
+SRC_OBJS_sub=$(subst $(SRC_DIR),$(SRC_OBJ_DIR),$(SRC_SRCS))
+SRC_OBJS=$(SRC_OBJS_sub:.c=.o)
+SRC_OBJ_DIRS_sub=$(shell find $(SRC_DIR) -type d)
+SRC_OBJ_DIRS=$(subst $(SRC_DIR),$(SRC_OBJ_DIR),$(SRC_OBJ_DIRS_sub))
+
+$(info $(SRC_SRCS))
+$(info $(SRC_OBJ_DIR))
+$(info $(SRC_OBJ_DIRS))
+$(info $(SRC_OBJS))
+
+# Library files
 
 # Include raylib if we want a visual experience
 ifdef RAYLIB
@@ -46,18 +55,18 @@ default: clean build
 
 build: $(BUILD_DIR)$(EXE)
 
-$(BUILD_DIR)$(EXE): $(OBJS)
+$(BUILD_DIR)$(EXE): $(SRC_OBJS)
 	@echo LD --\> $@
 	@gcc -o $@ $(LDFLAGS) $^
 
-$(OBJ_DIR)%.o: $(SRC_DIR)%.c
+$(SRC_OBJ_DIR)%.o: $(SRC_DIR)%.c
 	@echo CC $< --\> $@
 	@gcc -o $@ $(CFLAGS) -c $<
 
 clean:
 	@echo Cleaning build files...
 	@-rm -rf $(OBJ_DIR) $(BUILD_DIR)
-	@mkdir -p $(OBJ_DIR) $(BUILD_DIR) $(OBJ_DIRS)
+	@mkdir -p $(BUILD_DIR) $(SRC_OBJ_DIRS)
 
 run: $(BUILD_DIR)$(EXE)
 	@echo Executing...
-- 
cgit v1.2.1