From 4498fe1a2a7c4d28e07be5a8e5088afc2bd34c2b Mon Sep 17 00:00:00 2001 From: Sheng Mao Date: Wed, 19 Aug 2020 22:36:18 -0600 Subject: [PATCH] libbtrfsutil: add pkg-config spec file Add pkg-config file for libbtrfsutil which can be used to set up compilation and link flags. The paths in pc file depend on prefix variable but ignore DESTDIR. DESTDIR is used for packaging and it should not affect the paths in pc file. Issue: #285 Signed-off-by: Sheng Mao Signed-off-by: David Sterba --- .gitignore | 2 ++ Makefile | 2 ++ Makefile.inc.in | 1 + configure.ac | 12 ++++++++++++ libbtrfsutil/libbtrfsutil.pc.in | 11 +++++++++++ 5 files changed, 28 insertions(+) create mode 100644 libbtrfsutil/libbtrfsutil.pc.in diff --git a/.gitignore b/.gitignore index 1c70ec94..08e26bb9 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ /libbtrfsutil.so* /libbtrfsutil.a +/libbtrfsutil/libbtrfsutil.pc + /fssum /testsuite-id /tests/*-tests-results.txt diff --git a/Makefile b/Makefile index c788b91b..381b630d 100644 --- a/Makefile +++ b/Makefile @@ -779,6 +779,8 @@ endif $(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 libbtrfsutil/btrfsutil.h $(DESTDIR)$(incdir) + $(INSTALL) -m755 -d $(DESTDIR)$(pkgconfigdir) + $(INSTALL) -m644 libbtrfsutil/libbtrfsutil.pc $(DESTDIR)$(pkgconfigdir) endif ifeq ($(PYTHON_BINDINGS),1) diff --git a/Makefile.inc.in b/Makefile.inc.in index f3cd2733..9f493371 100644 --- a/Makefile.inc.in +++ b/Makefile.inc.in @@ -41,6 +41,7 @@ libdir ?= @libdir@ incdir = @includedir@ udevdir = @UDEVDIR@ udevruledir = ${udevdir}/rules.d +pkgconfigdir = @pkgconfigdir@ # external libs required by various binaries; for btrfs-foo, # specify btrfs_foo_libs = ; see $($(subst...)) rules in Makefile diff --git a/configure.ac b/configure.ac index 8acbf984..7b7675aa 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,10 @@ LIBBTRFS_MAJOR=0 LIBBTRFS_MINOR=1 LIBBTRFS_PATCHLEVEL=2 +BTRFS_UTIL_VERSION_MAJOR=`sed -rn 's/^\#define BTRFS_UTIL_VERSION_MAJOR ([0-9])+$/\1/p' libbtrfsutil/btrfsutil.h` +BTRFS_UTIL_VERSION_MINOR=`sed -rn 's/^\#define BTRFS_UTIL_VERSION_MINOR ([0-9])+$/\1/p' libbtrfsutil/btrfsutil.h` +BTRFS_UTIL_VERSION_PATCH=`sed -rn 's/^\#define BTRFS_UTIL_VERSION_PATCH ([0-9])+$/\1/p' libbtrfsutil/btrfsutil.h` + CFLAGS=${CFLAGS:-"-g -O1 -Wall -D_FORTIFY_SOURCE=2"} AC_SUBST([CFLAGS]) @@ -300,18 +304,25 @@ AC_SUBST([LZO2_LIBS]) AC_SUBST([LZO2_LIBS_STATIC]) AC_SUBST([LZO2_CFLAGS]) +dnl call PKG_INSTALLDIR from pkg.m4 to set pkgconfigdir +m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_MSG_ERROR([please install pkgconf])]) dnl library stuff AC_SUBST([LIBBTRFS_MAJOR]) AC_SUBST([LIBBTRFS_MINOR]) AC_SUBST([LIBBTRFS_PATCHLEVEL]) +AC_SUBST([BTRFS_UTIL_VERSION_MAJOR]) +AC_SUBST([BTRFS_UTIL_VERSION_MINOR]) +AC_SUBST([BTRFS_UTIL_VERSION_PATCH]) + AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([ Makefile.inc Documentation/Makefile version.h +libbtrfsutil/libbtrfsutil.pc ]) AC_OUTPUT @@ -327,6 +338,7 @@ AC_MSG_RESULT([ bindir: ${bindir} libdir: ${libdir} includedir: ${includedir} + pkgconfigdir: ${pkgconfigdir} compiler: ${CC} cflags: ${CFLAGS} diff --git a/libbtrfsutil/libbtrfsutil.pc.in b/libbtrfsutil/libbtrfsutil.pc.in new file mode 100644 index 00000000..81e66622 --- /dev/null +++ b/libbtrfsutil/libbtrfsutil.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libbtrfsutil +Description: libbtrfsutil library +Version: @BTRFS_UTIL_VERSION_MAJOR@.@BTRFS_UTIL_VERSION_MINOR@.@BTRFS_UTIL_VERSION_PATCH@ +URL: http://btrfs.wiki.kernel.org +Cflags: -I${includedir} +Libs: -L${libdir} -lbtrfsutil