Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/sdl2: Fix Raspberry Pi support for SDL2
@ 2018-01-16  3:34 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:23 ` [Buildroot] [PATCH 1/2] package/sdl2: Fix Raspberry Pi support for SDL2 Thomas Petazzoni
  0 siblings, 2 replies; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-16  3:34 UTC (permalink / raw)
  To: buildroot

Tweak build system to play well with Buildroot.

Signed-off-by: Guillermo A. Amaral <g@maral.me>
---
 .../sdl2/0001-sdl2-rpi-video-buildroot-fix.patch   | 90 ++++++++++++++++++++++
 package/sdl2/sdl2.mk                               |  8 +-
 2 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch

diff --git a/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch b/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch
new file mode 100644
index 000000000..1866579f1
--- /dev/null
+++ b/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch
@@ -0,0 +1,90 @@
+From 76cb63afbe53c984c9734dc4f034c670791ca4d2 Mon Sep 17 00:00:00 2001
+From: "Guillermo A. Amaral" <g@maral.me>
+Date: Sun, 14 Jan 2018 23:01:47 -0800
+Subject: [PATCH] sdl2: Get Raspberry Pi video working on Buildroot
+
+Signed-off-by: Guillermo A. Amaral <g@maral.me>
+---
+ configure           |  8 +++++++-
+ configure.in        |  8 +++++++-
+ src/video/SDL_egl.c | 12 ++++++------
+ 3 files changed, 20 insertions(+), 8 deletions(-)
+
+diff --git a/configure b/configure
+index b622085..36e6623 100755
+--- a/configure
++++ b/configure
+@@ -19488,6 +19488,9 @@ fi
+         if 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"
++        elif test x$VENDOR = xbuildroot; then
++            RPI_CFLAGS="-I${STAGING_DIR}/usr/include/interface/vcos/pthreads -I${STAGING_DIR}/usr/include/interface/vmcs_host/linux"
++            RPI_LDFLAGS="-L${STAGING_DIR}/usr/lib -lbcm_host -lvchostif"
+         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"
+@@ -23739,7 +23742,10 @@ case "$host" in
+                     SUMMARY_video="${SUMMARY_video} android"
+                 fi
+                 ;;
+-            *-*-linux*)         ARCH=linux ;;
++            *-*-linux*)
++                ARCH=linux
++                VENDOR=buildroot
++                ;;
+             *-*-uclinux*)       ARCH=linux ;;
+             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
+             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
+diff --git a/configure.in b/configure.in
+index 5ac2130..daee88b 100644
+--- a/configure.in
++++ b/configure.in
+@@ -1566,6 +1566,9 @@ AC_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=ye
+         if 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"
++        elif test x$VENDOR = xbuildroot; then
++            RPI_CFLAGS="-I${STAGING_DIR}/usr/include/interface/vcos/pthreads -I${STAGING_DIR}/usr/include/interface/vmcs_host/linux"
++            RPI_LDFLAGS="-L${STAGING_DIR}/usr/lib -lbcm_host -lvchostif"
+         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"
+@@ -3260,7 +3263,10 @@ case "$host" in
+                     SUMMARY_video="${SUMMARY_video} android"
+                 fi
+                 ;;
+-            *-*-linux*)         ARCH=linux ;;
++            *-*-linux*)
++                ARCH=linux
++                VENDOR=buildroot
++                ;;
+             *-*-uclinux*)       ARCH=linux ;;
+             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
+             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
+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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 2/2] package/rpi-fbcp: Added package for Raspberry Pi
  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 ` Guillermo A. Amaral
  2018-01-16  8:26   ` Thomas Petazzoni
  2018-01-16  8:23 ` [Buildroot] [PATCH 1/2] package/sdl2: Fix Raspberry Pi support for SDL2 Thomas Petazzoni
  1 sibling, 1 reply; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-16  3:34 UTC (permalink / raw)
  To: buildroot

Raspberry Pi utility used to mirror primary framebuffer to secondary
framebuffer.

Signed-off-by: Guillermo A. Amaral <g@maral.me>
---
 package/Config.in                                  |  1 +
 .../rpi-fbcp/0001-make-buildroot-friendly.patch    | 35 ++++++++++++++++++++++
 package/rpi-fbcp/Config.in                         | 13 ++++++++
 package/rpi-fbcp/rpi-fbcp.mk                       | 11 +++++++
 4 files changed, 60 insertions(+)
 create mode 100644 package/rpi-fbcp/0001-make-buildroot-friendly.patch
 create mode 100644 package/rpi-fbcp/Config.in
 create mode 100644 package/rpi-fbcp/rpi-fbcp.mk

diff --git a/package/Config.in b/package/Config.in
index 8e8e7581c..c54901c69 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -483,6 +483,7 @@ endmenu
 	source "package/read-edid/Config.in"
 	source "package/rng-tools/Config.in"
 	source "package/rpi-userland/Config.in"
+	source "package/rpi-fbcp/Config.in"
 	source "package/rs485conf/Config.in"
 	source "package/rtl8188eu/Config.in"
 	source "package/rtl8723bs/Config.in"
diff --git a/package/rpi-fbcp/0001-make-buildroot-friendly.patch b/package/rpi-fbcp/0001-make-buildroot-friendly.patch
new file mode 100644
index 000000000..5f86f5af6
--- /dev/null
+++ b/package/rpi-fbcp/0001-make-buildroot-friendly.patch
@@ -0,0 +1,35 @@
+From 8218434aafd18f7a1f742bddeef10b8829d59f89 Mon Sep 17 00:00:00 2001
+From: "Guillermo A. Amaral" <g@maral.me>
+Date: Sun, 14 Jan 2018 15:22:21 -0800
+Subject: [PATCH] Make build script more buildroot friendly
+
+Signed-off-by: Guillermo A. Amaral <g@maral.me>
+---
+ CMakeLists.txt | 13 +++----------
+ 1 file changed, 3 insertions(+), 10 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6202553..367182c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,14 +1,7 @@
+ cmake_minimum_required(VERSION 2.8)
+ 
+-SET(COMPILE_DEFINITIONS -Werror)
+-
+-include_directories(/opt/vc/include)
+-include_directories(/opt/vc/include/interface/vcos/pthreads)
+-include_directories(/opt/vc/include/interface/vmcs_host)
+-include_directories(/opt/vc/include/interface/vmcs_host/linux)
+-
+-link_directories(/opt/vc/lib)
+-
+ add_executable(fbcp main.c)
+ 
+-target_link_libraries(fbcp bcm_host)
++target_link_libraries(fbcp bcm_host vchostif)
++
++install(TARGETS fbcp RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/sbin")
+-- 
+2.13.6
+
diff --git a/package/rpi-fbcp/Config.in b/package/rpi-fbcp/Config.in
new file mode 100644
index 000000000..9a186de9c
--- /dev/null
+++ b/package/rpi-fbcp/Config.in
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_RPI_FBCP
+	bool "rpi-fbcp"
+	depends on BR2_arm
+	depends on BR2_PACKAGE_RPI_USERLAND
+	help
+	  Raspberry Pi utility. Used for mirror primary framebuffer to
+	  secondary framebuffer.
+
+	  https://github.com/tasanakorn/rpi-fbcp
+
+comment "rpi-fbc needs rpi-userland"
+	depends on BR2_arm
+	depends on !BR2_PACKAGE_RPI_USERLAND
diff --git a/package/rpi-fbcp/rpi-fbcp.mk b/package/rpi-fbcp/rpi-fbcp.mk
new file mode 100644
index 000000000..72f778c1e
--- /dev/null
+++ b/package/rpi-fbcp/rpi-fbcp.mk
@@ -0,0 +1,11 @@
+################################################################################
+#
+# rpi-fbcp
+#
+################################################################################
+
+RPI_FBCP_VERSION = 8087a71d0330a078d91aa78656684ab5313616c6
+RPI_FBCP_SITE = $(call github,tasanakorn,rpi-fbcp,$(RPI_FBCP_VERSION))
+RPI_FBCP_DEPENDENCIES = rpi-userland
+
+$(eval $(cmake-package))
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/2] package/sdl2: Fix Raspberry Pi support for SDL2
  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:23 ` Thomas Petazzoni
  2018-01-16 17:50   ` Guillermo A. Amaral
  1 sibling, 1 reply; 22+ messages in thread
From: Thomas Petazzoni @ 2018-01-16  8:23 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon, 15 Jan 2018 19:34:49 -0800, Guillermo A. Amaral wrote:

> diff --git a/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch b/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch
> new file mode 100644
> index 000000000..1866579f1
> --- /dev/null
> +++ b/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch
> @@ -0,0 +1,90 @@
> +From 76cb63afbe53c984c9734dc4f034c670791ca4d2 Mon Sep 17 00:00:00 2001
> +From: "Guillermo A. Amaral" <g@maral.me>
> +Date: Sun, 14 Jan 2018 23:01:47 -0800
> +Subject: [PATCH] sdl2: Get Raspberry Pi video working on Buildroot

It's not nice to have this specific to Buildroot. It shouldn't be that
way, and having it specific to Buildroot means that the patch cannot be
accepted upstream. See below for a suggestion on how to improve.

> + configure           |  8 +++++++-

Do you really need to patch the configure script? What about fixing
just configure.in, and using AUTORECONF = YES ?

> + configure.in        |  8 +++++++-
> + src/video/SDL_egl.c | 12 ++++++------
> + 3 files changed, 20 insertions(+), 8 deletions(-)
> +
> +diff --git a/configure.in b/configure.in
> +index 5ac2130..daee88b 100644
> +--- a/configure.in
> ++++ b/configure.in
> +@@ -1566,6 +1566,9 @@ AC_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=ye
> +         if 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"
> ++        elif test x$VENDOR = xbuildroot; then
> ++            RPI_CFLAGS="-I${STAGING_DIR}/usr/include/interface/vcos/pthreads -I${STAGING_DIR}/usr/include/interface/vmcs_host/linux"
> ++            RPI_LDFLAGS="-L${STAGING_DIR}/usr/lib -lbcm_host -lvchostif"
> +         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"

Here is a different suggestion. In the "else", do the following:

	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`
		RPI_LDFLAGS=`$PKG_CONFIG --libs bcm_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"
	fi

This should use pkg-config if available, and bcm_host is available as
pkg-config module, and if not default to the hardcoded path in /opt/vc.

> +@@ -3260,7 +3263,10 @@ case "$host" in
> +                     SUMMARY_video="${SUMMARY_video} android"
> +                 fi
> +                 ;;
> +-            *-*-linux*)         ARCH=linux ;;
> ++            *-*-linux*)
> ++                ARCH=linux
> ++                VENDOR=buildroot
> ++                ;;

It would make this change unneeded.

> + #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"

I am not totally sure how to solve this though. I think the easiest
solution is for the configure script to fill in another variable, like
RPI_LIB_DIR. It would be set to empty in the pkg-config case, assuming
the libraries are in the right location, and set to /opt/vc/lib in the
hardcoded case. Or for the pkg-config case you do:

	RPI_LIB_DIR=`PKG_CONFIG_SYSROOT_DIR=/ $PKG_CONFIG --libs-only-L bcm_host | sed 's/^-L//'`

But I believe leaving it to empty is fine as well. Indeed dlopen()
automatically searches in the default library paths, and if the library
is not installed in the default location, it's up to the user to pass
LD_LIBRARY_PATH.

Best regards,

Thomas Petazzoni
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 2/2] package/rpi-fbcp: Added package for Raspberry Pi
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas Petazzoni @ 2018-01-16  8:26 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon, 15 Jan 2018 19:34:50 -0800, Guillermo A. Amaral wrote:
> Raspberry Pi utility used to mirror primary framebuffer to secondary
> framebuffer.
> 
> Signed-off-by: Guillermo A. Amaral <g@maral.me>
> ---
>  package/Config.in                                  |  1 +
>  .../rpi-fbcp/0001-make-buildroot-friendly.patch    | 35 ++++++++++++++++++++++
>  package/rpi-fbcp/Config.in                         | 13 ++++++++
>  package/rpi-fbcp/rpi-fbcp.mk                       | 11 +++++++

Could you add an entry in the DEVELOPERS file for this package?

> diff --git a/package/rpi-fbcp/0001-make-buildroot-friendly.patch b/package/rpi-fbcp/0001-make-buildroot-friendly.patch
> new file mode 100644
> index 000000000..5f86f5af6
> --- /dev/null
> +++ b/package/rpi-fbcp/0001-make-buildroot-friendly.patch
> @@ -0,0 +1,35 @@
> +From 8218434aafd18f7a1f742bddeef10b8829d59f89 Mon Sep 17 00:00:00 2001
> +From: "Guillermo A. Amaral" <g@maral.me>
> +Date: Sun, 14 Jan 2018 15:22:21 -0800
> +Subject: [PATCH] Make build script more buildroot friendly
> +
> +Signed-off-by: Guillermo A. Amaral <g@maral.me>

Here as well, this Buildroot-specific patch is not nice.

> +---
> + CMakeLists.txt | 13 +++----------
> + 1 file changed, 3 insertions(+), 10 deletions(-)
> +
> +diff --git a/CMakeLists.txt b/CMakeLists.txt
> +index 6202553..367182c 100644
> +--- a/CMakeLists.txt
> ++++ b/CMakeLists.txt
> +@@ -1,14 +1,7 @@
> + cmake_minimum_required(VERSION 2.8)
> + 
> +-SET(COMPILE_DEFINITIONS -Werror)
> +-
> +-include_directories(/opt/vc/include)
> +-include_directories(/opt/vc/include/interface/vcos/pthreads)
> +-include_directories(/opt/vc/include/interface/vmcs_host)
> +-include_directories(/opt/vc/include/interface/vmcs_host/linux)
> +-
> +-link_directories(/opt/vc/lib)
> +-

What about using pkg-config again ?

> + add_executable(fbcp main.c)
> + 
> +-target_link_libraries(fbcp bcm_host)
> ++target_link_libraries(fbcp bcm_host vchostif)
> ++
> ++install(TARGETS fbcp RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/sbin")
> +-- 
> +2.13.6
> +
> diff --git a/package/rpi-fbcp/Config.in b/package/rpi-fbcp/Config.in
> new file mode 100644
> index 000000000..9a186de9c
> --- /dev/null
> +++ b/package/rpi-fbcp/Config.in
> @@ -0,0 +1,13 @@
> +config BR2_PACKAGE_RPI_FBCP
> +	bool "rpi-fbcp"
> +	depends on BR2_arm
> +	depends on BR2_PACKAGE_RPI_USERLAND
> +	help
> +	  Raspberry Pi utility. Used for mirror primary framebuffer to
> +	  secondary framebuffer.
> +
> +	  https://github.com/tasanakorn/rpi-fbcp
> +
> +comment "rpi-fbc needs rpi-userland"
> +	depends on BR2_arm
> +	depends on !BR2_PACKAGE_RPI_USERLAND
> diff --git a/package/rpi-fbcp/rpi-fbcp.mk b/package/rpi-fbcp/rpi-fbcp.mk
> new file mode 100644
> index 000000000..72f778c1e
> --- /dev/null
> +++ b/package/rpi-fbcp/rpi-fbcp.mk
> @@ -0,0 +1,11 @@
> +################################################################################
> +#
> +# rpi-fbcp
> +#
> +################################################################################
> +
> +RPI_FBCP_VERSION = 8087a71d0330a078d91aa78656684ab5313616c6
> +RPI_FBCP_SITE = $(call github,tasanakorn,rpi-fbcp,$(RPI_FBCP_VERSION))
> +RPI_FBCP_DEPENDENCIES = rpi-userland

The package upstream has no license information, which basically means
you're not allowed to distribute it. A bit annoying, no?

Could you get in touch with the upstream developer to ask him/her to
add license information. I do realize that this repository hasn't seen
any update since 4 years, so there are some chances that the upstream
developer doesn't answer. But really, shipping code that has no license
is bad.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/2] package/sdl2: Fix Raspberry Pi support for SDL2
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-16 17:50 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

On Tue, Jan 16, 2018 at 09:23:41AM +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Mon, 15 Jan 2018 19:34:49 -0800, Guillermo A. Amaral wrote:
> 
> > diff --git a/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch b/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch
> > new file mode 100644
> > index 000000000..1866579f1
> > --- /dev/null
> > +++ b/package/sdl2/0001-sdl2-rpi-video-buildroot-fix.patch
> > @@ -0,0 +1,90 @@
> > +From 76cb63afbe53c984c9734dc4f034c670791ca4d2 Mon Sep 17 00:00:00 2001
> > +From: "Guillermo A. Amaral" <g@maral.me>
> > +Date: Sun, 14 Jan 2018 23:01:47 -0800
> > +Subject: [PATCH] sdl2: Get Raspberry Pi video working on Buildroot
> 
> It's not nice to have this specific to Buildroot. It shouldn't be that
> way, and having it specific to Buildroot means that the patch cannot be
> accepted upstream. See below for a suggestion on how to improve.

Agreed, I'll first try to upstream the changes to the project.

> > + configure           |  8 +++++++-
> 
> Do you really need to patch the configure script? What about fixing
> just configure.in, and using AUTORECONF = YES ?

I was not sure if that was the right way to go, so I left that off and
updated the configure script too just in case. I'll take that into
account for any future submissions.

> > + configure.in        |  8 +++++++-
> > + src/video/SDL_egl.c | 12 ++++++------
> > + 3 files changed, 20 insertions(+), 8 deletions(-)
> > +
> > +diff --git a/configure.in b/configure.in
> > +index 5ac2130..daee88b 100644
> > +--- a/configure.in
> > ++++ b/configure.in
> > +@@ -1566,6 +1566,9 @@ AC_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=ye
> > +         if 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"
> > ++        elif test x$VENDOR = xbuildroot; then
> > ++            RPI_CFLAGS="-I${STAGING_DIR}/usr/include/interface/vcos/pthreads -I${STAGING_DIR}/usr/include/interface/vmcs_host/linux"
> > ++            RPI_LDFLAGS="-L${STAGING_DIR}/usr/lib -lbcm_host -lvchostif"
> > +         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"
> 
> Here is a different suggestion. In the "else", do the following:
> 
> 	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`
> 		RPI_LDFLAGS=`$PKG_CONFIG --libs bcm_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"
> 	fi
> 
> This should use pkg-config if available, and bcm_host is available as
> pkg-config module, and if not default to the hardcoded path in /opt/vc.

Oh that's pretty good, I totally forgot about BRs pkg-config. I'll try
it out.

> > +@@ -3260,7 +3263,10 @@ case "$host" in
> > +                     SUMMARY_video="${SUMMARY_video} android"
> > +                 fi
> > +                 ;;
> > +-            *-*-linux*)         ARCH=linux ;;
> > ++            *-*-linux*)
> > ++                ARCH=linux
> > ++                VENDOR=buildroot
> > ++                ;;
> 
> It would make this change unneeded.
> 
> > + #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"
> 
> I am not totally sure how to solve this though. I think the easiest
> solution is for the configure script to fill in another variable, like
> RPI_LIB_DIR. It would be set to empty in the pkg-config case, assuming
> the libraries are in the right location, and set to /opt/vc/lib in the
> hardcoded case. Or for the pkg-config case you do:
> 
> 	RPI_LIB_DIR=`PKG_CONFIG_SYSROOT_DIR=/ $PKG_CONFIG --libs-only-L bcm_host | sed 's/^-L//'`
> 
> But I believe leaving it to empty is fine as well. Indeed dlopen()
> automatically searches in the default library paths, and if the library
> is not installed in the default location, it's up to the user to pass
> LD_LIBRARY_PATH.
> 

Right, sounds like a plan.

Thanks for reviewing the patch, I'll update it. I'll try to get upstream
as well.

-- 
gamaral

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 2/2] package/rpi-fbcp: Added package for Raspberry Pi
  2018-01-16  8:26   ` Thomas Petazzoni
@ 2018-01-16 18:05     ` Guillermo A. Amaral
  0 siblings, 0 replies; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-16 18:05 UTC (permalink / raw)
  To: buildroot

Howdy,

I'll also update this patch too, thanks for taking a look.

I did try to contact the developer about a year ago (via GitHub) about
it. No luck.

I'll try via social media, maybe I can get him to BSD or MIT it and be
done with it.

Thanks again!

On Tue, Jan 16, 2018 at 09:26:33AM +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Mon, 15 Jan 2018 19:34:50 -0800, Guillermo A. Amaral wrote:
> > Raspberry Pi utility used to mirror primary framebuffer to secondary
> > framebuffer.
> > 
> > Signed-off-by: Guillermo A. Amaral <g@maral.me>
> > ---
> >  package/Config.in                                  |  1 +
> >  .../rpi-fbcp/0001-make-buildroot-friendly.patch    | 35 ++++++++++++++++++++++
> >  package/rpi-fbcp/Config.in                         | 13 ++++++++
> >  package/rpi-fbcp/rpi-fbcp.mk                       | 11 +++++++
> 
> Could you add an entry in the DEVELOPERS file for this package?
> 
> > diff --git a/package/rpi-fbcp/0001-make-buildroot-friendly.patch b/package/rpi-fbcp/0001-make-buildroot-friendly.patch
> > new file mode 100644
> > index 000000000..5f86f5af6
> > --- /dev/null
> > +++ b/package/rpi-fbcp/0001-make-buildroot-friendly.patch
> > @@ -0,0 +1,35 @@
> > +From 8218434aafd18f7a1f742bddeef10b8829d59f89 Mon Sep 17 00:00:00 2001
> > +From: "Guillermo A. Amaral" <g@maral.me>
> > +Date: Sun, 14 Jan 2018 15:22:21 -0800
> > +Subject: [PATCH] Make build script more buildroot friendly
> > +
> > +Signed-off-by: Guillermo A. Amaral <g@maral.me>
> 
> Here as well, this Buildroot-specific patch is not nice.
> 
> > +---
> > + CMakeLists.txt | 13 +++----------
> > + 1 file changed, 3 insertions(+), 10 deletions(-)
> > +
> > +diff --git a/CMakeLists.txt b/CMakeLists.txt
> > +index 6202553..367182c 100644
> > +--- a/CMakeLists.txt
> > ++++ b/CMakeLists.txt
> > +@@ -1,14 +1,7 @@
> > + cmake_minimum_required(VERSION 2.8)
> > + 
> > +-SET(COMPILE_DEFINITIONS -Werror)
> > +-
> > +-include_directories(/opt/vc/include)
> > +-include_directories(/opt/vc/include/interface/vcos/pthreads)
> > +-include_directories(/opt/vc/include/interface/vmcs_host)
> > +-include_directories(/opt/vc/include/interface/vmcs_host/linux)
> > +-
> > +-link_directories(/opt/vc/lib)
> > +-
> 
> What about using pkg-config again ?
> 
> > + add_executable(fbcp main.c)
> > + 
> > +-target_link_libraries(fbcp bcm_host)
> > ++target_link_libraries(fbcp bcm_host vchostif)
> > ++
> > ++install(TARGETS fbcp RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/sbin")
> > +-- 
> > +2.13.6
> > +
> > diff --git a/package/rpi-fbcp/Config.in b/package/rpi-fbcp/Config.in
> > new file mode 100644
> > index 000000000..9a186de9c
> > --- /dev/null
> > +++ b/package/rpi-fbcp/Config.in
> > @@ -0,0 +1,13 @@
> > +config BR2_PACKAGE_RPI_FBCP
> > +	bool "rpi-fbcp"
> > +	depends on BR2_arm
> > +	depends on BR2_PACKAGE_RPI_USERLAND
> > +	help
> > +	  Raspberry Pi utility. Used for mirror primary framebuffer to
> > +	  secondary framebuffer.
> > +
> > +	  https://github.com/tasanakorn/rpi-fbcp
> > +
> > +comment "rpi-fbc needs rpi-userland"
> > +	depends on BR2_arm
> > +	depends on !BR2_PACKAGE_RPI_USERLAND
> > diff --git a/package/rpi-fbcp/rpi-fbcp.mk b/package/rpi-fbcp/rpi-fbcp.mk
> > new file mode 100644
> > index 000000000..72f778c1e
> > --- /dev/null
> > +++ b/package/rpi-fbcp/rpi-fbcp.mk
> > @@ -0,0 +1,11 @@
> > +################################################################################
> > +#
> > +# rpi-fbcp
> > +#
> > +################################################################################
> > +
> > +RPI_FBCP_VERSION = 8087a71d0330a078d91aa78656684ab5313616c6
> > +RPI_FBCP_SITE = $(call github,tasanakorn,rpi-fbcp,$(RPI_FBCP_VERSION))
> > +RPI_FBCP_DEPENDENCIES = rpi-userland
> 
> The package upstream has no license information, which basically means
> you're not allowed to distribute it. A bit annoying, no?
> 
> Could you get in touch with the upstream developer to ask him/her to
> add license information. I do realize that this repository hasn't seen
> any update since 4 years, so there are some chances that the upstream
> developer doesn't answer. But really, shipping code that has no license
> is bad.
> 
> Thanks!
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 
gamaral

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support in package SDL2
  2018-01-16 17:50   ` Guillermo A. Amaral
@ 2018-01-18  8:15     ` Guillermo A. Amaral
  2018-01-18  8:19       ` Guillermo A. Amaral
  2018-01-18 15:05       ` Thomas Petazzoni
  0 siblings, 2 replies; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-18  8:15 UTC (permalink / raw)
  To: buildroot

Backported upstream patch which makes SDL2 more cross-compiler friendly.

Signed-off-by: Guillermo A. Amaral <g@maral.me>
---
 .../sdl2/0001-make-cross-compiler-friendly.patch   | 176 +++++++++++++++++++++
 package/sdl2/sdl2.mk                               |   8 +-
 2 files changed, 183 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..42d636adc
--- /dev/null
+++ b/package/sdl2/0001-make-cross-compiler-friendly.patch
@@ -0,0 +1,176 @@
+From ca98276a3b806b06a019ba5784b075d5d371befd Mon Sep 17 00:00:00 2001
+From: "Guillermo A. Amaral" <g@maral.me>
+Date: Tue, 16 Jan 2018 22:19:12 -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 | 13 ++++++++-----
+ configure             | 46 +++++++++++++++++++++++++++++++++++++++++++++-
+ configure.in          |  6 +++++-
+ src/video/SDL_egl.c   | 29 +++++++++++++++++++++++------
+ 4 files changed, 81 insertions(+), 13 deletions(-)
+
+diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
+index e2e89a2..5dde86c 100644
+--- a/cmake/sdlchecks.cmake
++++ b/cmake/sdlchecks.cmake
+@@ -1127,15 +1127,18 @@ 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 )
++    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,7 +1150,7 @@ 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}")
+     endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
+   endif(VIDEO_RPI)
+diff --git a/configure b/configure
+index b622085..5e91d08 100755
+--- a/configure
++++ b/configure
+@@ -19485,7 +19485,51 @@ 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
+diff --git a/configure.in b/configure.in
+index 5ac2130..6a0b380 100644
+--- a/configure.in
++++ b/configure.in
+@@ -1563,7 +1563,11 @@ 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
+diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
+index 9ccc2c3..08132b4 100644
+--- a/src/video/SDL_egl.c
++++ b/src/video/SDL_egl.c
+@@ -44,12 +44,13 @@
+ 
+ #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"
++static const char g_rpi_opt_path[] = "/opt/vc/lib";
++#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 */
+@@ -257,6 +258,22 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
+     const char *d3dcompiler;
+ #endif
+ 
++#if SDL_VIDEO_DRIVER_RPI
++    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
++
+     if (_this->egl_data) {
+         return SDL_SetError("OpenGL ES context already created");
+     }
+-- 
+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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support in package SDL2
  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
  1 sibling, 0 replies; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-18  8:19 UTC (permalink / raw)
  To: buildroot

Hi,

Just a little heads up. I did try AUTORECONF but it would fail to
generate the configure script.

The upstream patch contains the configure diff as well, so I left well
enough alone.

Cheers,
G

On Thu, Jan 18, 2018 at 12:15:28AM -0800, Guillermo A. Amaral wrote:
> Backported upstream patch which makes SDL2 more cross-compiler friendly.
> 
> Signed-off-by: Guillermo A. Amaral <g@maral.me>
> ---
>  .../sdl2/0001-make-cross-compiler-friendly.patch   | 176 +++++++++++++++++++++
>  package/sdl2/sdl2.mk                               |   8 +-
>  2 files changed, 183 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..42d636adc
> --- /dev/null
> +++ b/package/sdl2/0001-make-cross-compiler-friendly.patch
> @@ -0,0 +1,176 @@
> +From ca98276a3b806b06a019ba5784b075d5d371befd Mon Sep 17 00:00:00 2001
> +From: "Guillermo A. Amaral" <g@maral.me>
> +Date: Tue, 16 Jan 2018 22:19:12 -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 | 13 ++++++++-----
> + configure             | 46 +++++++++++++++++++++++++++++++++++++++++++++-
> + configure.in          |  6 +++++-
> + src/video/SDL_egl.c   | 29 +++++++++++++++++++++++------
> + 4 files changed, 81 insertions(+), 13 deletions(-)
> +
> +diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
> +index e2e89a2..5dde86c 100644
> +--- a/cmake/sdlchecks.cmake
> ++++ b/cmake/sdlchecks.cmake
> +@@ -1127,15 +1127,18 @@ 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 )
> ++    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,7 +1150,7 @@ 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}")
> +     endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
> +   endif(VIDEO_RPI)
> +diff --git a/configure b/configure
> +index b622085..5e91d08 100755
> +--- a/configure
> ++++ b/configure
> +@@ -19485,7 +19485,51 @@ 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
> +diff --git a/configure.in b/configure.in
> +index 5ac2130..6a0b380 100644
> +--- a/configure.in
> ++++ b/configure.in
> +@@ -1563,7 +1563,11 @@ 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
> +diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
> +index 9ccc2c3..08132b4 100644
> +--- a/src/video/SDL_egl.c
> ++++ b/src/video/SDL_egl.c
> +@@ -44,12 +44,13 @@
> + 
> + #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"
> ++static const char g_rpi_opt_path[] = "/opt/vc/lib";
> ++#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 */
> +@@ -257,6 +258,22 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
> +     const char *d3dcompiler;
> + #endif
> + 
> ++#if SDL_VIDEO_DRIVER_RPI
> ++    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
> ++
> +     if (_this->egl_data) {
> +         return SDL_SetError("OpenGL ES context already created");
> +     }
> +-- 
> +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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support in package SDL2
  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
  1 sibling, 1 reply; 22+ messages in thread
From: Thomas Petazzoni @ 2018-01-18 15:05 UTC (permalink / raw)
  To: buildroot

Hello,

Thanks for respining! It looks much better, but there's still one thing
I'm not sure is very good. See below.

On Thu, 18 Jan 2018 00:15:28 -0800, Guillermo A. Amaral wrote:

> ++#if SDL_VIDEO_DRIVER_RPI
> ++    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;

Yerk, upstream has accepted this? To me, it looks really terrible to
set LD_LIBRARY_PATH from within a program. Is it really considered a
good practice ?

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support in package SDL2
  2018-01-18 15:05       ` Thomas Petazzoni
@ 2018-01-18 15:44         ` Adrian Perez de Castro
  2018-01-18 16:22           ` Thomas Petazzoni
  0 siblings, 1 reply; 22+ messages in thread
From: Adrian Perez de Castro @ 2018-01-18 15:44 UTC (permalink / raw)
  To: buildroot

Hello everybody,

On Thu, 18 Jan 2018 16:05:14 +0100, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:
 
> Thanks for respining! It looks much better, but there's still one thing
> I'm not sure is very good. See below.
> 
> On Thu, 18 Jan 2018 00:15:28 -0800, Guillermo A. Amaral wrote:
> 
> > ++#if SDL_VIDEO_DRIVER_RPI
> > ++    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;
> 
> Yerk, upstream has accepted this? To me, it looks really terrible to
> set LD_LIBRARY_PATH from within a program. Is it really considered a
> good practice ?

Historically in WebKitGTK+ we have had our share of issues with environment
variables, mainly due to ?setenv()? not being thread-safe: the only case in
which it does really work is at the very beginning of program execution,
before any threads or secondary processes are started. Otherwise it's easy
to shoot oneself on the foot and end up with threads/processes that ?see?
different values for the same environment variable.

Provided that the patch is adding to ?LD_LIBRARY_PATH?, maybe one option could
be using ?patchelf? to add the path to the DT_RUNPATH entry in the ELF header
of ?libSDL2.so? in a post-build (or post-install?) hook. Or, if possible,
arrange to pass the needed linker flags to get the path added there.

Or, even better, add ?/opt/vc/lib? in DT_RUNPATH when the RPi VideoCore
libraries are installed into ?/opt/vc? ? somehow that sounds more correct
in my head. WDYT?

Cheers,


--
 Adri?n ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180118/25b5f162/attachment.asc>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support in package SDL2
  2018-01-18 15:44         ` Adrian Perez de Castro
@ 2018-01-18 16:22           ` Thomas Petazzoni
  2018-01-18 16:35             ` Guillermo A. Amaral
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas Petazzoni @ 2018-01-18 16:22 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 18 Jan 2018 15:44:41 +0000, Adrian Perez de Castro wrote:

> Historically in WebKitGTK+ we have had our share of issues with environment
> variables, mainly due to ?setenv()? not being thread-safe: the only case in
> which it does really work is at the very beginning of program execution,
> before any threads or secondary processes are started. Otherwise it's easy
> to shoot oneself on the foot and end up with threads/processes that ?see?
> different values for the same environment variable.
> 
> Provided that the patch is adding to ?LD_LIBRARY_PATH?, maybe one option could
> be using ?patchelf? to add the path to the DT_RUNPATH entry in the ELF header
> of ?libSDL2.so? in a post-build (or post-install?) hook. Or, if possible,
> arrange to pass the needed linker flags to get the path added there.
> 
> Or, even better, add ?/opt/vc/lib? in DT_RUNPATH when the RPi VideoCore
> libraries are installed into ?/opt/vc? ? somehow that sounds more correct
> in my head. WDYT?

Yes, I agree it would be much better to add a -Wl,-rpath,/opt/vc/lib to
the LDFLAGS if the libraries are in /opt/vc/lib.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support in package SDL2
  2018-01-18 16:22           ` Thomas Petazzoni
@ 2018-01-18 16:35             ` Guillermo A. Amaral
  2018-01-18 16:43               ` Thomas Petazzoni
  0 siblings, 1 reply; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-18 16:35 UTC (permalink / raw)
  To: buildroot

On Thu, Jan 18, 2018 at 05:22:16PM +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Thu, 18 Jan 2018 15:44:41 +0000, Adrian Perez de Castro wrote:
> 
> > Historically in WebKitGTK+ we have had our share of issues with environment
> > variables, mainly due to ?setenv()? not being thread-safe: the only case in
> > which it does really work is at the very beginning of program execution,
> > before any threads or secondary processes are started. Otherwise it's easy
> > to shoot oneself on the foot and end up with threads/processes that ?see?
> > different values for the same environment variable.
> > 
> > Provided that the patch is adding to ?LD_LIBRARY_PATH?, maybe one option could
> > be using ?patchelf? to add the path to the DT_RUNPATH entry in the ELF header
> > of ?libSDL2.so? in a post-build (or post-install?) hook. Or, if possible,
> > arrange to pass the needed linker flags to get the path added there.
> > 
> > Or, even better, add ?/opt/vc/lib? in DT_RUNPATH when the RPi VideoCore
> > libraries are installed into ?/opt/vc? ? somehow that sounds more correct
> > in my head. WDYT?
> 
> Yes, I agree it would be much better to add a -Wl,-rpath,/opt/vc/lib to
> the LDFLAGS if the libraries are in /opt/vc/lib.
> 

After 6-7 years, I hoped that darn path wouldn't be an issue anymore.
If only Raspbian and friends would all add /opt/vc/lib to their
ld.so.conf...

Anyway, I'll try the rpath approach, using LD_LIBRARY_PATH did hurt a
little, but at the moment it looked like the lesser of two evils; They
already added in another workaround for more library locations for the
RPi and it's starting to look even more like a hodgepodge.

Cheers,
G

-- 
gamaral

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support in package SDL2
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas Petazzoni @ 2018-01-18 16:43 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 18 Jan 2018 08:35:51 -0800, Guillermo A. Amaral wrote:

> > Yes, I agree it would be much better to add a -Wl,-rpath,/opt/vc/lib to
> > the LDFLAGS if the libraries are in /opt/vc/lib.
> 
> After 6-7 years, I hoped that darn path wouldn't be an issue anymore.
> If only Raspbian and friends would all add /opt/vc/lib to their
> ld.so.conf...
> 
> Anyway, I'll try the rpath approach, using LD_LIBRARY_PATH did hurt a
> little, but at the moment it looked like the lesser of two evils; They
> already added in another workaround for more library locations for the
> RPi and it's starting to look even more like a hodgepodge.

I would be the SDL2 upstream developers, I would just tell the RPi
users to add /opt/vc/lib to /etc/ld.so.conf, if they really want to add
libraries in this non-standard location.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2
  2018-01-18 16:43               ` Thomas Petazzoni
@ 2018-01-18 17:54                 ` Guillermo A. Amaral
  2018-01-18 17:56                   ` Guillermo A. Amaral
                                     ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-18 17:54 UTC (permalink / raw)
  To: buildroot

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2
  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
  2018-01-18 21:17                   ` Thomas Petazzoni
  2018-01-19 17:11                   ` Ryan Coe
  2 siblings, 0 replies; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-18 17:56 UTC (permalink / raw)
  To: buildroot

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2
  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
@ 2018-01-18 21:17                   ` Thomas Petazzoni
  2018-01-19  6:25                     ` Guillermo A. Amaral
  2018-01-19 17:11                   ` Ryan Coe
  2 siblings, 1 reply; 22+ messages in thread
From: Thomas Petazzoni @ 2018-01-18 21:17 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 18 Jan 2018 09:54:15 -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

Applied to master, thanks. Please submit the patch upstream if not
already done. Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2
  2018-01-18 21:17                   ` Thomas Petazzoni
@ 2018-01-19  6:25                     ` Guillermo A. Amaral
  0 siblings, 0 replies; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-19  6:25 UTC (permalink / raw)
  To: buildroot

Hi,

On Thu, Jan 18, 2018 at 10:17:45PM +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Thu, 18 Jan 2018 09:54:15 -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
> 
> Applied to master, thanks. Please submit the patch upstream if not
> already done. Thanks!

Already submitted.

Thanks again for taking the time to review,
G

> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com

-- 
gamaral

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2
  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
  2018-01-18 21:17                   ` Thomas Petazzoni
@ 2018-01-19 17:11                   ` Ryan Coe
       [not found]                     ` <CAPeEpDouAm5vqoQQ3PmHcJwvssMe=3yyyrQUvc4zoaw3ehandw@mail.gmail.com>
  2 siblings, 1 reply; 22+ messages in thread
From: Ryan Coe @ 2018-01-19 17:11 UTC (permalink / raw)
  To: buildroot

Guillermo, All,


On 1/18/2018 9:54 AM, 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
--disable-video-wayland now has a dangling backslash.
>   
>   # 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)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2
       [not found]                           ` <CAPeEpDoZ64=_wE=4OXQvZ_hJdZN9u7eAzOEbXP-+bH05dF1WGg@mail.gmail.com>
@ 2018-01-19 19:24                             ` Guillermo Amaral
  2018-01-19 21:40                               ` Peter Korsgaard
  0 siblings, 1 reply; 22+ messages in thread
From: Guillermo Amaral @ 2018-01-19 19:24 UTC (permalink / raw)
  To: buildroot

Hi Ryan,

Yes, but to a blank line; It shouldn't break anything. I tend to leave
those in, in order to reduce diff changes in the future.

That said, I can avoid doing that in future submissions if that's frowned
upon here.

Cheers,
gamaral

On Jan 19, 2018 09:11, "Ryan Coe" <bluemrp9@gmail.com> wrote:

Guillermo, All,



On 1/18/2018 9:54 AM, 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/r
> aspberry/*.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/v
> mcs_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/v
> mcs_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
>
--disable-video-wayland now has a dangling backslash.

    # 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)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180119/d456eb13/attachment.html>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Fix Raspberry Pi support for SDL2
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Peter Korsgaard @ 2018-01-19 21:40 UTC (permalink / raw)
  To: buildroot

>>>>> "Guillermo" == Guillermo Amaral <g@maral.me> writes:

 > Hi Ryan,
 > Yes, but to a blank line; It shouldn't break anything. I tend to leave
 > those in, in order to reduce diff changes in the future.

 > That said, I can avoid doing that in future submissions if that's frowned
 > upon here.

We generally do remove them, yes.

Thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Remove trailing backslash
  2018-01-19 21:40                               ` Peter Korsgaard
@ 2018-01-20 21:25                                 ` Guillermo A. Amaral
  2018-01-22 21:29                                   ` Peter Korsgaard
  0 siblings, 1 reply; 22+ messages in thread
From: Guillermo A. Amaral @ 2018-01-20 21:25 UTC (permalink / raw)
  To: buildroot

Left over from 9f8a6fdf9

Signed-off-by: Guillermo A. Amaral <g@maral.me>
---
 package/sdl2/sdl2.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/sdl2/sdl2.mk b/package/sdl2/sdl2.mk
index 113e1063d..6cb24d9e7 100644
--- a/package/sdl2/sdl2.mk
+++ b/package/sdl2/sdl2.mk
@@ -18,7 +18,7 @@ SDL2_CONF_OPTS += \
 	--disable-esd \
 	--disable-dbus \
 	--disable-pulseaudio \
-	--disable-video-wayland \
+	--disable-video-wayland
 
 # We must enable static build to get compilation successful.
 SDL2_CONF_OPTS += --enable-static
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] package/sdl2: Remove trailing backslash
  2018-01-20 21:25                                 ` [Buildroot] [PATCH 1/1] package/sdl2: Remove trailing backslash Guillermo A. Amaral
@ 2018-01-22 21:29                                   ` Peter Korsgaard
  0 siblings, 0 replies; 22+ messages in thread
From: Peter Korsgaard @ 2018-01-22 21:29 UTC (permalink / raw)
  To: buildroot

>>>>> "Guillermo" == Guillermo A Amaral <g@maral.me> writes:

 > Left over from 9f8a6fdf9
 > Signed-off-by: Guillermo A. Amaral <g@maral.me>

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-01-22 21:29 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox