CORE_PKGS += stdcxx libm
NO_UNDEFINED =
	# Uses Genode API to create secondary stack
LIBRETRO_COMM_DIR =
	# TODO: build against newer libretro-common

WITH_DYNAREC = @(TUP_ARCH)
  # TODO: will not configure correctly for every possible TUP_ARCH

include upstream/Makefile.common

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

DEFINES += -O2 -DNDEBUG -D__GENODE__
CFLAGS += $(COMMONFLAGS)

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

: 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 |>
