From 80721b7eb3ff0d55affbb8a4c82569b39a140e37 Mon Sep 17 00:00:00 2001 From: Bradley Remedios Date: Sun, 10 Nov 2024 00:40:39 -0800 Subject: [PATCH] This is a fix for the toolchain not working for compiling programs that use SDL_image or SDL_ttf and are using the CMAKE build system. A relocation script was not required after these changes at least when working against SDL2, SDL2_image and SDL2_ttf. SDL2_image - Copied cmake fix from SDL2 into SDL2_image. - Using the toolchain works for static and shared linkage. SDL2_ttf - Same fix as SDL2_image - This library also has a bad extra static libs setup where it contains more than just static libraries. REGEX alone was not sufficient to resolve, replaced the extra libs with the necessary libraries. --- package/sdl2_image/sdl2_image.mk | 9 ++++++++ package/sdl2_ttf/sdl2_ttf.mk | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/package/sdl2_image/sdl2_image.mk b/package/sdl2_image/sdl2_image.mk index 40b9e3c9151..b683fe74c5b 100644 --- a/package/sdl2_image/sdl2_image.mk +++ b/package/sdl2_image/sdl2_image.mk @@ -27,6 +27,13 @@ SDL2_IMAGE_CONF_OPTS = \ --enable-xpm \ --enable-xv +define SDL2_IMAGE_FIX_SDL2_CONFIG_CMAKE + $(SED) '2iget_filename_component(PACKAGE_PREFIX_DIR "$${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)\n' \ + $(STAGING_DIR)/usr/lib/cmake/SDL2_image/sdl2_image-config.cmake + $(SED) 's%"/usr"%$${PACKAGE_PREFIX_DIR}%' \ + $(STAGING_DIR)/usr/lib/cmake/SDL2_image/sdl2_image-config.cmake +endef + SDL2_IMAGE_DEPENDENCIES = sdl2 host-pkgconf ifeq ($(BR2_PACKAGE_JPEG),y) @@ -57,4 +64,6 @@ else SDL2_IMAGE_CONF_OPTS += --disable-webp endif +SDL2_IMAGE_POST_INSTALL_STAGING_HOOKS += SDL2_IMAGE_FIX_SDL2_CONFIG_CMAKE + $(eval $(autotools-package)) diff --git a/package/sdl2_ttf/sdl2_ttf.mk b/package/sdl2_ttf/sdl2_ttf.mk index f4f293cec1a..163d773053a 100644 --- a/package/sdl2_ttf/sdl2_ttf.mk +++ b/package/sdl2_ttf/sdl2_ttf.mk @@ -13,6 +13,43 @@ SDL2_TTF_INSTALL_STAGING = YES SDL2_TTF_DEPENDENCIES = sdl2 freetype host-pkgconf SDL2_TTF_CONF_OPTS = --disable-freetype-builtin --disable-harfbuzz-builtin +# +# The ttf library for some reason has a broken regex where it adds -linux-gnu +# as a library to link against, which it pulls from the path. This is only +# broken in the cross toolchain. +# +# Adding a regex to pull out the entire -linux-gnu flag after the regex runs. +# +define SDL2_TTF_FIX_SDL2_CONFIG_CMAKE + $(SED) '18iget_filename_component(PACKAGE_PREFIX_DIR "$${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)\n' \ + $(STAGING_DIR)/usr/lib/cmake/SDL2_ttf/sdl2_ttf-config.cmake + $(SED) 's%"/usr"%$${PACKAGE_PREFIX_DIR}%' \ + $(STAGING_DIR)/usr/lib/cmake/SDL2_ttf/sdl2_ttf-config.cmake + $(SED) '37istring(REGEX REPLACE "\-linux-gnu " "" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}")' \ + $(STAGING_DIR)/usr/lib/cmake/SDL2_ttf/sdl2_ttf-config.cmake + $(SED) '39iset(_sdl2ttf_extra_static_libraries "-lfreetype -lharfbuzz")' \ + $(STAGING_DIR)/usr/lib/cmake/SDL2_ttf/sdl2_ttf-config.cmake +endef + +# batocera +define SDL2_TTF_FIX_WAYLAND_SCANNER_PATH + sed -i "s+/usr/bin/wayland-scanner+$(HOST_DIR)/usr/bin/wayland-scanner+g" $(@D)/Makefile +endef + +define SDL2_TTF_FIX_CONFIGURE_PATHS + sed -i "s+/host/bin/\.\.+/host+g" $(@D)/config.log + sed -i "s+/host/bin/\.\.+/host+g" $(@D)/config.status + sed -i "s+/host/bin/\.\.+/host+g" $(@D)/libtool + sed -i "s+/host/bin/\.\.+/host+g" $(@D)/Makefile + sed -i "s+/host/bin/\.\.+/host+g" $(@D)/sdl2_ttf-config + sed -i "s+/host/bin/\.\.+/host+g" $(@D)/sdl2_ttf.pc + sed -i "s+-I/.* ++g" $(@D)/sdl2_ttf.pc +endef + +SDL2_TTF_POST_INSTALL_STAGING_HOOKS += SDL2_TTF_FIX_SDL2_CONFIG_CMAKE +SDL2_TTF_POST_CONFIGURE_HOOKS += SDL2_TTF_FIX_WAYLAND_SCANNER_PATH +SDL2_TTF_POST_CONFIGURE_HOOKS += SDL2_TTF_FIX_CONFIGURE_PATHs + ifeq ($(BR2_PACKAGE_HARFBUZZ),y) SDL2_TTF_DEPENDENCIES += harfbuzz SDL2_TTF_CONF_OPTS += --enable-harfbuzz @@ -33,4 +70,5 @@ SDL2_TTF_CONF_OPTS += \ --without-x endif + $(eval $(autotools-package))