Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Guillermo A. Amaral <g@maral.me>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2
Date: Thu, 18 Jan 2018 09:56:04 -0800	[thread overview]
Message-ID: <20180118175604.GA16776@enterprise.starfleet> (raw)
In-Reply-To: <20180118175415.16715-1-g@maral.me>

Howdy,

Tested and it works like a charm!

Thanks for the idea Adrian. :-)

Cheers,
G

On Thu, Jan 18, 2018 at 09:54:15AM -0800, Guillermo A. Amaral wrote:
> Tweak build system to play well with Buildroot.
> 
> Signed-off-by: Guillermo A. Amaral <g@maral.me>
> ---
>  .../sdl2/0001-make-cross-compiler-friendly.patch   | 167 +++++++++++++++++++++
>  package/sdl2/sdl2.mk                               |   8 +-
>  2 files changed, 174 insertions(+), 1 deletion(-)
>  create mode 100644 package/sdl2/0001-make-cross-compiler-friendly.patch
> 
> diff --git a/package/sdl2/0001-make-cross-compiler-friendly.patch b/package/sdl2/0001-make-cross-compiler-friendly.patch
> new file mode 100644
> index 000000000..10dcf7465
> --- /dev/null
> +++ b/package/sdl2/0001-make-cross-compiler-friendly.patch
> @@ -0,0 +1,167 @@
> +From 4cbd2fbfcbfe94b5826907f59ee963c69860e522 Mon Sep 17 00:00:00 2001
> +From: "Guillermo A. Amaral" <g@maral.me>
> +Date: Thu, 18 Jan 2018 09:23:58 -0800
> +Subject: [PATCH] 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>
> +---
> + cmake/sdlchecks.cmake | 15 ++++++++++-----
> + configure             | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
> + configure.in          |  8 ++++++--
> + src/video/SDL_egl.c   | 12 ++++++------
> + 4 files changed, 68 insertions(+), 15 deletions(-)
> +
> +diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
> +index e2e89a2..fc715f1 100644
> +--- a/cmake/sdlchecks.cmake
> ++++ b/cmake/sdlchecks.cmake
> +@@ -1127,15 +1127,19 @@ endmacro()
> + # - n/a
> + macro(CheckRPI)
> +   if(VIDEO_RPI)
> +-    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_LIBS bcm_host )
> ++    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_LIBRARY_DIRS "/opt/vc/lib" )
> ++      set(VIDEO_RPI_LIBRARIES bcm_host )
> ++      set(VIDEO_RPI_LDFLAGS "-Wl,-rpath,/opt/vc/lib")
> ++    endif()
> +     listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
> +     listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
> + 
> +     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_LIBRARIES "${VIDEO_RPI_LIBS}")
> ++    set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBRARIES}")
> +     check_c_source_compiles("
> +         #include <bcm_host.h>
> +         int main(int argc, char **argv) {}" HAVE_VIDEO_RPI)
> +@@ -1147,8 +1151,9 @@ macro(CheckRPI)
> +       set(SDL_VIDEO_DRIVER_RPI 1)
> +       file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
> +       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}")
> ++      list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS})
> +     endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
> +   endif(VIDEO_RPI)
> + endmacro(CheckRPI)
> +diff --git a/configure b/configure
> +index b622085..d42a22a 100755
> +--- a/configure
> ++++ b/configure
> +@@ -19485,12 +19485,56 @@ else
> + fi
> + 
> +     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_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
> +         else
> +             RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
> +-            RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host"
> ++            RPI_LDFLAGS="-Wl,-rpath,/opt/vc/lib -L/opt/vc/lib -lbcm_host"
> +         fi
> + 
> +         # Save the original compiler flags and libraries
> +diff --git a/configure.in b/configure.in
> +index 5ac2130..450bf62 100644
> +--- a/configure.in
> ++++ b/configure.in
> +@@ -1563,12 +1563,16 @@ CheckRPI()
> + AC_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=yes]]]),
> +                   , enable_video_rpi=yes)
> +     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_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
> +         else
> +             RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
> +-            RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host"
> ++            RPI_LDFLAGS="-Wl,-rpath,/opt/vc/lib -L/opt/vc/lib -lbcm_host"
> +         fi
> + 
> +         # Save the original compiler flags and libraries
> +diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
> +index 9ccc2c3..23a7f2d 100644
> +--- a/src/video/SDL_egl.c
> ++++ b/src/video/SDL_egl.c
> +@@ -44,12 +44,12 @@
> + 
> + #if SDL_VIDEO_DRIVER_RPI
> + /* Raspbian places the OpenGL ES/EGL binaries in a non standard path */
> +-#define DEFAULT_EGL "/opt/vc/lib/libbrcmEGL.so"
> +-#define DEFAULT_OGL_ES2 "/opt/vc/lib/libbrcmGLESv2.so"
> +-#define ALT_EGL "/opt/vc/lib/libEGL.so"
> +-#define ALT_OGL_ES2 "/opt/vc/lib/libGLESv2.so"
> +-#define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so"
> +-#define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so"
> ++#define DEFAULT_EGL "libbrcmEGL.so"
> ++#define DEFAULT_OGL_ES2 "libbrcmGLESv2.so"
> ++#define ALT_EGL "libEGL.so"
> ++#define ALT_OGL_ES2 "libGLESv2.so"
> ++#define DEFAULT_OGL_ES_PVR "libGLES_CM.so"
> ++#define DEFAULT_OGL_ES "libGLESv1_CM.so"
> + 
> + #elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
> + /* Android */
> +-- 
> +2.13.6
> +
> diff --git a/package/sdl2/sdl2.mk b/package/sdl2/sdl2.mk
> index 3e3ba54aa..113e1063d 100644
> --- a/package/sdl2/sdl2.mk
> +++ b/package/sdl2/sdl2.mk
> @@ -19,7 +19,6 @@ SDL2_CONF_OPTS += \
>  	--disable-dbus \
>  	--disable-pulseaudio \
>  	--disable-video-wayland \
> -	--disable-video-rpi
>  
>  # We must enable static build to get compilation successful.
>  SDL2_CONF_OPTS += --enable-static
> @@ -39,6 +38,13 @@ else
>  SDL2_CONF_OPTS += --disable-video-directfb
>  endif
>  
> +ifeq ($(BR2_PACKAGE_RPI_USERLAND),y)
> +SDL2_DEPENDENCIES += rpi-userland
> +SDL2_CONF_OPTS += --enable-video-rpi
> +else
> +SDL2_CONF_OPTS += --disable-video-rpi
> +endif
> +
>  # x-includes and x-libraries must be set for cross-compiling
>  # By default x_includes and x_libraries contains unsafe paths.
>  # (/usr/X11R6/include and /usr/X11R6/lib)
> -- 
> 2.13.6

-- 
gamaral

  reply	other threads:[~2018-01-18 17:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16  3:34 [Buildroot] [PATCH 1/2] package/sdl2: Fix Raspberry Pi support for SDL2 Guillermo A. Amaral
2018-01-16  3:34 ` [Buildroot] [PATCH 2/2] package/rpi-fbcp: Added package for Raspberry Pi Guillermo A. Amaral
2018-01-16  8:26   ` Thomas Petazzoni
2018-01-16 18:05     ` Guillermo A. Amaral
2018-01-16  8:23 ` [Buildroot] [PATCH 1/2] package/sdl2: Fix Raspberry Pi support for SDL2 Thomas Petazzoni
2018-01-16 17:50   ` Guillermo A. Amaral
2018-01-18  8:15     ` [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support in package SDL2 Guillermo A. Amaral
2018-01-18  8:19       ` Guillermo A. Amaral
2018-01-18 15:05       ` Thomas Petazzoni
2018-01-18 15:44         ` Adrian Perez de Castro
2018-01-18 16:22           ` Thomas Petazzoni
2018-01-18 16:35             ` Guillermo A. Amaral
2018-01-18 16:43               ` Thomas Petazzoni
2018-01-18 17:54                 ` [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2 Guillermo A. Amaral
2018-01-18 17:56                   ` Guillermo A. Amaral [this message]
2018-01-18 21:17                   ` Thomas Petazzoni
2018-01-19  6:25                     ` Guillermo A. Amaral
2018-01-19 17:11                   ` Ryan Coe
     [not found]                     ` <CAPeEpDouAm5vqoQQ3PmHcJwvssMe=3yyyrQUvc4zoaw3ehandw@mail.gmail.com>
     [not found]                       ` <CAPeEpDrdRC2eDW5Q=YEc8naVfNz6aLq7zbd4Wcx=FUmEmfdswQ@mail.gmail.com>
     [not found]                         ` <CAPeEpDqrw8369-bhX0j3+5T-ZWo_1bW6=tnYpw8SiWUj5KMBAQ@mail.gmail.com>
     [not found]                           ` <CAPeEpDoZ64=_wE=4OXQvZ_hJdZN9u7eAzOEbXP-+bH05dF1WGg@mail.gmail.com>
2018-01-19 19:24                             ` Guillermo Amaral
2018-01-19 21:40                               ` Peter Korsgaard
2018-01-20 21:25                                 ` [Buildroot] [PATCH 1/1] package/sdl2: Remove trailing backslash Guillermo A. Amaral
2018-01-22 21:29                                   ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180118175604.GA16776@enterprise.starfleet \
    --to=g@maral.me \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox