Fixed bug 3805 - Why is there no --enable-video-rpi option in configure?
authorSam Lantinga <slouken@libsdl.org>
Fri, 08 Sep 2017 22:21:01 -0700
changeset 11472f31b73040ea3
parent 11471 510e461e584a
child 11473 f0f6af2b086a
Fixed bug 3805 - Why is there no --enable-video-rpi option in configure?

Andreas Falkenhahn

When compiling SDL for the Raspberry Pi, I have to use the --host parameter to enable compilation of the native Raspberry Pi video driver, like so:

--host=arm-raspberry-linux-gnueabihf

It took me a while to figure out that this was necessary in order to have the native Raspberry Pi video driver compiled in. I think it would be better if there was an option like --enable-video-rpi that could be passed to configure and that would also show up when saying configure --help. Currently, it’s rather difficult to figure out that you have to use the --host parameter with arm-raspberry-linux-gnueabihf in order to get Raspberry Pi video support. It’s also somewhat inconsistent because most other video drivers can in fact be enabled/disabled through specific configure parameters but there is no such parameter for the native Raspberry Pi video driver.
configure
configure.in
src/video/raspberry/SDL_rpivideo.h
     1.1 --- a/configure	Fri Sep 08 18:26:25 2017 -0700
     1.2 +++ b/configure	Fri Sep 08 22:21:01 2017 -0700
     1.3 @@ -832,6 +832,7 @@
     1.4  enable_wayland_shared
     1.5  enable_video_mir
     1.6  enable_mir_shared
     1.7 +enable_video_rpi
     1.8  enable_video_x11
     1.9  with_x
    1.10  enable_x11_shared
    1.11 @@ -1572,6 +1573,7 @@
    1.12    --enable-wayland-shared dynamically load Wayland support [[default=maybe]]
    1.13    --enable-video-mir      use Mir video driver [[default=yes]]
    1.14    --enable-mir-shared     dynamically load Mir support [[default=maybe]]
    1.15 +  --enable-video-rpi      use Raspberry Pi video driver [[default=yes]]
    1.16    --enable-video-x11      use X11 video driver [[default=yes]]
    1.17    --enable-x11-shared     dynamically load X11 support [[default=maybe]]
    1.18    --enable-video-x11-xcursor
    1.19 @@ -19460,10 +19462,77 @@
    1.20  }
    1.21  
    1.22  
    1.23 +CheckRPI()
    1.24 +{
    1.25 +    # Check whether --enable-video-rpi was given.
    1.26 +if test "${enable_video_rpi+set}" = set; then :
    1.27 +  enableval=$enable_video_rpi;
    1.28 +else
    1.29 +  enable_video_rpi=yes
    1.30 +fi
    1.31 +
    1.32 +    if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
    1.33 +        if test x$ARCH = xnetbsd; then
    1.34 +            RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
    1.35 +            RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
    1.36 +        else
    1.37 +            RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
    1.38 +            RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host"
    1.39 +        fi
    1.40 +
    1.41 +        # Save the original compiler flags and libraries
    1.42 +        ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
    1.43 +
    1.44 +        # Add the Raspberry Pi compiler flags and libraries
    1.45 +        CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_LDFLAGS"
    1.46 +
    1.47 +        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Raspberry Pi" >&5
    1.48 +$as_echo_n "checking for Raspberry Pi... " >&6; }
    1.49 +        have_video_rpi=no
    1.50 +        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    1.51 +/* end confdefs.h.  */
    1.52 +
    1.53 +          #include <bcm_host.h>
    1.54 +
    1.55 +int
    1.56 +main ()
    1.57 +{
    1.58 +
    1.59 +          bcm_host_init();
    1.60 +
    1.61 +  ;
    1.62 +  return 0;
    1.63 +}
    1.64 +_ACEOF
    1.65 +if ac_fn_c_try_link "$LINENO"; then :
    1.66 +
    1.67 +        have_video_rpi=yes
    1.68 +
    1.69 +fi
    1.70 +rm -f core conftest.err conftest.$ac_objext \
    1.71 +    conftest$ac_exeext conftest.$ac_ext
    1.72 +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_video_rpi" >&5
    1.73 +$as_echo "$have_video_rpi" >&6; }
    1.74 +
    1.75 +        # Restore the compiler flags and libraries
    1.76 +        CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
    1.77 +
    1.78 +        if test x$have_video_rpi = xyes; then
    1.79 +            CFLAGS="$CFLAGS $RPI_CFLAGS"
    1.80 +            SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
    1.81 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
    1.82 +            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_LDFLAGS"
    1.83 +            SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
    1.84 +
    1.85 +$as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
    1.86 +
    1.87 +            SUMMARY_video="${SUMMARY_video} rpi"
    1.88 +        fi
    1.89 +    fi
    1.90 +}
    1.91 +
    1.92  CheckX11()
    1.93  {
    1.94 -
    1.95 -
    1.96      # Check whether --enable-video-x11 was given.
    1.97  if test "${enable_video_x11+set}" = set; then :
    1.98    enableval=$enable_video_x11;
    1.99 @@ -23640,22 +23709,6 @@
   1.100  case "$host" in
   1.101      *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*|*-*-nto*)
   1.102          case "$host" in
   1.103 -            *-raspberry-linux*)
   1.104 -                # Raspberry Pi
   1.105 -                ARCH=linux
   1.106 -                RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
   1.107 -                CFLAGS="$CFLAGS $RPI_CFLAGS"
   1.108 -                SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
   1.109 -                EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
   1.110 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/opt/vc/lib -lbcm_host -ldl"
   1.111 -
   1.112 -                if test x$enable_video = xyes; then
   1.113 -                    SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
   1.114 -                    # FIXME: confdefs? Not AC_DEFINE?
   1.115 -                    $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
   1.116 -                    SUMMARY_video="${SUMMARY_video} rpi"
   1.117 -                fi
   1.118 -                ;;
   1.119              *-*-androideabi*)
   1.120                  # Android
   1.121                  ARCH=android
   1.122 @@ -23682,21 +23735,6 @@
   1.123              *-*-bsdi*)          ARCH=bsdi ;;
   1.124              *-*-freebsd*)       ARCH=freebsd ;;
   1.125              *-*-dragonfly*)     ARCH=freebsd ;;
   1.126 -            *-raspberry-netbsd*)
   1.127 -                # Raspberry Pi
   1.128 -                ARCH=netbsd
   1.129 -                RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
   1.130 -                CFLAGS="$CFLAGS $RPI_CFLAGS"
   1.131 -                SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
   1.132 -                EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
   1.133 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host -ldl"
   1.134 -
   1.135 -                if test x$enable_video = xyes; then
   1.136 -                    SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
   1.137 -                    $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
   1.138 -                    SUMMARY_video="${SUMMARY_video} raspberry"
   1.139 -                fi
   1.140 -                ;;
   1.141              *-*-netbsd*)        ARCH=netbsd ;;
   1.142              *-*-openbsd*)       ARCH=openbsd ;;
   1.143              *-*-sysv5*)         ARCH=sysv5 ;;
   1.144 @@ -23724,6 +23762,8 @@
   1.145          CheckSNDIO
   1.146          CheckFusionSound
   1.147          CheckLibSampleRate
   1.148 +        # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
   1.149 +        CheckRPI
   1.150          CheckX11
   1.151          CheckDirectFB
   1.152          CheckKMSDRM
     2.1 --- a/configure.in	Fri Sep 08 18:26:25 2017 -0700
     2.2 +++ b/configure.in	Fri Sep 08 22:21:01 2017 -0700
     2.3 @@ -1554,11 +1554,56 @@
     2.4  }
     2.5  
     2.6  
     2.7 +CheckRPI()
     2.8 +{
     2.9 +    AC_ARG_ENABLE(video-rpi,
    2.10 +AC_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=yes]]]),
    2.11 +                  , enable_video_rpi=yes)
    2.12 +    if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
    2.13 +        if test x$ARCH = xnetbsd; then
    2.14 +            RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
    2.15 +            RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
    2.16 +        else
    2.17 +            RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
    2.18 +            RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host"
    2.19 +        fi
    2.20 +
    2.21 +        # Save the original compiler flags and libraries
    2.22 +        ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
    2.23 +
    2.24 +        # Add the Raspberry Pi compiler flags and libraries
    2.25 +        CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_LDFLAGS"
    2.26 +
    2.27 +        AC_MSG_CHECKING(for Raspberry Pi)
    2.28 +        have_video_rpi=no
    2.29 +        AC_TRY_LINK([
    2.30 +          #include <bcm_host.h>
    2.31 +        ],[
    2.32 +          bcm_host_init();
    2.33 +        ],[
    2.34 +        have_video_rpi=yes
    2.35 +        ],[
    2.36 +        ])
    2.37 +        AC_MSG_RESULT($have_video_rpi)
    2.38 +
    2.39 +        # Restore the compiler flags and libraries
    2.40 +        CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
    2.41 +        
    2.42 +        if test x$have_video_rpi = xyes; then
    2.43 +            CFLAGS="$CFLAGS $RPI_CFLAGS"
    2.44 +            SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
    2.45 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
    2.46 +            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_LDFLAGS"
    2.47 +            SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
    2.48 +            AC_DEFINE(SDL_VIDEO_DRIVER_RPI, 1, [ ])
    2.49 +            SUMMARY_video="${SUMMARY_video} rpi"
    2.50 +        fi
    2.51 +    fi
    2.52 +}
    2.53 +
    2.54  dnl Find the X11 include and library directories
    2.55  CheckX11()
    2.56  {
    2.57 -
    2.58 -
    2.59      AC_ARG_ENABLE(video-x11,
    2.60  AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
    2.61                    , enable_video_x11=yes)
    2.62 @@ -3195,22 +3240,6 @@
    2.63  case "$host" in
    2.64      *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*|*-*-nto*)
    2.65          case "$host" in
    2.66 -            *-raspberry-linux*)
    2.67 -                # Raspberry Pi
    2.68 -                ARCH=linux
    2.69 -                RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
    2.70 -                CFLAGS="$CFLAGS $RPI_CFLAGS"
    2.71 -                SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
    2.72 -                EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
    2.73 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/opt/vc/lib -lbcm_host -ldl"
    2.74 -
    2.75 -                if test x$enable_video = xyes; then
    2.76 -                    SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
    2.77 -                    # FIXME: confdefs? Not AC_DEFINE?
    2.78 -                    $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
    2.79 -                    SUMMARY_video="${SUMMARY_video} rpi"
    2.80 -                fi
    2.81 -                ;;
    2.82              *-*-androideabi*)
    2.83                  # Android
    2.84                  ARCH=android
    2.85 @@ -3237,21 +3266,6 @@
    2.86              *-*-bsdi*)          ARCH=bsdi ;;
    2.87              *-*-freebsd*)       ARCH=freebsd ;;
    2.88              *-*-dragonfly*)     ARCH=freebsd ;;
    2.89 -            *-raspberry-netbsd*)
    2.90 -                # Raspberry Pi
    2.91 -                ARCH=netbsd
    2.92 -                RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
    2.93 -                CFLAGS="$CFLAGS $RPI_CFLAGS"
    2.94 -                SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
    2.95 -                EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
    2.96 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host -ldl"
    2.97 -
    2.98 -                if test x$enable_video = xyes; then
    2.99 -                    SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
   2.100 -                    $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
   2.101 -                    SUMMARY_video="${SUMMARY_video} raspberry"
   2.102 -                fi
   2.103 -                ;;
   2.104              *-*-netbsd*)        ARCH=netbsd ;;
   2.105              *-*-openbsd*)       ARCH=openbsd ;;
   2.106              *-*-sysv5*)         ARCH=sysv5 ;;
   2.107 @@ -3279,6 +3293,8 @@
   2.108          CheckSNDIO
   2.109          CheckFusionSound
   2.110          CheckLibSampleRate
   2.111 +        # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
   2.112 +        CheckRPI
   2.113          CheckX11
   2.114          CheckDirectFB
   2.115          CheckKMSDRM
     3.1 --- a/src/video/raspberry/SDL_rpivideo.h	Fri Sep 08 18:26:25 2017 -0700
     3.2 +++ b/src/video/raspberry/SDL_rpivideo.h	Fri Sep 08 22:21:01 2017 -0700
     3.3 @@ -25,7 +25,7 @@
     3.4  #include "../../SDL_internal.h"
     3.5  #include "../SDL_sysvideo.h"
     3.6  
     3.7 -#include "bcm_host.h"
     3.8 +#include <bcm_host.h>
     3.9  #include "GLES/gl.h"
    3.10  #include "EGL/egl.h"
    3.11  #include "EGL/eglext.h"