From 0dfaea2bcb7cdcc785f95e244223bd004a2d7fba Mon Sep 17 00:00:00 2001
From: Kyle Brenneman <kbrenneman@nvidia.com>
Date: Tue, 3 Sep 2019 08:13:34 -0600
Subject: [PATCH] Add pkg-config files for EGL, GL, GLES, and GLX.

This preserves the names from Mesa's gl, glesv1_cm, glesv2, and egl pkgconfig
data, and for compatibility with that, gl.pc gives you libGL.

Also added glx.pc and opengl.pc for libglvnd's libGLX and libOpenGL libraries.
If newer applications want to explicitly depend on libGLX and the appropriate
rendering API they can ask for the new pkgconfig names.

Note that the version numbers in each file are the API versions that each
library exposes, not the libglvnd package version.
---
 configure.ac               |  6 ++++++
 src/EGL/Makefile.am        |  3 +++
 src/EGL/egl.pc.in          | 10 ++++++++++
 src/GL/Makefile.am         |  3 +++
 src/GL/gl.pc.in            | 10 ++++++++++
 src/GLESv1/Makefile.am     |  2 ++
 src/GLESv1/glesv1_cm.pc.in | 10 ++++++++++
 src/GLESv2/Makefile.am     |  2 ++
 src/GLESv2/glesv2.pc.in    | 10 ++++++++++
 src/GLX/Makefile.am        |  2 ++
 src/GLX/glx.pc.in          | 10 ++++++++++
 src/OpenGL/Makefile.am     |  2 ++
 src/OpenGL/opengl.pc.in    | 10 ++++++++++
 13 files changed, 80 insertions(+)
 create mode 100644 src/EGL/egl.pc.in
 create mode 100644 src/GL/gl.pc.in
 create mode 100644 src/GLESv1/glesv1_cm.pc.in
 create mode 100644 src/GLESv2/glesv2.pc.in
 create mode 100644 src/GLX/glx.pc.in
 create mode 100644 src/OpenGL/opengl.pc.in

diff --git a/configure.ac b/configure.ac
index cdbb138..7feec30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -324,11 +324,17 @@ AC_CONFIG_FILES([Makefile
                  include/Makefile
                  src/Makefile
                  src/GL/Makefile
+                 src/GL/gl.pc
+                 src/OpenGL/opengl.pc
                  src/OpenGL/Makefile
+                 src/GLESv1/glesv1_cm.pc
                  src/GLESv1/Makefile
+                 src/GLESv2/glesv2.pc
                  src/GLESv2/Makefile
+                 src/GLX/glx.pc
                  src/GLX/Makefile
                  src/EGL/Makefile
+                 src/EGL/egl.pc
                  src/GLdispatch/Makefile
                  src/GLdispatch/vnd-glapi/Makefile
                  src/util/Makefile
diff --git a/src/EGL/Makefile.am b/src/EGL/Makefile.am
index 5c036dc..c55c83e 100644
--- a/src/EGL/Makefile.am
+++ b/src/EGL/Makefile.am
@@ -106,3 +106,6 @@ g_egldispatchstubs.c : $(GENERATE_DEPS)
 g_egldispatchstubs.h : $(GENERATE_DEPS)
 	$(AM_V_GEN)$(PYTHON) $(GENERATE_DISPATCH_SCRIPT) header $(GENERATE_LIST_FILES) > $@
 endif
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = egl.pc
diff --git a/src/EGL/egl.pc.in b/src/EGL/egl.pc.in
new file mode 100644
index 0000000..ffae9e2
--- /dev/null
+++ b/src/EGL/egl.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: egl
+Description: EGL library and headers
+Version: 1.5
+Libs: -L${libdir} -lEGL
+Cflags: -I${includedir}
diff --git a/src/GL/Makefile.am b/src/GL/Makefile.am
index ecdcbd0..225fdcb 100644
--- a/src/GL/Makefile.am
+++ b/src/GL/Makefile.am
@@ -70,3 +70,6 @@ libGL_la_LIBADD += ../GLdispatch/libGLdispatch.la
 libGL_la_LIBADD += ../GLdispatch/vnd-glapi/libglapi_gl.la
 libGL_la_LIBADD += ../util/libutils_misc.la
 libGL_la_LIBADD += @LIB_DL@
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gl.pc
diff --git a/src/GL/gl.pc.in b/src/GL/gl.pc.in
new file mode 100644
index 0000000..0eaa149
--- /dev/null
+++ b/src/GL/gl.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: gl
+Description: Legacy OpenGL and GLX library and headers
+Version: 1.2
+Libs: -L${libdir} -lGL
+Cflags: -I${includedir}
diff --git a/src/GLESv1/Makefile.am b/src/GLESv1/Makefile.am
index d20017d..88e07bc 100644
--- a/src/GLESv1/Makefile.am
+++ b/src/GLESv1/Makefile.am
@@ -38,3 +38,5 @@ libGLESv1_CM_la_LIBADD = \
 	../GLdispatch/vnd-glapi/libglapi_glesv1.la \
 	../util/libutils_misc.la
 
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = glesv1_cm.pc
diff --git a/src/GLESv1/glesv1_cm.pc.in b/src/GLESv1/glesv1_cm.pc.in
new file mode 100644
index 0000000..daa247f
--- /dev/null
+++ b/src/GLESv1/glesv1_cm.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: glesv1_cm
+Description: OpenGL ES-CM v1 library and headers
+Version: 1.0
+Libs: -L${libdir} -lGLESv1_CM
+Cflags: -I${includedir}
diff --git a/src/GLESv2/Makefile.am b/src/GLESv2/Makefile.am
index a9c2351..f40e06f 100644
--- a/src/GLESv2/Makefile.am
+++ b/src/GLESv2/Makefile.am
@@ -38,3 +38,5 @@ libGLESv2_la_LIBADD = \
 	../GLdispatch/vnd-glapi/libglapi_glesv2.la \
 	../util/libutils_misc.la
 
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = glesv2.pc
diff --git a/src/GLESv2/glesv2.pc.in b/src/GLESv2/glesv2.pc.in
new file mode 100644
index 0000000..a9fe839
--- /dev/null
+++ b/src/GLESv2/glesv2.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: gles2
+Description: OpenGL ES v2/v3 library and headers
+Version: 3.2
+Libs: -L${libdir} -lGLESv2
+Cflags: -I${includedir}
diff --git a/src/GLX/Makefile.am b/src/GLX/Makefile.am
index 030836b..0d19674 100644
--- a/src/GLX/Makefile.am
+++ b/src/GLX/Makefile.am
@@ -69,3 +69,5 @@ libGLX_la_SOURCES = \
 	libglxmapping.c \
 	libglxproto.c
 
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = glx.pc
diff --git a/src/GLX/glx.pc.in b/src/GLX/glx.pc.in
new file mode 100644
index 0000000..1561181
--- /dev/null
+++ b/src/GLX/glx.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: glx
+Description: GLX library and headers
+Version: 1.4
+Libs: -L${libdir} -lGLX
+Cflags: -I${includedir}
diff --git a/src/OpenGL/Makefile.am b/src/OpenGL/Makefile.am
index 647d9e4..4b34dd5 100644
--- a/src/OpenGL/Makefile.am
+++ b/src/OpenGL/Makefile.am
@@ -47,3 +47,5 @@ libOpenGL_la_LIBADD = \
 	../GLdispatch/vnd-glapi/libglapi_opengl.la \
 	../util/libutils_misc.la
 
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = opengl.pc
diff --git a/src/OpenGL/opengl.pc.in b/src/OpenGL/opengl.pc.in
new file mode 100644
index 0000000..d560c06
--- /dev/null
+++ b/src/OpenGL/opengl.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: opengl
+Description: OpenGL (without GLX) headers and interface
+Version: 4.5
+Libs: -L${libdir} -lOpenGL
+Cflags: -I${includedir}
-- 
2.21.0

