RetroArch/Makefile.vita
Jesse Talavera-Greenberg cbf49a0b77
XDelta patch support (Take 2) (#15915)
* Add xdelta in deps

* Include <assert.h> in xdelta3.h

- Otherwise the static_assert calls can fail

* Build xdelta3 in Makefile.common

* Add xdelta support to the softpatching infrastructure

- The patching itself isn't fully implemented yet

* Adjust how xdelta3.h checks the sizes of some types

- Now checks max values instead of relying on autotools

* Add some enums that were excluded by the cherry-pick

* Remove stray whitespace

* Adjust SIZE macros in xdelta3.h

- Move them outside the XD3_USE_LARGEFILE64 block
- Add more SIZE declarations
- Make SIZEOF_UNSIGNED_LONG_LONG contingent on the presence of ULLONG_MAX

* Reintegrate xdelta support

* Enable support for xdelta's secondary compressors

- Necessary for some patches

* Fix some format specifiers

* Remove unnecessary files from xdelta

* Include xdelta3.h with a relative path

* Add xdelta3 headers to HEADERS variable

* Gate Xdelta support behind HAVE_XDELTA

- HAVE_XDELTA is on by default
- HAVE_PATCH is still required for HAVE_XDELTA to be meaningful
- Support is mostly contingent on the availability of LZMA
- Anything modern should be okay
- Legacy platforms (e.g. DOS) may need to have Xdelta support disabled
- At least until some other solution can be found

* Disable HAVE_XDELTA on platforms where the build recently failed

- These come from looking at the failed builds on GitHub
- These are guesses, and may turn out to be wrong

* Fix a potential memory leak

- Whoops, looks like I need to call two cleanup functions
- xd3_close_stream exists separately from xd3_free_stream

* Split the --help printout for --xdelta into its own strlcat call

- GCC was complaining about #ifdefs within macro arguments being non-portable

* Fix some incorrect printf format specifiers

* Modify Xdelta to adhere to C89

- It's mostly using RetroArch's INLINE macro instead of the inline keyword

* Slight cleanups

* Remove a stray comma that was hindering C89 builds

* Add XDelta support to CHANGES.md

* Change how the xdelta patch's name is computed

- To be in line with other recent refactoring

* Fix an incorrect merge

- Whoops, this part was from before I figured out how to get the size of a patched file

* Explain the song-and-dance behind computing a patched file's size

* Define some XDelta3-related constants to 0 on 32-bit platforms

* Adjust some Xdelta-related macro definitions

- Exclude the encoder, since we're not making patches
- Move some #defines to after inclusion of <stdint.h>, to fix undefined behavior
- Remove _WIN32_WINNT overrides, since they were for code that we're not using

* Fix Xdelta support

* Wrap an encoder-only function in `#if XD3_ENCODER`
2023-11-23 20:19:07 -08:00

265 lines
6.2 KiB
Makefile

TARGET := retroarch_vita
DEBUG ?= 0
HAVE_FILE_LOGGER = 1
GRIFFIN_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
HAVE_STATIC_DUMMY ?= 0
VITA_TITLE_ID := RETROARCH
VITA_TITLE_NAME := RetroArch
PC_DEVELOPMENT_IP_ADDRESS =
PC_DEVELOPMENT_UDP_PORT =
OBJ :=
SCE_LIBC_SIZE := 4194304
DEFINES := -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_STB_VORBIS
INCDIRS :=
ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o
DEFINES += -DHAVE_GRIFFIN=1 \
-DHAVE_REWIND \
-DHAVE_NEON \
-DHAVE_MENU \
-DHAVE_CONFIGFILE \
-DHAVE_PATCH \
-DHAVE_CHEATS \
-DHAVE_XMB \
-DHAVE_MATERIALUI \
-DHAVE_LIBRETRODB \
-DHAVE_KEYMAPPER \
-DHAVE_ZLIB \
-DHAVE_RPNG \
-DHAVE_RJPEG \
-DHAVE_RBMP \
-DHAVE_RTGA \
-DHAVE_CC_RESAMPLER \
-DHAVE_CORE_INFO_CACHE
ifeq ($(DEBUG), 1)
DEFINES += -DHAVE_NETLOGGER
endif
INCDIRS += -I. \
-Ideps/7zip \
-Ilibretro-common/include \
-Ilibretro-common/include/compat/zlib \
-Ideps/stb
else
HAVE_REWIND := 1
HAVE_UPDATE_ASSETS := 1
HAVE_ONLINE_UPDATER := 1
HAVE_NEON := 1
HAVE_DSP_FILTER := 1
HAVE_VIDEO_FILTER := 1
HAVE_SCREENSHOTS := 1
HAVE_FILTERS_BUILTIN := 1
HAVE_LANGEXTRA := 1
HAVE_RPNG := 1
HAVE_RJPEG := 1
HAVE_RBMP := 1
HAVE_RTGA := 1
HAVE_ZLIB := 1
HAVE_7ZIP := 1
ifeq ($(HAVE_VITAGLES), 1)
HAVE_VITA2D := 0
HAVE_VITAGL := 0
HAVE_VITAGLES := 1
HAVE_OPENGL := 1
HAVE_OPENGLES := 1
HAVE_OPENGLES2 := 1
HAVE_EGL := 1
HAVE_GLSL := 1
HAVE_SHADERPIPELINE := 1
else
HAVE_VITA2D := 1
HAVE_VITAGL := 0
endif
HAVE_NETWORKING := 1
HAVE_IFINFO := 1
HAVE_NETPLAYDISCOVERY := 1
HAVE_SOCKET_LEGACY := 1
HAVE_MENU := 1
HAVE_MENU_COMMON := 1
HAVE_GFX_WIDGETS := 1
HAVE_CONFIGFILE := 1
HAVE_PATCH := 1
HAVE_XDELTA := 1 # disabled because <lzma.h> isn't available (or we haven't figured out how to install it)
HAVE_CHEATS := 1
HAVE_OVERLAY := 1
HAVE_MATERIALUI := 1
HAVE_XMB := 1
HAVE_RGUI := 1
HAVE_STB_FONT := 1
HAVE_THREADS := 1
HAVE_LIBRETRODB := 1
HAVE_CC_RESAMPLER := 1
HAVE_CHEEVOS := 1
HAVE_RUNAHEAD := 1
RARCH_CONSOLE := 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_AUDIOMIXER := 1
HAVE_RWAV := 1
HAVE_CORE_INFO_CACHE := 1
ifeq ($(DEBUG), 1)
HAVE_NETLOGGER = 1
endif
include Makefile.common
CFLAGS += $(DEF_FLAGS)
BLACKLIST :=
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
INCDIRS += $(INCLUDE_DIRS)
endif
ifeq ($(strip $(VITASDK)),)
$(error "Please set VITASDK in your environment. export VITASDK=<path to>vitasdk")
endif
export PATH := $(PATH):$(VITASDK)/bin
PREFIX := arm-vita-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
AS := $(PREFIX)as
AR := $(PREFIX)ar
OBJCOPY := $(PREFIX)objcopy
STRIP := $(PREFIX)strip
NM := $(PREFIX)nm
LD := $(CXX)
LIBDIRS := -L.
ARCHFLAGS := -march=armv7-a -mfpu=neon -mfloat-abi=hard -DVITA
ifeq ($(HAVE_VITAGLES), 1)
ARCHFLAGS += -DSCE_LIBC_SIZE=$(SCE_LIBC_SIZE)
endif
CFLAGS += $(ARCHFLAGS) -mword-relocations -fno-optimize-sibling-calls
ifeq ($(DEBUG), 1)
CFLAGS += -g -Og
else
CFLAGS += -O2
endif
ASFLAGS := $(CFLAGS)
LDFLAGS := -Wl,-q
CFLAGS += -Wall -ffast-math
CFLAGS += -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DRARCH_CONSOLE
CFLAGS += -DHAVE_DSP_FILTER
CFLAGS += -DHAVE_VIDEO_FILTER
CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES)
ifneq ($(PC_DEVELOPMENT_IP_ADDRESS),)
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS='"$(PC_DEVELOPMENT_IP_ADDRESS)"'
endif
ifneq ($(PC_DEVELOPMENT_UDP_PORT),)
CFLAGS += -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
endif
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl,--whole-archive
WHOLE_END := -Wl,--no-whole-archive
endif
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
VITA_LIBS := -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub -lSceNetCtl_stub -lSceAppUtil_stub \
-lSceSysmodule_stub -lSceCtrl_stub -lSceHid_stub -lSceTouch_stub -lSceAudio_stub \
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_stub -lSceMotion_stub \
-lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -lpthread -lpng -lz -lSceShaccCg_stub
ifeq ($(HAVE_VITAGLES), 1)
VITA_LIBS += -llibScePiglet_stub -ltaihen_stub
FSELF_FLAGS := -ss
else
VITA_LIBS += -lvitaGL -lvitashark
FSELF_FLAGS := -s
endif
LIBS := $(WHOLE_START)
ifeq ($(HAVE_STATIC_DUMMY),1)
DEFINES += -DHAVE_STATIC_DUMMY
else
LIBS += -lretro_vita
endif
LIBS += $(WHOLE_END) $(VITA_LIBS) -lm -lc
TARGETS := $(TARGET).vpk
DEPFLAGS = -MT $@ -MMD -MP -MF $*.Tdepend
POSTCOMPILE = mv -f $*.Tdepend $*.depend
all: $(TARGETS)
%.o: %.cpp
%.o: %.cpp %.depend
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.c
%.o: %.c %.depend
$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.S
%.o: %.S %.depend
$(CC) -c -o $@ $< $(ASFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.s
%.o: %.s %.depend
$(CC) -c -o $@ $< $(ASFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.depend: ;
liblibScePiglet_stub.a:
mkdir -p deps/Pigs-In-A-Blanket/piglet_stub/libScePiglet
vita-libs-gen deps/Pigs-In-A-Blanket/piglet_stub/nids.yml deps/Pigs-In-A-Blanket/piglet_stub/libScePiglet
make -C deps/Pigs-In-A-Blanket/piglet_stub/libScePiglet ARCH=arm-vita-eabi
cp deps/Pigs-In-A-Blanket/piglet_stub/libScePiglet/liblibScePiglet_stub.a .
$(TARGET).elf: $(OBJ) liblibScePiglet_stub.a
$(LD) $(OBJ) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
%.velf: %.elf
cp $< $<.unstripped.elf
$(PREFIX)strip -g $<
vita-elf-create $< $@
%.self: %.velf
vita-make-fself -c $(FSELF_FLAGS) $< $@
%.vpk: %.self
vita-mksfoex -s TITLE_ID=$(VITA_TITLE_ID) "$(VITA_TITLE_NAME)" -d ATTRIBUTE2=12 param.sfo
vita-pack-vpk -s param.sfo -b $< $@
clean:
rm -f $(OBJ) $(TARGET).elf $(TARGET).elf.unstripped.elf $(TARGET).velf $(TARGET).self param.sfo $(TARGET).vpk
rm -rf deps/Pigs-In-A-Blanket/piglet_stub/libScePiglet
rm -f $(OBJ:.o=.depend)
# Useful for developers
vpksend: $(TARGET).vpk
curl -T $< ftp://$(PSVITAIP):1337/ux0:/
send: $(TARGET).self
curl -T $< ftp://$(PSVITAIP):1337/ux0:/app/$(VITA_TITLE_ID)/eboot.bin
launch: $(TARGET).self
curl -T $< ftp://$(PSVITAIP):1337/ux0:/app/$(VITA_TITLE_ID)/eboot.bin
echo "launch $(VITA_TITLE_ID)" | nc ${PSVITAIP} 1338
.PHONY: clean all send vpksend
.PRECIOUS: %.depend
-include $(OBJ:.o=.depend)