# VirtualXT -- Circle baremetal kernel Makefile
#
# Builds a Raspberry Pi kernel image that loads VirtualXT as a libretro core.
# Requires Circle to be built first (see ../circle/README).
#
# Usage:
#   make -C tools/circle/kernel
#
# This builds the Circle frontend objects and links them with
# virtualxt_libretro.o (produced by `make rpi` from the project root).

ifeq ($(CIRCLEHOME),)
	CIRCLEHOME = ../../../../circle
endif

# VirtualXT core object and include paths.
VXT_HOME = ../../..
CFLAGS = -I$(VXT_HOME)/src -I$(VXT_HOME)/tools/libretro

# VirtualXT's static .bss footprint (~14.8 MB) exceeds Circle's default
# KERNEL_MAX_SIZE of 2 MB, which would trigger the silent halt in
# circle/lib/sysinit.cpp before any output is initialized. The matching
# define MUST also be present in $(CIRCLEHOME)/Config.mk so that libcircle
# itself is built with the larger value. See docs/STATUS.md.
DEFINE += -DKERNEL_MAX_SIZE=0x1400000 -DCRT_FILTER_EXTERNAL

OBJS = main.o kernel.o emuloop.o $(VXT_HOME)/virtualxt_libretro.o

LIBS = $(CIRCLEHOME)/lib/libcircle.a \
	$(CIRCLEHOME)/lib/usb/libusb.a \
	$(CIRCLEHOME)/lib/sound/libsound.a \
	$(CIRCLEHOME)/lib/input/libinput.a \
	$(CIRCLEHOME)/lib/fs/libfs.a \
	$(CIRCLEHOME)/addon/fatfs/libfatfs.a \
	$(CIRCLEHOME)/addon/SDCard/libsdcard.a

include $(CIRCLEHOME)/Rules.mk

-include $(DEPS)
