mirror of https://github.com/encounter/SDL.git
Make rpi video cross-compiler friendly.
* Stops using fixed path to find GLES/EGL libs. * Tries pkg-config to locate bcm_host. Signed-off-by: Guillermo A. Amaral <g@maral.me>
This commit is contained in:
parent
509db8afbd
commit
35554caf16
|
@ -1127,15 +1127,18 @@ endmacro()
|
||||||
# - n/a
|
# - n/a
|
||||||
macro(CheckRPI)
|
macro(CheckRPI)
|
||||||
if(VIDEO_RPI)
|
if(VIDEO_RPI)
|
||||||
|
pkg_check_modules(VIDEO_RPI bcm_host brcmegl)
|
||||||
|
if (NOT VIDEO_RPI_FOUND)
|
||||||
set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
|
set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
|
||||||
set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
|
set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
|
||||||
set(VIDEO_RPI_LIBS bcm_host )
|
set(VIDEO_RPI_LIBRARIES bcm_host )
|
||||||
|
endif()
|
||||||
listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
|
listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
|
||||||
listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
|
listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
|
||||||
|
|
||||||
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
||||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
|
||||||
set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBS}")
|
set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBRARIES}")
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#include <bcm_host.h>
|
#include <bcm_host.h>
|
||||||
int main(int argc, char **argv) {}" HAVE_VIDEO_RPI)
|
int main(int argc, char **argv) {}" HAVE_VIDEO_RPI)
|
||||||
|
@ -1147,7 +1150,7 @@ macro(CheckRPI)
|
||||||
set(SDL_VIDEO_DRIVER_RPI 1)
|
set(SDL_VIDEO_DRIVER_RPI 1)
|
||||||
file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
|
file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
|
||||||
set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_RPI_SOURCES})
|
set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_RPI_SOURCES})
|
||||||
list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBS})
|
list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBRARIES})
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
|
||||||
endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
|
endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
|
||||||
endif(VIDEO_RPI)
|
endif(VIDEO_RPI)
|
||||||
|
|
|
@ -19502,7 +19502,51 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
|
if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
|
||||||
if test x$ARCH = xnetbsd; then
|
# Extract the first word of "pkg-config", so it can be a program name with args.
|
||||||
|
set dummy pkg-config; ac_word=$2
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||||
|
$as_echo_n "checking for $ac_word... " >&6; }
|
||||||
|
if ${ac_cv_path_PKG_CONFIG+:} false; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
case $PKG_CONFIG in
|
||||||
|
[\\/]* | ?:[\\/]*)
|
||||||
|
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||||
|
for as_dir in $PATH
|
||||||
|
do
|
||||||
|
IFS=$as_save_IFS
|
||||||
|
test -z "$as_dir" && as_dir=.
|
||||||
|
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||||
|
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||||
|
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
|
||||||
|
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||||
|
break 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
IFS=$as_save_IFS
|
||||||
|
|
||||||
|
test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
|
||||||
|
if test -n "$PKG_CONFIG"; then
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
|
||||||
|
$as_echo "$PKG_CONFIG" >&6; }
|
||||||
|
else
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||||
|
$as_echo "no" >&6; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test x$PKG_CONFIG != xno && $PKG_CONFIG --exists bcm_host; then
|
||||||
|
RPI_CFLAGS=`$PKG_CONFIG --cflags bcm_host brcmegl`
|
||||||
|
RPI_LDFLAGS=`$PKG_CONFIG --libs bcm_host brcmegl`
|
||||||
|
elif test x$ARCH = xnetbsd; then
|
||||||
RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
|
RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
|
||||||
RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
|
RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
|
||||||
else
|
else
|
||||||
|
|
|
@ -1571,7 +1571,11 @@ CheckRPI()
|
||||||
AC_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=yes]]]),
|
AC_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=yes]]]),
|
||||||
, enable_video_rpi=yes)
|
, enable_video_rpi=yes)
|
||||||
if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
|
if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
|
||||||
if test x$ARCH = xnetbsd; then
|
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||||
|
if test x$PKG_CONFIG != xno && $PKG_CONFIG --exists bcm_host; then
|
||||||
|
RPI_CFLAGS=`$PKG_CONFIG --cflags bcm_host brcmegl`
|
||||||
|
RPI_LDFLAGS=`$PKG_CONFIG --libs bcm_host brcmegl`
|
||||||
|
elif test x$ARCH = xnetbsd; then
|
||||||
RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
|
RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
|
||||||
RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
|
RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
|
||||||
else
|
else
|
||||||
|
|
|
@ -44,12 +44,13 @@
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_RPI
|
#if SDL_VIDEO_DRIVER_RPI
|
||||||
/* Raspbian places the OpenGL ES/EGL binaries in a non standard path */
|
/* Raspbian places the OpenGL ES/EGL binaries in a non standard path */
|
||||||
#define DEFAULT_EGL ( vc4 ? "libEGL.so.1" : "/opt/vc/lib/libbrcmEGL.so" )
|
static const char g_rpi_opt_path[] = "/opt/vc/lib";
|
||||||
#define DEFAULT_OGL_ES2 ( vc4 ? "libGLESv2.so.2" : "/opt/vc/lib/libbrcmGLESv2.so" )
|
#define DEFAULT_EGL ( vc4 ? "libEGL.so.1" : "libbrcmEGL.so" )
|
||||||
#define ALT_EGL "/opt/vc/lib/libEGL.so"
|
#define DEFAULT_OGL_ES2 ( vc4 ? "libGLESv2.so.2" : "libbrcmGLESv2.so" )
|
||||||
#define ALT_OGL_ES2 "/opt/vc/lib/libGLESv2.so"
|
#define ALT_EGL "libEGL.so"
|
||||||
#define DEFAULT_OGL_ES_PVR ( vc4 ? "libGLES_CM.so.1" : "/opt/vc/lib/libbrcmGLESv2.so" )
|
#define ALT_OGL_ES2 "libGLESv2.so"
|
||||||
#define DEFAULT_OGL_ES ( vc4 ? "libGLESv1_CM.so.1" : "/opt/vc/lib/libbrcmGLESv2.so" )
|
#define DEFAULT_OGL_ES_PVR ( vc4 ? "libGLES_CM.so.1" : "libbrcmGLESv2.so" )
|
||||||
|
#define DEFAULT_OGL_ES ( vc4 ? "libGLESv1_CM.so.1" : "libbrcmGLESv2.so" )
|
||||||
|
|
||||||
#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
|
#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
|
||||||
/* Android */
|
/* Android */
|
||||||
|
@ -265,6 +266,20 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
||||||
#endif
|
#endif
|
||||||
#if SDL_VIDEO_DRIVER_RPI
|
#if SDL_VIDEO_DRIVER_RPI
|
||||||
SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK));
|
SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK));
|
||||||
|
|
||||||
|
path = SDL_getenv("LD_LIBRARY_PATH");
|
||||||
|
if (path) {
|
||||||
|
const int path_size = SDL_strlen(path) + 1 + sizeof(g_rpi_opt_path);
|
||||||
|
char *new_path = SDL_calloc(1, path_size);
|
||||||
|
strcat(new_path, path);
|
||||||
|
strcat(new_path, ":");
|
||||||
|
strcat(new_path, g_rpi_opt_path);
|
||||||
|
SDL_setenv("LD_LIBRARY_PATH", new_path, 1);
|
||||||
|
SDL_free(new_path);
|
||||||
|
} else {
|
||||||
|
SDL_setenv("LD_LIBRARY_PATH", g_rpi_opt_path, 1);
|
||||||
|
}
|
||||||
|
path = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_this->egl_data) {
|
if (_this->egl_data) {
|
||||||
|
|
Loading…
Reference in New Issue