[Libguestfs] [hivex PATCH 6/8] build: allow C programs using hivex to be compiled against build dir

Laszlo Ersek lersek at redhat.com
Wed Sep 8 13:27:56 UTC 2021


Port libguestfs commits e33b3c83a02c ("build: Allow C programs using
libguestfs to be compiled against build dir.", 2020-03-12) and
dbfab7d3b283 ("build: fix includedir in uninstalled libguestfs.pc",
2020-09-22) to hivex.

This allows C programs to find a just built, but not installed, hivex
tree. The "run" script points PKG_CONFIG_PATH to the new file
"lib/local/hivex.pc", which describes the just-built hivex worktree.

Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
 configure.ac          |  1 +
 lib/Makefile.am       |  3 ++-
 .gitignore            |  1 +
 lib/local/hivex.pc.in | 35 +++++++++++++++++++++++++++++++++++
 run.in                |  4 ++++
 5 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 lib/local/hivex.pc.in

diff --git a/configure.ac b/configure.ac
index 3c79842ee5c6..dd4a31b619e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -574,6 +574,7 @@ AC_CONFIG_FILES([Makefile
                  include/Makefile
                  lib/Makefile
                  lib/hivex.pc
+                 lib/local/hivex.pc
                  lib/tools/Makefile
                  ocaml/Makefile ocaml/META
                  perl/Makefile perl/Makefile.PL
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 581a0112d8df..f385e769e1fb 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -20,7 +20,8 @@ SUBDIRS = tools
 EXTRA_DIST = \
 	hivex.pc.in \
 	hivex.pod \
-	hivex.syms
+	hivex.syms \
+	local/hivex.pc.in
 
 lib_LTLIBRARIES = libhivex.la
 
diff --git a/.gitignore b/.gitignore
index 10154711f56c..596030afe5cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,6 +58,7 @@ Makefile.in
 /lib/hivex.pc
 /lib/hivex.pod
 /lib/hivex.syms
+/lib/local/hivex.pc
 /lib/test-just-header
 /lib/tools/*.opt
 /libtool
diff --git a/lib/local/hivex.pc.in b/lib/local/hivex.pc.in
new file mode 100644
index 000000000000..d899cb01a282
--- /dev/null
+++ b/lib/local/hivex.pc.in
@@ -0,0 +1,35 @@
+# @configure_input@
+# Copyright (C) 2020-2021 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+# Dummy pkg-config file which is used to allow out of tree packages to
+# be configured against the hivex tree without hivex needing to be installed.
+#
+# Note if you are using the ./run script then you don't need to worry
+# about this because the script sets PKG_CONFIG_PATH correctly.
+
+prefix=@abs_top_builddir@
+exec_prefix=@abs_top_builddir@
+libdir=@abs_top_builddir@/lib/.libs
+includedir=@abs_top_srcdir@/include
+
+Name: hivex
+Version: @VERSION@
+Description: Read and write Windows Registry Hive files.
+Requires:
+Cflags: -I${includedir}
+Libs: -L${libdir} -lhivex
diff --git a/run.in b/run.in
index 4adb2039c6fe..e2563845f673 100755
--- a/run.in
+++ b/run.in
@@ -87,6 +87,10 @@ export CAML_LD_LIBRARY_PATH
 random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
 export MALLOC_PERTURB_=$random_val
 
+# Allow dependent packages like libguestfs to be compiled against local hivex.
+prepend PKG_CONFIG_PATH "$b/lib/local"
+export PKG_CONFIG_PATH
+
 # Do we have libtool?  If we have it then we can use it to make
 # running valgrind simpler.  However don't depend on it.
 if libtool --help >/dev/null 2>&1; then
-- 
2.19.1.3.g30247aa5d201




More information about the Libguestfs mailing list