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 <shngmao@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Sheng Mao 2020-08-19 22:36:18 -06:00 committed by David Sterba
parent f43df8a863
commit 4498fe1a2a
5 changed files with 28 additions and 0 deletions

2
.gitignore vendored
View File

@ -35,6 +35,8 @@
/libbtrfsutil.so* /libbtrfsutil.so*
/libbtrfsutil.a /libbtrfsutil.a
/libbtrfsutil/libbtrfsutil.pc
/fssum /fssum
/testsuite-id /testsuite-id
/tests/*-tests-results.txt /tests/*-tests-results.txt

View File

@ -779,6 +779,8 @@ endif
$(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs
$(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs
$(INSTALL) -m644 libbtrfsutil/btrfsutil.h $(DESTDIR)$(incdir) $(INSTALL) -m644 libbtrfsutil/btrfsutil.h $(DESTDIR)$(incdir)
$(INSTALL) -m755 -d $(DESTDIR)$(pkgconfigdir)
$(INSTALL) -m644 libbtrfsutil/libbtrfsutil.pc $(DESTDIR)$(pkgconfigdir)
endif endif
ifeq ($(PYTHON_BINDINGS),1) ifeq ($(PYTHON_BINDINGS),1)

View File

@ -41,6 +41,7 @@ libdir ?= @libdir@
incdir = @includedir@ incdir = @includedir@
udevdir = @UDEVDIR@ udevdir = @UDEVDIR@
udevruledir = ${udevdir}/rules.d udevruledir = ${udevdir}/rules.d
pkgconfigdir = @pkgconfigdir@
# external libs required by various binaries; for btrfs-foo, # external libs required by various binaries; for btrfs-foo,
# specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules in Makefile # specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules in Makefile

View File

@ -12,6 +12,10 @@ LIBBTRFS_MAJOR=0
LIBBTRFS_MINOR=1 LIBBTRFS_MINOR=1
LIBBTRFS_PATCHLEVEL=2 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"} CFLAGS=${CFLAGS:-"-g -O1 -Wall -D_FORTIFY_SOURCE=2"}
AC_SUBST([CFLAGS]) AC_SUBST([CFLAGS])
@ -300,18 +304,25 @@ AC_SUBST([LZO2_LIBS])
AC_SUBST([LZO2_LIBS_STATIC]) AC_SUBST([LZO2_LIBS_STATIC])
AC_SUBST([LZO2_CFLAGS]) 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 dnl library stuff
AC_SUBST([LIBBTRFS_MAJOR]) AC_SUBST([LIBBTRFS_MAJOR])
AC_SUBST([LIBBTRFS_MINOR]) AC_SUBST([LIBBTRFS_MINOR])
AC_SUBST([LIBBTRFS_PATCHLEVEL]) 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_HEADERS([config.h])
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile.inc Makefile.inc
Documentation/Makefile Documentation/Makefile
version.h version.h
libbtrfsutil/libbtrfsutil.pc
]) ])
AC_OUTPUT AC_OUTPUT
@ -327,6 +338,7 @@ AC_MSG_RESULT([
bindir: ${bindir} bindir: ${bindir}
libdir: ${libdir} libdir: ${libdir}
includedir: ${includedir} includedir: ${includedir}
pkgconfigdir: ${pkgconfigdir}
compiler: ${CC} compiler: ${CC}
cflags: ${CFLAGS} cflags: ${CFLAGS}

View File

@ -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