From c150e7773764d100a21eb5ee4c586fe1edf4673b Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 28 Nov 2020 22:10:00 +0100
Subject: [PATCH] build: Add a pkg-config file

The .pc are a better replacement for library detection and linking
usage, than libtool .la files or hardcoding the flags in the using
code.
---
 configure.ac       |    1 +
 lib/Makefile.am    |    5 +++++
 lib/libsysfs.pc.in |   11 +++++++++++
 3 files changed, 17 insertions(+)
 create mode 100644 lib/libsysfs.pc.in

--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,7 @@ AC_CHECK_FUNCS([bzero isascii memset str
 
 AC_CONFIG_FILES([Makefile
                  lib/Makefile
+                 lib/libsysfs.pc
                  cmd/Makefile
                  test/Makefile])
 AC_OUTPUT
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,3 +1,8 @@
+EXTRA_DIST = libsysfs.pc.in
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libsysfs.pc
+
 lib_LTLIBRARIES = libsysfs.la
 libsysfs_la_SOURCES = sysfs_utils.c sysfs_attr.c sysfs_class.c dlist.c \
       sysfs_device.c sysfs_driver.c sysfs_bus.c sysfs_module.c sysfs.h
--- /dev/null
+++ b/lib/libsysfs.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libsysfs
+Description: interface to Linux sysfs
+Version: @VERSION@
+URL: https://github.com/linux-ras/sysfsutils
+Libs: -L${libdir} -lsysfs
+Cflags: -I${includedir}