Set rpath instead of changing environment for RPi
author"Guillermo A. Amaral" <g@maral.me>
Wed, 07 Feb 2018 14:12:26 -0800
changeset 118518f295e7acefd
parent 11850 8d97fd557ba1
child 11852 c3fc99758ad2
Set rpath instead of changing environment for RPi
Credit goes to Adrian Perez de Castro for the improvement.

Signed-off-by: Guillermo A. Amaral <g@maral.me>
cmake/sdlchecks.cmake
configure
configure.in
src/video/SDL_egl.c
     1.1 --- a/cmake/sdlchecks.cmake	Wed Feb 07 14:07:54 2018 -0800
     1.2 +++ b/cmake/sdlchecks.cmake	Wed Feb 07 14:12:26 2018 -0800
     1.3 @@ -1132,6 +1132,7 @@
     1.4        set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
     1.5        set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
     1.6        set(VIDEO_RPI_LIBRARIES bcm_host )
     1.7 +      set(VIDEO_RPI_LDFLAGS "-Wl,-rpath,/opt/vc/lib")
     1.8      endif()
     1.9      listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
    1.10      listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
    1.11 @@ -1152,6 +1153,7 @@
    1.12        set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_RPI_SOURCES})
    1.13        list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBRARIES})
    1.14        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
    1.15 +      list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS})
    1.16      endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
    1.17    endif(VIDEO_RPI)
    1.18  endmacro(CheckRPI)
     2.1 --- a/configure	Wed Feb 07 14:07:54 2018 -0800
     2.2 +++ b/configure	Wed Feb 07 14:12:26 2018 -0800
     2.3 @@ -19551,7 +19551,7 @@
     2.4              RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
     2.5          else
     2.6              RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
     2.7 -            RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host"
     2.8 +            RPI_LDFLAGS="-Wl,-rpath,/opt/vc/lib -L/opt/vc/lib -lbcm_host"
     2.9          fi
    2.10  
    2.11          # Save the original compiler flags and libraries
     3.1 --- a/configure.in	Wed Feb 07 14:07:54 2018 -0800
     3.2 +++ b/configure.in	Wed Feb 07 14:12:26 2018 -0800
     3.3 @@ -1580,7 +1580,7 @@
     3.4              RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
     3.5          else
     3.6              RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
     3.7 -            RPI_LDFLAGS="-L/opt/vc/lib -lbcm_host"
     3.8 +            RPI_LDFLAGS="-Wl,-rpath,/opt/vc/lib -L/opt/vc/lib -lbcm_host"
     3.9          fi
    3.10  
    3.11          # Save the original compiler flags and libraries
     4.1 --- a/src/video/SDL_egl.c	Wed Feb 07 14:07:54 2018 -0800
     4.2 +++ b/src/video/SDL_egl.c	Wed Feb 07 14:12:26 2018 -0800
     4.3 @@ -44,7 +44,6 @@
     4.4  
     4.5  #if SDL_VIDEO_DRIVER_RPI
     4.6  /* Raspbian places the OpenGL ES/EGL binaries in a non standard path */
     4.7 -static const char g_rpi_opt_path[] = "/opt/vc/lib";
     4.8  #define DEFAULT_EGL ( vc4 ? "libEGL.so.1" : "libbrcmEGL.so" )
     4.9  #define DEFAULT_OGL_ES2 ( vc4 ? "libGLESv2.so.2" : "libbrcmGLESv2.so" )
    4.10  #define ALT_EGL "libEGL.so"
    4.11 @@ -266,20 +265,6 @@
    4.12  #endif
    4.13  #if SDL_VIDEO_DRIVER_RPI
    4.14      SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK));
    4.15 -
    4.16 -    path = SDL_getenv("LD_LIBRARY_PATH");
    4.17 -    if (path) {
    4.18 -        const int path_size = SDL_strlen(path) + 1 + sizeof(g_rpi_opt_path);
    4.19 -        char *new_path = SDL_calloc(1, path_size);
    4.20 -        strcat(new_path, path);
    4.21 -        strcat(new_path, ":");
    4.22 -        strcat(new_path, g_rpi_opt_path);
    4.23 -        SDL_setenv("LD_LIBRARY_PATH", new_path, 1);
    4.24 -        SDL_free(new_path);
    4.25 -    } else {
    4.26 -        SDL_setenv("LD_LIBRARY_PATH", g_rpi_opt_path, 1);
    4.27 -    }
    4.28 -    path = NULL;
    4.29  #endif
    4.30  
    4.31      if (_this->egl_data) {