# Makefile

# Define variables
SRC_DIR = .
BUILD_DIR = .

# Target to create directories
setup:
	mkdir -p $(BUILD_DIR)

# Target to compile the C source files using a loop
compile: setup
	for file in $(SRC_DIR)/*.c; do gcc -c $$file -o $(BUILD_DIR)/$(notdir $(basename $$file .c)).o; done

# Target to link the object files into an executable
link: compile
	gcc -o $(BUILD_DIR)/test_program $(BUILD_DIR)/*.o

# Target to run the compiled program
run: link
	$(BUILD_DIR)/test_program

# Clean target to remove created directories and files
clean:
	rm -rf $(BUILD_DIR)
