# Copyright (C) 2026 centaurself
#
# This file is part of Ithaca, a simulator for the Magnavox Odyssey.
#
# Ithaca is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# Ithaca is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# Ithaca. If not, see <https://www.gnu.org/licenses/>. 

CC=gcc
CFLAGS=-g
LDFLAGS=-lSDL2

TARGET_EXEC:=ithaca

BUILD_DIR:=build
SRC_DIRS:=src

SRCS:=$(shell find $(SRC_DIRS) -name '*.c')

OBJS:=$(SRCS:%=$(BUILD_DIR)/%.o)

$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
	$(CC) $(OBJS) -o $@ $(LDFLAGS)
	rm -r $(BUILD_DIR)/$(SRC_DIRS)

$(BUILD_DIR)/%.c.o: %.c
	mkdir -p $(dir $@)
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -r $(BUILD_DIR)
