diff --git a/Makefile b/Makefile
index 2f248c1..ec72779 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,8 @@ else ifneq (,$(findstring rpi,$(platform)))
    else
       LLE = 0
       CPUFLAGS += -DVC
-      GL_LIB := -L/opt/vc/lib -lGLESv2
+      GL_LIB := -L/opt/vc/lib -lbrcmGLESv2
+      EGL_LIB := -lbrcmEGL
       INCFLAGS += -I/opt/vc/include -I/opt/vc/include/interface/vcos -I/opt/vc/include/interface/vcos/pthreads
    endif
    WITH_DYNAREC=arm
diff --git a/Makefile.common b/Makefile.common
index 4d36cba..4ae4325 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -301,9 +301,11 @@ else
 	SOURCES_CXX   += $(VIDEODIR_GLIDEN64)/src/3DMath.cpp
 endif
 
+EGL_LIB ?= -lEGL
+
 ifeq ($(GLES),1)
 	GLFLAGS += -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLES2 -DUSE_DEPTH_RENDERBUFFER
-	LDFLAGS += -lEGL
+	LDFLAGS += $(EGL_LIB)
 	SOURCES_C += $(LIBRETRO_COMM_DIR)/glsym/glsym_es2.c
 	SOURCES_CXX += $(VIDEODIR_GLIDEN64)/src/GLES2/GLSLCombiner_gles2.cpp
 	ifneq (,$(findstring android,$(platform)))
@@ -312,7 +314,7 @@ ifeq ($(GLES),1)
 
 else ifeq ($(GLES3),1)
 	GLFLAGS += -DHAVE_OPENGLES -DHAVE_OPENGLES3 -DGLES3
-	LDFLAGS += -lEGL
+	LDFLAGS += $(EGL_LIB)
 	SOURCES_C += $(LIBRETRO_COMM_DIR)/glsym/glsym_es3.c
 	SOURCES_CXX +=  $(VIDEODIR_GLIDEN64)/src/OGL3X/GLSLCombiner_ogl3x.cpp \
 		$(VIDEODIR_GLIDEN64)/src/BufferCopy/ColorBufferToRDRAM_GL.cpp
diff --git a/mupen64plus-core/projects/unix/Makefile b/mupen64plus-core/projects/unix/Makefile
index 4a80335..a58fdeb 100755
--- a/mupen64plus-core/projects/unix/Makefile
+++ b/mupen64plus-core/projects/unix/Makefile
@@ -264,15 +264,16 @@ CFLAGS += $(SDL_CFLAGS)
 LDLIBS += $(SDL_LDLIBS)
 
 ifeq ($(VC), 1)
-  CFLAGS += -DUSE_GLES -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/vmcs_host/linux
-  LDLIBS += -L/opt/vc/lib -lGLESv2 -lEGL -lbcm_host -lvcos -lvchiq_arm
-  # OSD uses non-ES code and breaks attribs of video plugins
-  OSD=0
+  CFLAGS += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/vmcs_host/linux
+  LDLIBS += -L/opt/vc/lib -lbrcmEGL -lbcm_host -lvcos -lvchiq_arm
+  GLES_LIB := -lbrcmGLESv2
+  USE_GLES := 1
 endif
 
 ifeq ($(USE_GLES), 1)
+  GLES_LIB ?= -lGLESv2
   CFLAGS += -DUSE_GLES
-  LDLIBS += -lGLESv2
+  LDLIBS += $(GLES_LIB)
   # OSD uses non-ES code and breaks attribs of video plugins
   OSD=0
 endif
