Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 0/8] add a pkg-config descriptor for the local (not installed) build tree
This series introduces the "lib/local/hivex.pc" pkg-config file to hivex, permitting, through the "run" script, other programs and libraries to be built against the just-built (not installed) hivex tree. A few small details in the hivex build machinery that I understood to be warts are cleaned up, and parts of the libguestfs tree *layout* are adopted. Thanks, Laszlo Laszlo Ersek (8): build: do not look for headers in "$(top_builddir)/lib" build: expose public library header "hivex.h" without "lib" contents build: remove "hivex.pc" from EXTRA_DIST build: move "hivex.pc.in" to the "lib" subdirectory run: use 'prepend' function to build paths build: allow C programs using hivex to be compiled against build dir build: link hivex statically into C programs compiled against build dir build: allow OCaml programs using hivex to be compiled against build dir configure.ac | 4 ++- Makefile.am | 8 ++--- images/Makefile.am | 2 +- include/Makefile.am | 20 +++++++++++++ lib/Makefile.am | 16 +++++++--- ocaml/Makefile.am | 21 ++++++++++++-- perl/Makefile.PL.in | 2 +- python/Makefile.am | 2 +- ruby/Rakefile.in | 2 +- sh/Makefile.am | 3 +- xml/Makefile.am | 1 + .gitignore | 6 ++-- generator/generator.ml | 2 +- hivex.pc.in => lib/hivex.pc.in | 0 lib/local/hivex.pc.in | 35 ++++++++++++++++++++++ run.in | 53 +++++++++++++++++----------------- 16 files changed, 129 insertions(+), 48 deletions(-) create mode 100644 include/Makefile.am rename hivex.pc.in => lib/hivex.pc.in (100%) create mode 100644 lib/local/hivex.pc.in -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 1/8] build: do not look for headers in "$(top_builddir)/lib"
The "hivex.h" public library header is generated when "autogen.sh" is run. Thus, for example, "hivex.h" is part of the tarball distribution that is created by "make dist". When plain "make" is invoked (for building the project), "hivex.h" already exists, namely in "$(top_srcdir)/lib". "make" does not generate *any* header files in "$(top_builddir)/lib" (which, for out-of-tree builds, stands for a different pathname than "$(top_srcdir)/lib" does). Remove the useless "-I$(top_builddir)/lib" options from the lib, perl, and python makefiles, preserving the proper "-I$(top_srcdir)/lib" ones. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- lib/Makefile.am | 2 +- perl/Makefile.PL.in | 2 +- python/Makefile.am | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index 4a7cea1752e6..1a1e2bc2e55d 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -84,7 +84,7 @@ TESTS = test-just-header test_just_header_SOURCES = test-just-header.c test_just_header_CFLAGS = \ - -I$(top_srcdir)/lib -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ $(WARN_CFLAGS) $(WERROR_CFLAGS) test_just_header_LDADD = \ $(top_builddir)/lib/libhivex.la diff --git a/perl/Makefile.PL.in b/perl/Makefile.PL.in index 77b4a0e4dd59..92e298b9a889 100644 --- a/perl/Makefile.PL.in +++ b/perl/Makefile.PL.in @@ -25,7 +25,7 @@ WriteMakefile ( VERSION => '@PACKAGE_VERSION@', LIBS => '-L at top_builddir@/lib/.libs -lhivex', - INC => '-I at top_builddir@/lib -I at top_srcdir@/lib', + INC => '-I at top_srcdir@/lib', TYPEMAPS => [ '@srcdir@/typemap' ], CCFLAGS => $Config{ccflags} . ' @CFLAGS@', ); diff --git a/python/Makefile.am b/python/Makefile.am index 1117ab942edc..5bac34b95fc7 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -38,7 +38,7 @@ python_LTLIBRARIES = libhivexmod.la libhivexmod_la_SOURCES = hivex-py.c libhivexmod_la_CFLAGS = -Wall $(PYTHON_CFLAGS) \ - -I$(top_srcdir)/lib -I$(top_builddir)/lib + -I$(top_srcdir)/lib libhivexmod_la_LIBADD = $(top_builddir)/lib/libhivex.la libhivexmod_la_LDFLAGS = -avoid-version -shared -module -shrext $(PYTHON_EXT_SUFFIX) -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 2/8] build: expose public library header "hivex.h" without "lib" contents
Move the public library header "hivex.h" from "lib" to "include". In the "lib", "sh" and "xml" subdirectories, some of the library-internal header files ("byte_conversions.h", "gettext.h", "hivex-internal.h", "mmap.h") are consumed. There, let the new "include" directory extend -- and not replace -- the existent "lib" directory. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- configure.ac | 1 + Makefile.am | 2 +- images/Makefile.am | 2 +- include/Makefile.am | 20 ++++++++++++++++++++ lib/Makefile.am | 7 +++---- ocaml/Makefile.am | 2 +- perl/Makefile.PL.in | 2 +- python/Makefile.am | 2 +- ruby/Rakefile.in | 2 +- sh/Makefile.am | 3 ++- xml/Makefile.am | 1 + .gitignore | 2 +- generator/generator.ml | 2 +- 13 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 include/Makefile.am diff --git a/configure.ac b/configure.ac index 6180195ec4be..8adcb8512e66 100644 --- a/configure.ac +++ b/configure.ac @@ -572,6 +572,7 @@ AC_CONFIG_FILES([Makefile gnulib/tests/Makefile hivex.pc images/Makefile + include/Makefile lib/Makefile lib/tools/Makefile ocaml/Makefile ocaml/META diff --git a/Makefile.am b/Makefile.am index 48611a0f929e..d217ea52fcb2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,7 +20,7 @@ ACLOCAL_AMFLAGS = -I m4 # Work around broken libtool. export to_tool_file_cmd=func_convert_file_noop -SUBDIRS = gnulib/lib generator lib images gnulib/tests +SUBDIRS = gnulib/lib generator lib images include gnulib/tests if HAVE_LIBXML2 SUBDIRS += xml diff --git a/images/Makefile.am b/images/Makefile.am index cdf3edc4c27d..41a0c0c06935 100644 --- a/images/Makefile.am +++ b/images/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = minimal rlenvalue_test_hive special mkzero/Makefile mkzero/mkzero.c noinst_PROGRAMS = mklarge mklarge_SOURCES = mklarge.c mklarge_CFLAGS = \ - -I$(srcdir)/../lib \ + -I$(srcdir)/../include \ $(WARN_CFLAGS) $(WERROR_CFLAGS) mklarge_LDADD = ../lib/libhivex.la diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 000000000000..edb02fe0a972 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,20 @@ +# hivex +# Copyright (C) 2009-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., 675 Mass Ave, Cambridge, MA 02139, USA. + +EXTRA_DIST = hivex.h + +include_HEADERS = hivex.h diff --git a/lib/Makefile.am b/lib/Makefile.am index 1a1e2bc2e55d..9bdf494c7742 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -27,7 +27,7 @@ libhivex_la_SOURCES = \ byte_conversions.h \ gettext.h \ handle.c \ - hivex.h \ + ../include/hivex.h \ hivex-internal.h \ mmap.h \ node.c \ @@ -48,11 +48,10 @@ libhivex_la_LDFLAGS = \ libhivex_la_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) libhivex_la_CPPFLAGS = \ -I$(top_srcdir)/gnulib/lib \ + -I$(top_srcdir)/include \ -I$(top_builddir)/gnulib/lib \ -I$(srcdir) -include_HEADERS = hivex.h - man_MANS = hivex.3 hivex.3: hivex.pod @@ -84,7 +83,7 @@ TESTS = test-just-header test_just_header_SOURCES = test-just-header.c test_just_header_CFLAGS = \ - -I$(top_srcdir)/lib \ + -I$(top_srcdir)/include \ $(WARN_CFLAGS) $(WERROR_CFLAGS) test_just_header_LDADD = \ $(top_builddir)/lib/libhivex.la diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 85655b6f727d..1ef0c194e212 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -26,7 +26,7 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so AM_CPPFLAGS = \ -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \ - -I$(top_srcdir)/lib \ + -I$(top_srcdir)/include \ $(WARN_CFLAGS) $(WERROR_CFLAGS) if HAVE_OCAML diff --git a/perl/Makefile.PL.in b/perl/Makefile.PL.in index 92e298b9a889..49d79d1a1c29 100644 --- a/perl/Makefile.PL.in +++ b/perl/Makefile.PL.in @@ -25,7 +25,7 @@ WriteMakefile ( VERSION => '@PACKAGE_VERSION@', LIBS => '-L at top_builddir@/lib/.libs -lhivex', - INC => '-I at top_srcdir@/lib', + INC => '-I at top_srcdir@/include', TYPEMAPS => [ '@srcdir@/typemap' ], CCFLAGS => $Config{ccflags} . ' @CFLAGS@', ); diff --git a/python/Makefile.am b/python/Makefile.am index 5bac34b95fc7..77dca93a01cb 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -38,7 +38,7 @@ python_LTLIBRARIES = libhivexmod.la libhivexmod_la_SOURCES = hivex-py.c libhivexmod_la_CFLAGS = -Wall $(PYTHON_CFLAGS) \ - -I$(top_srcdir)/lib + -I$(top_srcdir)/include libhivexmod_la_LIBADD = $(top_builddir)/lib/libhivex.la libhivexmod_la_LDFLAGS = -avoid-version -shared -module -shrext $(PYTHON_EXT_SUFFIX) diff --git a/ruby/Rakefile.in b/ruby/Rakefile.in index cd995077d0ae..bf07c2296e94 100644 --- a/ruby/Rakefile.in +++ b/ruby/Rakefile.in @@ -54,7 +54,7 @@ CLOBBER.include [ "@builddir@/config.save", "@builddir@/ext/**/mkmf.log", # Build locally file MAKEFILE => EXT_CONF do |t| - unless sh "top_srcdir=$(pwd)/@top_srcdir@; top_builddir=$(pwd)/@top_builddir@; export ARCHFLAGS=\"-arch $(uname -m)\"; mkdir -p @builddir@/ext/hivex; cd @builddir@/ext/hivex; @RUBY@ #{EXT_CONF} --with-_hivex-include=$top_srcdir/lib --with-_hivex-lib=$top_builddir/lib/.libs" + unless sh "top_srcdir=$(pwd)/@top_srcdir@; top_builddir=$(pwd)/@top_builddir@; export ARCHFLAGS=\"-arch $(uname -m)\"; mkdir -p @builddir@/ext/hivex; cd @builddir@/ext/hivex; @RUBY@ #{EXT_CONF} --with-_hivex-include=$top_srcdir/include --with-_hivex-lib=$top_builddir/lib/.libs" $stderr.puts "Failed to run extconf" break end diff --git a/sh/Makefile.am b/sh/Makefile.am index 98fdd052e78a..9fec4aab8332 100644 --- a/sh/Makefile.am +++ b/sh/Makefile.am @@ -32,7 +32,7 @@ noinst_SCRIPTS = example1 example2 example3 example4 example5 example6 hivexsh_SOURCES = \ hivexsh.c \ - ../lib/hivex.h \ + ../include/hivex.h \ ../lib/byte_conversions.h hivexsh_LDADD = ../lib/libhivex.la ../gnulib/lib/libgnu.la $(LIBREADLINE) @@ -40,6 +40,7 @@ hivexsh_CFLAGS = \ -I$(top_srcdir)/gnulib/lib \ -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib \ + -I$(top_srcdir)/include \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ $(WARN_CFLAGS) $(WERROR_CFLAGS) diff --git a/xml/Makefile.am b/xml/Makefile.am index 3ebe2cc14c27..1119e785d675 100644 --- a/xml/Makefile.am +++ b/xml/Makefile.am @@ -29,6 +29,7 @@ hivexml_CFLAGS = \ -I$(top_srcdir)/gnulib/lib \ -I$(top_builddir)/gnulib/lib \ -I$(top_srcdir)/lib \ + -I$(top_srcdir)/include \ $(LIBXML2_CFLAGS) \ $(WARN_CFLAGS) $(WERROR_CFLAGS) diff --git a/.gitignore b/.gitignore index c64fe5bbae38..af256d59030e 100644 --- a/.gitignore +++ b/.gitignore @@ -53,9 +53,9 @@ Makefile.in /html/hivexsh.1.html /images/large /images/mklarge +/include/hivex.h /install-sh /lib/*.3 -/lib/hivex.h /lib/hivex.pod /lib/hivex.syms /lib/test-just-header diff --git a/generator/generator.ml b/generator/generator.ml index dd55c23b4851..f693ebb2b39c 100755 --- a/generator/generator.ml +++ b/generator/generator.ml @@ -3855,7 +3855,7 @@ Run it from the top source directory using the command check_functions (); - output_to "lib/hivex.h" generate_c_header; + output_to "include/hivex.h" generate_c_header; output_to "lib/hivex.pod" generate_c_pod; output_to "lib/hivex.syms" generate_linker_script; -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 3/8] build: remove "hivex.pc" from EXTRA_DIST
The "configure" script creates "hivex.pc" in the build directory from "hivex.pc.in"; there's no need to package "hivex.pc" in a tarball distribution (created by "make dist"). Remove "hivex.pc" from EXTRA_DIST. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index d217ea52fcb2..f69d8cfb8e67 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,7 @@ if ALWAYS_FALSE SUBDIRS += extra-tests endif -EXTRA_DIST = hivex.pc hivex.pc.in LICENSE README run.in \ +EXTRA_DIST = hivex.pc.in LICENSE README run.in \ po/zanata-pull.sh po/zanata.xml # Generate the ChangeLog automatically from the gitlog. -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 4/8] build: move "hivex.pc.in" to the "lib" subdirectory
Bring hivex's worktree structure closer to libguestfs's, in preparation for introducing "lib/local/hivex.pc.in" in a subsequent patch. Move "hivex.pc.in" to the "lib" subdirectory. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- configure.ac | 2 +- Makefile.am | 6 +----- lib/Makefile.am | 8 ++++++++ .gitignore | 2 +- hivex.pc.in => lib/hivex.pc.in | 0 5 files changed, 11 insertions(+), 7 deletions(-) rename hivex.pc.in => lib/hivex.pc.in (100%) diff --git a/configure.ac b/configure.ac index 8adcb8512e66..3c79842ee5c6 100644 --- a/configure.ac +++ b/configure.ac @@ -570,10 +570,10 @@ AC_CONFIG_FILES([Makefile generator/Makefile gnulib/lib/Makefile gnulib/tests/Makefile - hivex.pc images/Makefile include/Makefile lib/Makefile + lib/hivex.pc lib/tools/Makefile ocaml/Makefile ocaml/META perl/Makefile perl/Makefile.PL diff --git a/Makefile.am b/Makefile.am index f69d8cfb8e67..221eebb75298 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,7 @@ if ALWAYS_FALSE SUBDIRS += extra-tests endif -EXTRA_DIST = hivex.pc.in LICENSE README run.in \ +EXTRA_DIST = LICENSE README run.in \ po/zanata-pull.sh po/zanata.xml # Generate the ChangeLog automatically from the gitlog. @@ -60,10 +60,6 @@ dist-hook: $(top_srcdir)/build-aux/gitlog-to-changelog > ChangeLog cp ChangeLog $(distdir)/ChangeLog -# Pkgconfig. -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = hivex.pc - # Maintainer website update. HTMLFILES = \ html/hivex.3.html \ diff --git a/lib/Makefile.am b/lib/Makefile.am index 9bdf494c7742..581a0112d8df 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -18,6 +18,7 @@ SUBDIRS = tools EXTRA_DIST = \ + hivex.pc.in \ hivex.pod \ hivex.syms @@ -52,6 +53,13 @@ libhivex_la_CPPFLAGS = \ -I$(top_builddir)/gnulib/lib \ -I$(srcdir) +# Pkgconfig. + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = hivex.pc + +# Manual page. + man_MANS = hivex.3 hivex.3: hivex.pod diff --git a/.gitignore b/.gitignore index af256d59030e..10154711f56c 100644 --- a/.gitignore +++ b/.gitignore @@ -44,7 +44,6 @@ Makefile.in /generator/stamp-generator /GNUmakefile /gnulib -/hivex.pc /hivex-*.tar.gz /html/hivex.3.html /html/hivexget.1.html @@ -56,6 +55,7 @@ Makefile.in /include/hivex.h /install-sh /lib/*.3 +/lib/hivex.pc /lib/hivex.pod /lib/hivex.syms /lib/test-just-header diff --git a/hivex.pc.in b/lib/hivex.pc.in similarity index 100% rename from hivex.pc.in rename to lib/hivex.pc.in -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 5/8] run: use 'prepend' function to build paths
Port libguestfs commit cae7909f5ed8 ("./run: Use 'prepend' function to build paths.", 2015-02-13) to hivex: Add a bash function 'prepend' for intelligently prepending elements to paths. eg: prepend PYTHONPATH "/foo" would set PYTHONPATH to "/foo" or "/foo:<previous-contents-of-PYTHONPATH>". Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- run.in | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/run.in b/run.in index 0f23a7c638d4..4adb2039c6fe 100755 --- a/run.in +++ b/run.in @@ -29,29 +29,31 @@ #---------------------------------------------------------------------- +# Function to intelligently prepend a path to an environment variable. +# See http://stackoverflow.com/a/9631350 +prepend() +{ + eval $1="$2\${$1:+:\$$1}" +} + # Source and build directories (absolute paths so this works from any # directory). s="$(cd @abs_srcdir@ && pwd)" b="$(cd @abs_builddir@ && pwd)" # Set PATH to contain all local programs. -PATH="$b/sh:$b/regedit:$b/xml:$PATH" +prepend PATH "$b/xml" +prepend PATH "$b/regedit" +prepend PATH "$b/sh" export PATH # Set LD_LIBRARY_PATH to contain library. -if [ -z "$LD_LIBRARY_PATH" ]; then - LD_LIBRARY_PATH="$b/lib/.libs" -else - LD_LIBRARY_PATH="$b/lib/.libs:$LD_LIBRARY_PATH" -fi +prepend LD_LIBRARY_PATH "$b/lib/.libs" export LD_LIBRARY_PATH # For Perl. -if [ -z "$PERL5LIB" ]; then - PERL5LIB="$b/perl/blib/lib:$b/perl/blib/arch" -else - PERL5LIB="$b/perl/blib/lib:$b/perl/blib/arch:$PERL5LIB" -fi +prepend PERL5LIB "$b/perl/blib/arch" +prepend PERL5LIB "$b/perl/blib/lib" export PERL5LIB # Enable Perl valgrinding. @@ -63,30 +65,21 @@ export PERL_DESTRUCT_LEVEL=2 # For Python. export PYTHON="@PYTHON@" -if [ -z "$PYTHONPATH" ]; then - PYTHONPATH="$s/python:$b/python:$b/python/.libs" -else - PYTHONPATH="$s/python:$b/python:$b/python/.libs:$PYTHONPATH" -fi +prepend PYTHONPATH "$b/python/.libs" +prepend PYTHONPATH "$b/python" +prepend PYTHONPATH "$s/python" export PYTHONPATH # For Ruby. export RUBY="@RUBY@" export RAKE="@RAKE@" -if [ -z "$RUBYLIB" ]; then - RUBYLIB="$s/ruby/lib:$b/ruby/ext/hivex" -else - RUBYLIB="$s/ruby/lib:$b/ruby/ext/hivex:$RUBYLIB" -fi +prepend RUBYLIB "$b/ruby/ext/hivex" +prepend RUBYLIB "$s/ruby/lib" export RUBYLIB -export LD_LIBRARY_PATH="$b/ruby/ext/hivex:$LD_LIBRARY_PATH" +prepend LD_LIBRARY_PATH "$b/ruby/ext/hivex" # For OCaml. -if [ -z "$CAML_LD_LIBRARY_PATH" ]; then - CAML_LD_LIBRARY_PATH="$b/ocaml" -else - CAML_LD_LIBRARY_PATH="$b/ocaml:$CAML_LD_LIBRARY_PATH" -fi +prepend CAML_LD_LIBRARY_PATH "$b/ocaml" export CAML_LD_LIBRARY_PATH # This is a cheap way to find some use-after-free and uninitialized -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 6/8] build: allow C programs using hivex to be compiled against build dir
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
Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 7/8] build: link hivex statically into C programs compiled against build dir
This static-only linking allows the libguestfs daemon ("guestfsd") to launch in the appliance, without unresolved hivex symbols, when libguestfs is built against the hivex build dir. (Libguestfs's automatic *package* collection for the appliance, based on the shared library requirements of "guestfsd", cannot cover hivex when hivex is provided by a local build directory.) Linking hivex statically into *host-side* C programs that are compiled against the hivex build dir is only a small penalty. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- lib/local/hivex.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local/hivex.pc.in b/lib/local/hivex.pc.in index d899cb01a282..6f0b5bb44237 100644 --- a/lib/local/hivex.pc.in +++ b/lib/local/hivex.pc.in @@ -32,4 +32,4 @@ Version: @VERSION@ Description: Read and write Windows Registry Hive files. Requires: Cflags: -I${includedir} -Libs: -L${libdir} -lhivex +Libs: -L${libdir} -l:libhivex.a -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Sep-08 13:27 UTC
[Libguestfs] [hivex PATCH 8/8] build: allow OCaml programs using hivex to be compiled against build dir
Port libguestfs commit bf61bf7355d3 ("build: Allow OCaml programs using libguestfs to be compiled against build dir.", 2020-03-12) to hivex. This allows C+OCaml programs, such as libguestfs itself, to find a just built, but not installed, hivex tree:> libguestfs$ ../hivex/run ./configure CFLAGS=-fPIC > libguestfs$ ../hivex/run make -j $(getconf _NPROCESSORS_ONLN) > libguestfs$ ../hivex/run make -j $(getconf _NPROCESSORS_ONLN) checkSigned-off-by: Laszlo Ersek <lersek at redhat.com> --- ocaml/Makefile.am | 19 ++++++++++++++++++- .gitignore | 1 + run.in | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 1ef0c194e212..ace3208ea309 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -112,7 +112,24 @@ install-data-hook: CLEANFILES += $(noinst_DATA) -endif +# This "tricks" ocamlfind into allowing us to compile other OCaml +# programs against a locally compiled copy of the hivex sources. +# ocamlfind needs to see a directory called ?hivex? which contains +# ?META?. The current directory is called ?ocaml?, but if we make +# this symlink then we can create the required directory structure. +# +# Note if you just want to use this, make sure you use +# ?../hivex/run make? in your other program and everything should +# just work. +CLEANFILES += hivex + +all-local: hivex + +hivex: + rm -f $@ + $(LN_S) . $@ + +endif HAVE_OCAML # Tell version 3.79 and up of GNU make to not build goals in this # directory in parallel. (See RHBZ#502309). diff --git a/.gitignore b/.gitignore index 596030afe5cc..b856922c917b 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,7 @@ Makefile.in /m4/ltversion.m4 /maint.mk /missing +/ocaml/hivex /ocaml/hivex.ml /ocaml/hivex.mli /ocaml/hivex_c.c diff --git a/run.in b/run.in index e2563845f673..e166a9202248 100755 --- a/run.in +++ b/run.in @@ -90,6 +90,8 @@ 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 +prepend OCAMLPATH "$b/ocaml" +export OCAMLPATH # Do we have libtool? If we have it then we can use it to make # running valgrind simpler. However don't depend on it. -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2021-Sep-09 13:43 UTC
[Libguestfs] [hivex PATCH 0/8] add a pkg-config descriptor for the local (not installed) build tree
On 09/08/21 15:27, Laszlo Ersek wrote:> This series introduces the "lib/local/hivex.pc" pkg-config file to > hivex, permitting, through the "run" script, other programs and > libraries to be built against the just-built (not installed) hivex tree. > A few small details in the hivex build machinery that I understood to be > warts are cleaned up, and parts of the libguestfs tree *layout* are > adopted. > > Thanks, > Laszlo > > Laszlo Ersek (8): > build: do not look for headers in "$(top_builddir)/lib" > build: expose public library header "hivex.h" without "lib" contents > build: remove "hivex.pc" from EXTRA_DIST > build: move "hivex.pc.in" to the "lib" subdirectory > run: use 'prepend' function to build paths > build: allow C programs using hivex to be compiled against build dir > build: link hivex statically into C programs compiled against build > dir > build: allow OCaml programs using hivex to be compiled against build > dir > > configure.ac | 4 ++- > Makefile.am | 8 ++--- > images/Makefile.am | 2 +- > include/Makefile.am | 20 +++++++++++++ > lib/Makefile.am | 16 +++++++--- > ocaml/Makefile.am | 21 ++++++++++++-- > perl/Makefile.PL.in | 2 +- > python/Makefile.am | 2 +- > ruby/Rakefile.in | 2 +- > sh/Makefile.am | 3 +- > xml/Makefile.am | 1 + > .gitignore | 6 ++-- > generator/generator.ml | 2 +- > hivex.pc.in => lib/hivex.pc.in | 0 > lib/local/hivex.pc.in | 35 ++++++++++++++++++++++ > run.in | 53 +++++++++++++++++----------------- > 16 files changed, 129 insertions(+), 48 deletions(-) > create mode 100644 include/Makefile.am > rename hivex.pc.in => lib/hivex.pc.in (100%) > create mode 100644 lib/local/hivex.pc.in >Merged as commit range ace0be49b529..34c6d42a9b0e. Thanks Laszlo