[Libguestfs] [hivex PATCH 2/8] build: expose public library header "hivex.h" without "lib" contents

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


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




More information about the Libguestfs mailing list