Skip to content

Commit

Permalink
components/glew: updated glew build
Browse files Browse the repository at this point in the history
  • Loading branch information
itsManjeet committed Jun 8, 2024
1 parent c32ca24 commit e892299
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 20 deletions.
29 changes: 23 additions & 6 deletions elements/components/glew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@ version: 2.2.0
about: OpenGL extension wrangler library

script: |-
# patch -Np1 -i /files/glew/glew-install.patch
patch -Np1 -i glew-install.patch
patch -Np1 -i egl+glx.patch
sed -i 's|lib64|lib|' config/Makefile.linux
sed -i '/^.PHONY: .*\.pc$/d' Makefile
make STRIP= \
LIBDIR=/usr/lib
make install.all DESTDIR=%{install-root} \
LIBDIR=/usr/lib
mv bin/glewinfo bin/glxewinfo
rm glew.pc
make STRIP= SYSTEM=linux-egl glew.lib.shared bin/glewinfo
mv bin/glewinfo bin/eglewinfo
make GLEW_DEST=%{install-root}/%{prefix} \
STRIP= \
SYSTEM=linux-egl install
install -D -m755 -t %{install-root}/%{bindir} \
bin/eglewinfo bin/glxewinfo bin/visualinfo
ln -s eglewinfo %{install-root}%{bindir}/glewinfo
depends:
- components/glu.yml
- components/x11/libxi.yml
- components/x11/libxmu.yml
- components/libglvnd.yml
- components/x11/libx11.yml
sources:
- https://downloads.sourceforge.net/glew/glew-%{version}.tgz

- patches/glew/egl+glx.patch
- patches/glew/glew-install.patch
# TODO: fix patch
6 changes: 4 additions & 2 deletions elements/components/htop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: htop
version: 3.2.2
version: 3.3.0
about: Interactive process viewer

pre-script: |-
Expand All @@ -17,6 +17,8 @@ build-depends:
- components/libnl.yml
- components/ncurses.yml
- components/lm-sensors.yml
- components/appimagetool.yml
- components/lsof.yml
- components/strace.yml

sources:
- https://github.com/htop-dev/htop/releases/download/%{version}/htop-%{version}.tar.xz
24 changes: 14 additions & 10 deletions elements/components/lsof.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
id: lsof
version: 4.98.0
version: 4.99.3
about: Lists open files for running unix processes

pre-script: |-
autoreconf -fiv
build-type: autotools
configure: >-
--enable-security
--enable-no-sock-security
--with-libtirpc
depends:
- components/glibc.yml
- components/libtirpc.yml

build-depends:
- components/groff.yml

sources:
- https://github.com/lsof-org/lsof/archive/%{version}/%{id}-%{version}.tar.gz
pre-script: |-
sed -i 's|/\* #define\tHASSECURITY\t1 \*/|#define\tHASSECURITY\t1|' dialects/linux/machine.h
sed -i "s|.so ./version|.ds VN %{version}|" -i Lsof.8
script: |-
./Configure -n linux
make CC="cc ${CFLAGS}"
install -D -m 0755 lsof -t %{install-root}/%{bindir}
install -D -m 0644 Lsof.8 %{install-root}%{datadir}/man/man8/lsof.8
3 changes: 1 addition & 2 deletions elements/components/strace.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
id: strace
version: 6.7
version: 6.9
about: A diagnostic, debugging and instructional userspace tracer

configure: >-
--enable-mpers=no
--with-libunwind
sources:
Expand Down
2 changes: 2 additions & 0 deletions elements/system/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ depends:
- components/dracut.yml
- components/glfw.yml
- components/glew.yml
- components/htop.yml
- components/zsync.yml

- components/firmware.yml
- components/sof-firmware.yml
Expand Down
168 changes: 168 additions & 0 deletions patches/glew/egl+glx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
--- a/src/glew.c
+++ b/src/glew.c
@@ -36,11 +36,13 @@
# include GLEW_INCLUDE
#endif

+#if defined(GLEW_EGL)
+# include <GL/eglew.h>
+#endif
+
#if defined(GLEW_OSMESA)
# define GLAPI extern
# include <GL/osmesa.h>
-#elif defined(GLEW_EGL)
-# include <GL/eglew.h>
#elif defined(_WIN32)
/*
* If NOGDI is defined, wingdi.h won't be included by windows.h, and thus
@@ -57,8 +59,7 @@

#include <stddef.h> /* For size_t */

-#if defined(GLEW_EGL)
-#elif defined(GLEW_REGAL)
+#if defined(GLEW_REGAL)

/* In GLEW_REGAL mode we call direcly into the linked
libRegal.so glGetProcAddressREGAL for looking up
@@ -159,23 +160,37 @@
* Define glewGetProcAddress.
*/
#if defined(GLEW_REGAL)
-# define glewGetProcAddress(name) regalGetProcAddress((const GLchar *)name)
+# define _glewGetProcAddress(name) regalGetProcAddress((const GLchar *)name)
#elif defined(GLEW_OSMESA)
-# define glewGetProcAddress(name) OSMesaGetProcAddress((const char *)name)
-#elif defined(GLEW_EGL)
-# define glewGetProcAddress(name) eglGetProcAddress((const char *)name)
+# define _glewGetProcAddress(name) OSMesaGetProcAddress((const char *)name)
#elif defined(_WIN32)
-# define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name)
+# define _glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name)
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
-# define glewGetProcAddress(name) NSGLGetProcAddress(name)
+# define _glewGetProcAddress(name) NSGLGetProcAddress(name)
#elif defined(__sgi) || defined(__sun) || defined(__HAIKU__)
-# define glewGetProcAddress(name) dlGetProcAddress(name)
+# define _glewGetProcAddress(name) dlGetProcAddress(name)
#elif defined(__ANDROID__)
-# define glewGetProcAddress(name) NULL /* TODO */
+# define _glewGetProcAddress(name) NULL /* TODO */
#elif defined(__native_client__)
-# define glewGetProcAddress(name) NULL /* TODO */
+# define _glewGetProcAddress(name) NULL /* TODO */
#else /* __linux */
-# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name)
+# define _glewGetProcAddress(name) (*glXGetProcAddressARB)(name)
+#endif
+
+#if defined(GLEW_EGL)
+static GLboolean _EGL_available = GL_FALSE;
+static void (*glewGetProcAddress (const GLubyte *name)) (void)
+{
+ void (*addr)(void);
+ if (_EGL_available)
+ {
+ addr = eglGetProcAddress((const char *)name);
+ if (addr) return addr;
+ }
+ return _glewGetProcAddress(name);
+}
+#else
+# define glewGetProcAddress(name) _glewGetProcAddress(name)
#endif

/*
@@ -19297,9 +19312,7 @@
}


-#if defined(GLEW_OSMESA)
-
-#elif defined(GLEW_EGL)
+#if defined(GLEW_EGL)

PFNEGLCHOOSECONFIGPROC __eglewChooseConfig = NULL;
PFNEGLCOPYBUFFERSPROC __eglewCopyBuffers = NULL;
@@ -20490,8 +20503,8 @@
PFNEGLQUERYSTRINGPROC queryString = NULL;

/* Load necessary entry points */
- initialize = (PFNEGLINITIALIZEPROC) glewGetProcAddress("eglInitialize");
- queryString = (PFNEGLQUERYSTRINGPROC) glewGetProcAddress("eglQueryString");
+ initialize = (PFNEGLINITIALIZEPROC) eglGetProcAddress("eglInitialize");
+ queryString = (PFNEGLQUERYSTRINGPROC) eglGetProcAddress("eglQueryString");
if (!initialize || !queryString)
return 1;

@@ -21029,7 +21042,9 @@
return GLEW_OK;
}

-#elif defined(_WIN32)
+#endif
+
+#if defined(_WIN32)

PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL;

@@ -23105,13 +23120,26 @@
GLenum r;
#if defined(GLEW_EGL)
PFNEGLGETCURRENTDISPLAYPROC getCurrentDisplay = NULL;
+ EGLDisplay display;
#endif
r = glewContextInit();
if ( r != 0 ) return r;
#if defined(GLEW_EGL)
- getCurrentDisplay = (PFNEGLGETCURRENTDISPLAYPROC) glewGetProcAddress("eglGetCurrentDisplay");
- return eglewInit(getCurrentDisplay());
-#elif defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
+ getCurrentDisplay = (PFNEGLGETCURRENTDISPLAYPROC) eglGetProcAddress("eglGetCurrentDisplay");
+ if (getCurrentDisplay)
+ display = getCurrentDisplay();
+ else
+ display = EGL_NO_DISPLAY;
+ if (display != EGL_NO_DISPLAY)
+ {
+ r = eglewInit(display);
+ if ( r == 0 ) {
+ _EGL_available = GL_TRUE;
+ return r;
+ }
+ }
+#endif
+#if defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
return r;
#elif defined(_WIN32)
return wglewInit();
@@ -29785,7 +29813,7 @@
return ret;
}

-#if defined(_WIN32) && !defined(GLEW_EGL) && !defined(GLEW_OSMESA)
+#if defined(_WIN32) && !defined(GLEW_OSMESA)

GLboolean GLEWAPIENTRY wglewIsSupported (const char* name)
{
@@ -30228,7 +30256,7 @@
return ret;
}

-#elif !defined(GLEW_OSMESA) && !defined(GLEW_EGL) && !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
+#elif !defined(GLEW_OSMESA) && !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)

GLboolean glxewIsSupported (const char* name)
{
@@ -30805,7 +30833,9 @@
return ret;
}

-#elif defined(GLEW_EGL)
+#endif
+
+#if defined(GLEW_EGL)

GLboolean eglewIsSupported (const char* name)
{
73 changes: 73 additions & 0 deletions patches/glew/glew-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
--- glew-2.2.0/Makefile 2020-03-15 12:53:59.000000000 +0100
+++ glew-2.2.0/Makefile 2020-04-17 11:51:25.568482195 +0200
@@ -120,7 +120,7 @@
endif

$(LIB.SHARED.DIR)/$(LIB.SHARED): $(LIB.SOBJS)
- $(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
+ $(LD) $(LDFLAGS.SO) $(LDFLAGS) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
ifneq ($(LN),)
$(LN) $(LIB.SHARED) $(LIB.SHARED.DIR)/$(LIB.SONAME)
$(LN) $(LIB.SHARED) $(LIB.SHARED.DIR)/$(LIB.DEVLNK)
@@ -131,11 +131,11 @@

tmp/$(SYSTEM)/default/static/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
@mkdir -p $(dir $@)
- $(CC) -DGLEW_NO_GLU -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+ $(CC) -DGLEW_NO_GLU -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) $(LDFLAGS) -o $@ -c $<

tmp/$(SYSTEM)/default/shared/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
@mkdir -p $(dir $@)
- $(CC) -DGLEW_NO_GLU -DGLEW_BUILD $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+ $(CC) -DGLEW_NO_GLU -DGLEW_BUILD $(CFLAGS) $(CFLAGS.SO) $(LDFLAGS) -o $@ -c $<

# Force re-write of glew.pc, GLEW_DEST can vary

@@ -180,13 +180,13 @@
mkdir bin

bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.OBJ) $(LIB.SHARED.DIR)/$(LIB.SHARED)
- $(CC) $(CFLAGS) -o $@ $(GLEWINFO.BIN.OBJ) $(BIN.LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(GLEWINFO.BIN.OBJ) $(BIN.LIBS)
ifneq ($(STRIP),)
$(STRIP) -x $@
endif

bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.OBJ) $(LIB.SHARED.DIR)/$(LIB.SHARED)
- $(CC) $(CFLAGS) -o $@ $(VISUALINFO.BIN.OBJ) $(BIN.LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(VISUALINFO.BIN.OBJ) $(BIN.LIBS)
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
@@ -193,11 +193,11 @@

$(GLEWINFO.BIN.OBJ): $(GLEWINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
@mkdir -p $(dir $@)
- $(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+ $(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) $(LDFLAGS) -o $@ -c $<

$(VISUALINFO.BIN.OBJ): $(VISUALINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
@mkdir -p $(dir $@)
- $(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
+ $(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) $(LDFLAGS) -o $@ -c $<

# Install targets

--- glew-2.1.0/Makefile.install 2018-08-15 13:51:45.220637107 +0200
+++ glew-2.1.0/Makefile 2018-08-15 13:52:02.168740876 +0200
@@ -231,6 +231,7 @@ install.bin: glew.bin

install.include:
$(INSTALL) -d -m 0755 "$(DESTDIR)$(INCDIR)"
+ $(INSTALL) -m 0644 include/GL/eglew.h "$(DESTDIR)$(INCDIR)/"
$(INSTALL) -m 0644 include/GL/wglew.h "$(DESTDIR)$(INCDIR)/"
$(INSTALL) -m 0644 include/GL/glew.h "$(DESTDIR)$(INCDIR)/"
$(INSTALL) -m 0644 include/GL/glxew.h "$(DESTDIR)$(INCDIR)/"
@@ -241,6 +242,7 @@ install.pkgconfig: glew.pc
$(INSTALL) -m 0644 glew.pc "$(DESTDIR)$(PKGDIR)/"

uninstall:
+ $(RM) "$(DESTDIR)$(INCDIR)/eglew.h"
$(RM) "$(DESTDIR)$(INCDIR)/wglew.h"
$(RM) "$(DESTDIR)$(INCDIR)/glew.h"
$(RM) "$(DESTDIR)$(INCDIR)/glxew.h"

0 comments on commit e892299

Please sign in to comment.