CORE_PKGS += stdcxx libm
NO_UNDEFINED =
	# Uses Genode API to create secondary stack
#LIBRETRO_COMM_DIR =

ifeq (@(TUP_ARCH),arm64)
WITH_DYNAREC = arm64
endif

ifeq (@(TUP_ARCH),i386)
WITH_DYNAREC = x86
endif

ifeq (@(TUP_ARCH),x86_64)
WITH_DYNAREC = x86_64
endif

ifeq ($(WITH_DYNAREC),)
error dynamic recompiler not configured for @(TUP_ARCH)
endif

WITH_FAKE_SDL = 1
include upstream/libretro/Makefile.common

DEFINES += -O1 -DNDEBUG -D__GENODE__ -DWITH_FAKE_SDL
DEFINES += -DDB_HAVE_CLOCK_GETTIME
DEFINES += $(COMMONFLAGS)

DEFINES += -DHAVE_MMAP
	# Use anonymous mmap to allocate executable memory pages

SOURCES_CXX += $(LIBRETRO_COMM_DIR)/libco/genode.cpp

: foreach $(SOURCES_C) |> !libretro_cc |> {libretro_objs}
: foreach $(SOURCES_CXX) |> !libretro_cxx |> {libretro_objs}

: {libretro_objs} |> !libretro_core_link |> {core}
: {core} |> !collect_bin |>
: |> !bin |>

PKG_DEPENDS += \
	@(PUBLIC_SRC_STDCXX) \

: $(TUP_CWD)/runtime |> !collect_pkg_runtime |>
: |> !pkg |>
