Files
RetroArch/Makefile.ngc
LibretroAdmin a86d86a22c HAVE_RGIF: GIF images through image_texture, image_transfer and the tasks
rgif now loads GIFs wherever RetroArch loads images: thumbnails and
backgrounds through task_image, the image viewer core, the file browser
and the image_texture/image_transfer layer underneath them all.

rgif:
- the image_transfer interface the other decoders have:
  rgif_set_buf_ptr, rgif_set_avail, rgif_header_ready and
  rgif_process_image, giving a 32-bit texture of its own, ARGB32 or
  ABGR32 in native byte order
- RGIF_ABGR, for ABGR32 on big-endian targets
- a file not all read yet gives IMAGE_PROCESS_WAIT and is not touched;
  the image is decoded in one call once it is all in

Wiring, as HAVE_RTGA is wired:
- IMAGE_TYPE_GIF (image.h) and NBIO_TYPE_GIF (task_file_transfer.h),
  both appended so no other value moves
- image_texture_get_type: .gif
- image_transfer: new, free, start, is_valid, set_buffer_ptr, process,
  set_avail; the support matrix gains a GIF column
- task_image and task_file_transfer: GIF is an image task
- FILE_TYPE_GIF ("gif", "GIF"): opened as image content
- the file browser's image extensions, the image viewer core's
  extensions, the System Information list ("GIF (RGIF)") and
  --features ("RGIF"); SUPPORTS_RGIF in config.features.h
- griffin.c, Makefile.common (rgif.o), configure (HAVE_RGIF=yes), and
  next to HAVE_RTGA in every platform Makefile, the Android, Apple,
  MSVC, UWP and QNX projects and the CI compile matrix
- tools/settings_check.py and tools/stack_budget.py check with it

Also: menu_displaylist's image viewer extension list wrote "tga"
without moving its length on, so "webp" and "dds" landed on top of it
and TGA dropped out of the list; it moves on now.

Tests: rgif_test checks the texture in both byte orders against
rgif_decode, the wait before the whole file is in, and a refused file;
image_decode_fuzz sweeps GIF too (every byte of a small GIF set to
edge values, and every truncation), under ASan and UBSan. The griffin
unity build with every codec, the touched objects in a configured
build, the MinGW/C89 syntax check, the overlap check and the stack
budget pass.
2026-11-10 20:00:24 +01:00

334 lines
8.7 KiB
Makefile

ROOT_DIR := .
DEPS_DIR := $(ROOT_DIR)/deps
DEBUG ?= 0
HAVE_LOGGER = 0
HAVE_FILE_LOGGER = 0
HAVE_CC_RESAMPLER = 1
WHOLE_ARCHIVE_LINK = 0
BIG_STACK = 1
PC_DEVELOPMENT_IP_ADDRESS = 255.255.255.255
PC_DEVELOPMENT_UDP_PORT = 3490
RARCH_CONSOLE = 0
USBGECKO = 0
HAVE_STATIC_DUMMY ?= 0
# GameCube has no salamander / exec support, so in-menu core
# switching is impossible: each core dol is launched directly
# from the loader. If core info matching fails (missing or
# mismatched info files, stale core_info.cache), a strict
# core-info gate would leave content loading with no options at
# all. Default to offering the statically linked, currently
# running core as a fallback in that case.
LOAD_WITHOUT_CORE_INFO ?= 1
SPACE :=
SPACE := $(SPACE) $(SPACE)
BACKSLASH :=
BACKSLASH := \$(BACKSLASH)
filter_out1 = $(filter-out $(firstword $1),$1)
filter_out2 = $(call filter_out1,$(call filter_out1,$1))
# system platform
system_platform = unix
ifeq ($(shell uname -s),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -s)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -s)),)
system_platform = win
endif
TARGET_NAME := retroarch
INCLUDE :=
LDFLAGS :=
LIBDIRS :=
ifeq ($(LIBRETRO), nxengine)
WHOLE_ARCHIVE_LINK = 1
endif
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl,--whole-archive
WHOLE_END := -Wl,--no-whole-archive
endif
LIB_CORE :=
ifeq ($(HAVE_STATIC_DUMMY),1)
DEFINES += -DHAVE_STATIC_DUMMY
else
LIB_CORE += -lretro_ngc
endif
LIBS := $(WHOLE_START) $(LIB_CORE) $(WHOLE_END)
# RetroArch's own system layer, os/gekko; HAVE_LIBOGC=1 builds on
# devkitPro's libogc instead. EXTERNAL_LIBOGC=1, which the core CI
# templates pass when they relink the precompiled HAVE_LIBOGC=1 tree,
# names devkitPro's libogc too and selects the same build.
ifeq ($(EXTERNAL_LIBOGC), 1)
HAVE_LIBOGC ?= 1
endif
HAVE_LIBOGC ?= 0
ifeq ($(HAVE_LIBOGC), 1)
libogc_platform := 1
endif
HAVE_OGG_OGC ?= 0
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
LD = $(DEVKITPPC)/bin/powerpc-eabi-ld$(EXE_EXT)
ELF2DOL = $(DEVKITPPC)/bin/elf2dol$(EXE_EXT)
EXT_TARGET := $(TARGET_NAME)_ngc.dol
EXT_INTER_TARGET := $(TARGET_NAME)_ngc.elf
# Check whether ELF2DOL executable exists
# (path has changed in more recent toolchains)
ifeq ("$(wildcard $(ELF2DOL))","")
ELF2DOL = $(DEVKITPRO)/tools/bin/elf2dol$(EXE_EXT)
endif
INCLUDE += -I.
ifeq ($(HAVE_LIBOGC), 0)
CFLAGS += -DGEKKO_NATIVE
CXXFLAGS += -DGEKKO_NATIVE
INCLUDE += -Ios/gekko/include
else
CFLAGS += -DHAVE_LIBOGC
CXXFLAGS += -DHAVE_LIBOGC
LIBDIRS += -L$(DEVKITPRO)/libogc/lib/cube
INCLUDE += -I$(DEVKITPRO)/libogc/include
endif
MACHDEP := -DHW_DOL -mogc
LIBDIRS += -L.
MACHDEP += -DGEKKO -mcpu=750 -meabi -mhard-float
LDFLAGS += $(MACHDEP) -Wl,-Map,$(notdir $(EXT_INTER_TARGET)).map
# libogc 3 links with devkitPPC's own scripts and sizes the main stack
# in C (platform_gx_libogc.c); older libogc takes the os/gekko/libogc ones.
LIBOGC_MAJOR := $(shell sed -n 's/^.define[[:space:]]*_V_MAJOR_[[:space:]]*\([0-9]*\).*/\1/p' $(DEVKITPRO)/libogc/include/ogc/libversion.h 2>/dev/null)
ifneq ($(filter-out 0 1 2,$(LIBOGC_MAJOR)),)
LIBOGC_OWN_LD := 1
endif
ifeq ($(HAVE_LIBOGC), 0)
LDFLAGS += -T os/gekko/boot/dol.ld -Los/gekko/boot
else ifeq ($(BIG_STACK)$(LIBOGC_OWN_LD), 1)
LDFLAGS += -T os/gekko/libogc/ogc.ld
endif
ifeq ($(HAVE_OGG_OGC), 1)
LIBS += -L$(DEVKITPRO)/portlibs/ppc/lib -lvorbisfile -lvorbis -logg
endif
ifeq ($(HAVE_LIBOGC), 1)
LIBS += -lfat
ifeq ($(HAVE_LOGGER), 1)
LIBS += -lbba
endif
LIBS += -logc
endif
CFLAGS += -DGEKKO -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
# 24 MB of MEM1 makes resident code weight count, so features that cannot
# do their job on this hardware are compiled out: runahead (the second
# savestate never fits beside a running core), the webp/dds thumbnail
# decoders, the mod/s3m/xm tracker, 7z (LZMA dictionaries alone outsize
# the console's free RAM, so 7z archives could never extract anyway) and
# libretrodb (defaulted on by Makefile.common; database scanning is
# impractical here, and the explore menu goes with it). Together these
# return about 640 KB of MEM1 to content.
HAVE_LIBRETRODB := 0
HAVE_RUNAHEAD := 0
HAVE_DSP_FILTER := 1
HAVE_VIDEO_FILTER := 1
HAVE_FILTERS_BUILTIN := 1
HAVE_THREADS := 1
HAVE_RPNG := 1
HAVE_RWEBP := 0
HAVE_RDDS := 0
HAVE_RJPEG := 1
HAVE_RBMP := 1
HAVE_RTGA := 1
HAVE_RGIF := 1
HAVE_RMODTRACKER := 0
HAVE_OVERLAY := 1
HAVE_7ZIP := 0
HAVE_RZSTD := 1
HAVE_CONFIGFILE := 1
HAVE_PATCH := 1
HAVE_XDELTA := 0 # disabled because <lzma.h> isn't available (or we haven't figured out how to install it)
HAVE_CHEATS := 1
HAVE_SCREENSHOTS := 1
HAVE_REWIND := 1
HAVE_AUDIOMIXER := 1
HAVE_RWAV := 1
RARCH_CONSOLE = 1
HAVE_CHEATS := 1
HAVE_CORE_INFO_CACHE := 1
HAVE_MENU_COMMON := 1
HAVE_MENU := 1
HAVE_STATIC_AUDIO_FILTERS := 1
HAVE_STATIC_VIDEO_FILTERS := 1
HAVE_XMB := 0
HAVE_OZONE := 0
HAVE_RGUI := 1
HAVE_MATERIALUI := 0
INCLUDE += -I./libretro-common/include \
-Ideps
CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(PLATCFLAGS) $(INCLUDE)
ifeq ($(HAVE_LIBOGC), 1)
OBJ = $(PLATOBJS) audio/drivers/gx_audio_libogc.o gfx/drivers/gx_gfx_libogc.o gfx/display_servers/dispserv_gx_libogc.o gfx/display_servers/dispserv_gx_modes.o input/drivers/gx_input.o frontend/drivers/platform_gx_libogc.o input/drivers_joypad/gx_joypad_libogc.o
else
GEKKO_DIR := os/gekko
GEKKO_PLATFORM := dol
include os/gekko/gekko.mk
OBJ = audio/drivers/gekko_audio.o gfx/drivers/gekko_gfx.o gfx/display_servers/dispserv_gekko.o gfx/display_servers/dispserv_gx_modes.o input/drivers/gx_input.o frontend/drivers/platform_gekko.o input/drivers_joypad/gekko_joypad.o $(addsuffix .o,$(basename $(GEKKO_SOURCES)))
endif
include Makefile.common
CFLAGS += $(DEFINES)
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
endif
ifeq ($(HAVE_THREADS), 1)
CFLAGS += -DHAVE_THREADS
endif
ifeq ($(HAVE_WIIUSB_HID), 1)
CFLAGS += -DHAVE_WIIUSB_HID -DHAVE_HID
endif
ifeq ($(BIG_STACK),1)
CFLAGS += -DBIG_STACK
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
ifeq ($(HAVE_RARCH_EXEC), 1)
CFLAGS += -DHAVE_RARCH_EXEC
endif
ifeq ($(RARCH_CONSOLE), 1)
CFLAGS += -DRARCH_CONSOLE
endif
ifeq ($(RARCH_MOBILE), 1)
CFLAGS += -DRARCH_MOBILE
endif
CFLAGS += -std=gnu99 -DHAVE_RGUI -DHAVE_MENU -DHAVE_GRIFFIN=1 -Wno-char-subscripts -DRARCH_INTERNAL
ifeq ($(HAVE_FILTERS_BUILTIN), 1)
CFLAGS += -DHAVE_FILTERS_BUILTIN
endif
ifeq ($(HAVE_RSOUND), 1)
CFLAGS += -DHAVE_RSOUND
endif
ifeq ($(HAVE_GETOPT_LONG), 1)
CFLAGS += -DHAVE_GETOPT_LONG=1
endif
ifeq ($(HAVE_NETWORK_CMD), 1)
CFLAGS += -DHAVE_NETWORK_CMD
endif
ifeq ($(HAVE_DYNAMIC), 1)
CFLAGS += -DHAVE_DYNAMIC
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g -DDEBUG
else
CFLAGS += -O3
endif
ifeq ($(LOAD_WITHOUT_CORE_INFO),1)
CFLAGS += -DLOAD_WITHOUT_CORE_INFO
endif
ifneq ($(V),1)
Q := @
endif
OBJOUT = -o
LINKOUT = -o
LINK = $(CXX)
all: $(EXT_TARGET)
define INFO
CC: $(CC)
CFLAGS: $(CFLAGS)
CXX: $(CXX)
LD: $(LD)
LDFLAGS: $(LDFLAGS)
LIBDIRS: $(LIBDIRS)
LIBS: $(LIBS)
LINK: $(LINK)
LINKOUT: $(LINKOUT)
OBJ: $(OBJ)
OBJOUT: $(OBJOUT)
PLATEXTRA: $(PLATEXTRA)
endef
export INFO
info:
ifneq ($(V),1)
@echo "$$INFO"
endif
%.dol: %.elf
$(ELF2DOL) $< $@
$(EXT_INTER_TARGET): $(OBJ)
@$(if $(Q), $(shell echo echo LINK $@),)
$(Q)$(LINK) $(LINKOUT)$@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(PLATEXTRA) $(LIBS)
%.o: %.c
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) -c $(OBJOUT)$@ $<
%.o: %.cpp
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CFLAGS) -c $(OBJOUT)$@ $<
%.o: %.S
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) -c $(OBJOUT)$@ $<
%.binobj: %.bin
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LD) -r -b binary $(OBJOUT)$@ $<
clean:
@$(if $(Q), echo $@,)
$(Q)rm -f $(EXT_TARGET)
$(Q)rm -f $(EXT_INTER_TARGET)
$(Q)rm -f $(OBJ)
.PHONY: clean
print-%:
@echo '$*=$($*)'