Subject: [PATCH v2] community/glew: fix libdir in glew.pc

From: Sebastian <[email-masked]>
Date: Thu, 27 Jan 2022 22:59:03 -0500

By default, glew sets the libdir in the pkg-config file to the LIBDIR
that it is installed to. We don't want that here, so this commit patches
the pkg-config file to always use the system's libdir (/usr/lib).

Signed-off-by: Sebastian <[email-masked]>
---
 community/glew/APKBUILD   | 16 ++++++++--------
 community/glew/glew.patch | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 8 deletions(-)
 create mode 100644 community/glew/glew.patch

diff --git a/community/glew/APKBUILD b/community/glew/APKBUILD
index 4b3fb46f..ccf75f81 100644
--- a/community/glew/APKBUILD
+++ b/community/glew/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=glew
 pkgver=2.2.0
-pkgrel=0
+pkgrel=1
 pkgdesc="A cross-platform C/C++ extension loading library"
 url="http://glew.sourceforge.net"
 arch="all"
@@ -11,14 +11,11 @@ options="!check"  # No test suite.
 depends_dev="libxmu-dev libxi-dev mesa-dev glu-dev"
 makedepends="$depends_dev"
 subpackages="$pkgname-dev"
-source="https://downloads.sourceforge.net/glew/glew-$pkgver.tgz"
+source="https://downloads.sourceforge.net/glew/glew-$pkgver.tgz
+	glew.patch
+	"
 replaces="mesa-dev"
 
-prepare() {
-	default_prepare
-	sed -i 's|lib64|lib|' config/Makefile.linux
-}
-
 build() {
 	make CFLAGS.EXTRA="$CFLAGS -fPIC"
 }
@@ -27,4 +24,7 @@ package() {
 	make GLEW_DEST="$pkgdir/usr" install
 }
 
-sha512sums="57453646635609d54f62fb32a080b82b601fd471fcfd26e109f479b3fef6dfbc24b83f4ba62916d07d62cd06d1409ad7aa19bc1cd7cf3639c103c815b8be31d1  glew-2.2.0.tgz"
+sha512sums="
+57453646635609d54f62fb32a080b82b601fd471fcfd26e109f479b3fef6dfbc24b83f4ba62916d07d62cd06d1409ad7aa19bc1cd7cf3639c103c815b8be31d1  glew-2.2.0.tgz
+ceee2d21ce0f4f6cd4b8d9e524440a30c31cd2aa4fa206f2a8081c49d10db5779979bfb15087218d6f290faed9a4ed01e3d26c6a88768fe3ed66f8b171ae2b34  glew.patch
+"
diff --git a/community/glew/glew.patch b/community/glew/glew.patch
new file mode 100644
index 00000000..61c4447b
--- /dev/null
+++ b/community/glew/glew.patch
@@ -0,0 +1,34 @@
+Fixes pkg-config file to have correct system libdir.
+
+diff -aur glew-2.2.0/Makefile glew-2.2.0-alpine/Makefile
+--- glew-2.2.0/Makefile	2020-03-15 11:53:59.000000000 +0000
++++ glew-2.2.0-alpine/Makefile	2022-01-28 02:42:23.773580331 +0000
+@@ -144,7 +144,7 @@
+ glew.pc: glew.pc.in
+ 	sed \
+ 		-e "s|@prefix@|$(GLEW_PREFIX)|g" \
+-		-e "s|@libdir@|$(LIBDIR)|g" \
++		-e "s|@libdir@|/usr/lib|g" \
+ 		-e "s|@exec_prefix@|$(BINDIR)|g" \
+ 		-e "s|@includedir@|$(INCDIR)|g" \
+ 		-e "s|@version@|$(GLEW_VERSION)|g" \
+
+diff -aur glew-2.2.0/config/Makefile.linux glew-2.2.0-alpine/config/Makefile.linux
+--- glew-2.2.0/config/Makefile.linux	2020-03-15 11:53:59.000000000 +0000
++++ glew-2.2.0-alpine/config/Makefile.linux	2022-01-28 02:43:26.813582486 +0000
+@@ -12,13 +12,8 @@
+ ifeq (e2k,${M_ARCH})
+   ARCH64 = true
+ endif
+-ifeq (${ARCH64},true)
+-  LDFLAGS.EXTRA = -L/usr/X11R6/lib64 -L/usr/lib64
+-  LIBDIR = $(GLEW_DEST)/lib64
+-else
+-  LDFLAGS.EXTRA = -L/usr/X11R6/lib -L/usr/lib
+-  LIBDIR = $(GLEW_DEST)/lib
+-endif
++LDFLAGS.EXTRA = -L/usr/X11R6/lib -L/usr/lib
++LIBDIR = $(GLEW_DEST)/lib
+ LDFLAGS.GL = -lGL -lX11
+ LDFLAGS.STATIC = -Wl,-Bstatic
+ LDFLAGS.DYNAMIC = -Wl,-Bdynamic
-- 
2.34.1