[PATCH] hivex: A few tweaks to enable building in a separate directory
--- configure.ac | 2 +- images/Makefile.am | 5 +++-- lib/Makefile.am | 14 +++++++------- ocaml/Makefile.am | 3 ++- ocaml/t/hivex_300_fold.ml | 3 +-- python/run-python-tests | 25 ------------------------- python/run-python-tests.in | 25 +++++++++++++++++++++++++ 7 files changed, 39 insertions(+), 38 deletions(-) delete mode 100755 python/run-python-tests create mode 100755 python/run-python-tests.in diff --git a/configure.ac b/configure.ac index 22b806f..31d20ff 100644 --- a/configure.ac +++ b/configure.ac @@ -434,7 +434,7 @@ AC_CONFIG_FILES([Makefile lib/tools/Makefile ocaml/Makefile ocaml/META perl/Makefile perl/Makefile.PL - python/Makefile + python/Makefile python/run-python-tests po/Makefile.in regedit/Makefile sh/Makefile diff --git a/images/Makefile.am b/images/Makefile.am index 2adaed3..e176d3c 100644 --- a/images/Makefile.am +++ b/images/Makefile.am @@ -29,7 +29,8 @@ mklarge_LDADD = ../lib/libhivex.la noinst_DATA = large -large: mklarge - ./mklarge $(srcdir)/minimal large +large: minimal mklarge + cp -u $(srcdir)/minimal $(builddir)/minimal + ./mklarge $(builddir)/minimal $(builddir)/large CLEANFILES = $(noinst_DATA) diff --git a/lib/Makefile.am b/lib/Makefile.am index d54aaee..7e5b92b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -33,11 +33,11 @@ libhivex_la_SOURCES = \ libhivex_la_LIBADD = ../gnulib/lib/libgnu.la libhivex_la_LDFLAGS = \ -version-info 0:0:0 \ - $(VERSION_SCRIPT_FLAGS)hivex.syms \ + $(VERSION_SCRIPT_FLAGS)$(srcdir)/hivex.syms \ $(LTLIBINTL) \ $(LTLIBTHREAD) libhivex_la_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) -libhivex_la_CPPFLAGS = -I$(top_srcdir)/gnulib/lib +libhivex_la_CPPFLAGS = -I$(top_srcdir)/gnulib/lib -I$(srcdir) include_HEADERS = hivex.h @@ -56,10 +56,10 @@ noinst_DATA = \ $(top_builddir)/html/hivex.3.html: hivex.pod mkdir -p $(top_builddir)/html - cd $(top_builddir) && pod2html \ - --css 'pod.css' \ - --htmldir html \ - --outfile html/hivex.3.html \ - lib/hivex.pod + pod2html \ + --css $(top_srcdir)/css/pod.css \ + --htmldir $(top_builddir)/html \ + --outfile $(top_builddir)/html/hivex.3.html \ + $< CLEANFILES = $(man_MANS) diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index c688df0..89a59cd 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -64,7 +64,8 @@ TESTS = \ noinst_DATA += $(TESTS) # https://www.redhat.com/archives/libguestfs/2011-May/thread.html#00015 -t/%: t/%.cmo mlhivex.cma +t/%: $(srcdir)/t/%.cmo mlhivex.cma + mkdir -p t $(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \ $(OCAMLFIND) ocamlc -dllpath $(abs_builddir) -package unix \ -linkpkg mlhivex.cma $< -o $@ diff --git a/ocaml/t/hivex_300_fold.ml b/ocaml/t/hivex_300_fold.ml index 0c7bc4f..c8de6e8 100644 --- a/ocaml/t/hivex_300_fold.ml +++ b/ocaml/t/hivex_300_fold.ml @@ -21,7 +21,6 @@ open Unix open Printf let (//) = Filename.concat -let srcdir = try Sys.getenv "srcdir" with Not_found -> "." (* This is a generic function to fold over hives. * fn : 'a -> node -> 'a is called for each node @@ -36,7 +35,7 @@ let hive_fold h fn fv a root = fold a root let () = - let h = Hivex.open_file (srcdir // "../images/large") [] in + let h = Hivex.open_file ("../images/large") [] in (* Count the number of nodes and values in the hive. *) let count_node (nodes, values) _ = (nodes+1, values) in diff --git a/python/run-python-tests b/python/run-python-tests deleted file mode 100755 index e8c8c14..0000000 --- a/python/run-python-tests +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# hivex Python bindings -# Copyright (C) 2009-2011 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. - -set -e -shopt -s nullglob - -for f in t/*.py; do - basename "$f" - python "$f" -done diff --git a/python/run-python-tests.in b/python/run-python-tests.in new file mode 100755 index 0000000..af51080 --- /dev/null +++ b/python/run-python-tests.in @@ -0,0 +1,25 @@ +#!/bin/bash - +# hivex Python bindings +# Copyright (C) 2009-2011 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. + +set -e +shopt -s nullglob + +for f in $(srcdir)t/*.py; do + basename "$f" + @PYTHON@ "$f" +done -- 1.7.5.4
On Thu, Aug 11, 2011 at 05:24:05PM +0200, Hilko Bengen wrote:
--- configure.ac | 2 +- images/Makefile.am | 5 +++-- lib/Makefile.am | 14 +++++++------- ocaml/Makefile.am | 3 ++- ocaml/t/hivex_300_fold.ml | 3 +-- python/run-python-tests | 25 ------------------------- python/run-python-tests.in | 25 +++++++++++++++++++++++++ 7 files changed, 39 insertions(+), 38 deletions(-) delete mode 100755 python/run-python-tests create mode 100755 python/run-python-tests.in
diff --git a/configure.ac b/configure.ac index 22b806f..31d20ff 100644 --- a/configure.ac +++ b/configure.ac @@ -434,7 +434,7 @@ AC_CONFIG_FILES([Makefile lib/tools/Makefile ocaml/Makefile ocaml/META perl/Makefile perl/Makefile.PL - python/Makefile + python/Makefile python/run-python-tests po/Makefile.in regedit/Makefile sh/Makefile diff --git a/images/Makefile.am b/images/Makefile.am index 2adaed3..e176d3c 100644 --- a/images/Makefile.am +++ b/images/Makefile.am @@ -29,7 +29,8 @@ mklarge_LDADD = ../lib/libhivex.la
noinst_DATA = large
-large: mklarge - ./mklarge $(srcdir)/minimal large +large: minimal mklarge + cp -u $(srcdir)/minimal $(builddir)/minimal + ./mklarge $(builddir)/minimal $(builddir)/large
CLEANFILES = $(noinst_DATA) diff --git a/lib/Makefile.am b/lib/Makefile.am index d54aaee..7e5b92b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -33,11 +33,11 @@ libhivex_la_SOURCES = \ libhivex_la_LIBADD = ../gnulib/lib/libgnu.la libhivex_la_LDFLAGS = \ -version-info 0:0:0 \ - $(VERSION_SCRIPT_FLAGS)hivex.syms \ + $(VERSION_SCRIPT_FLAGS)$(srcdir)/hivex.syms \ $(LTLIBINTL) \ $(LTLIBTHREAD) libhivex_la_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) -libhivex_la_CPPFLAGS = -I$(top_srcdir)/gnulib/lib +libhivex_la_CPPFLAGS = -I$(top_srcdir)/gnulib/lib -I$(srcdir)
include_HEADERS = hivex.h
@@ -56,10 +56,10 @@ noinst_DATA = \
$(top_builddir)/html/hivex.3.html: hivex.pod mkdir -p $(top_builddir)/html - cd $(top_builddir) && pod2html \ - --css 'pod.css' \ - --htmldir html \ - --outfile html/hivex.3.html \ - lib/hivex.pod + pod2html \ + --css $(top_srcdir)/css/pod.css \ + --htmldir $(top_builddir)/html \ + --outfile $(top_builddir)/html/hivex.3.html \ + $<
CLEANFILES = $(man_MANS) diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index c688df0..89a59cd 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -64,7 +64,8 @@ TESTS = \ noinst_DATA += $(TESTS)
# https://www.redhat.com/archives/libguestfs/2011-May/thread.html#00015 -t/%: t/%.cmo mlhivex.cma +t/%: $(srcdir)/t/%.cmo mlhivex.cma + mkdir -p t $(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \ $(OCAMLFIND) ocamlc -dllpath $(abs_builddir) -package unix \ -linkpkg mlhivex.cma $< -o $@ diff --git a/ocaml/t/hivex_300_fold.ml b/ocaml/t/hivex_300_fold.ml index 0c7bc4f..c8de6e8 100644 --- a/ocaml/t/hivex_300_fold.ml +++ b/ocaml/t/hivex_300_fold.ml @@ -21,7 +21,6 @@ open Unix open Printf let (//) = Filename.concat -let srcdir = try Sys.getenv "srcdir" with Not_found -> "."
(* This is a generic function to fold over hives. * fn : 'a -> node -> 'a is called for each node @@ -36,7 +35,7 @@ let hive_fold h fn fv a root = fold a root
let () = - let h = Hivex.open_file (srcdir // "../images/large") [] in + let h = Hivex.open_file ("../images/large") [] in
(* Count the number of nodes and values in the hive. *) let count_node (nodes, values) _ = (nodes+1, values) in diff --git a/python/run-python-tests b/python/run-python-tests deleted file mode 100755 index e8c8c14..0000000 --- a/python/run-python-tests +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# hivex Python bindings -# Copyright (C) 2009-2011 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. - -set -e -shopt -s nullglob - -for f in t/*.py; do - basename "$f" - python "$f" -done diff --git a/python/run-python-tests.in b/python/run-python-tests.in new file mode 100755 index 0000000..af51080 --- /dev/null +++ b/python/run-python-tests.in @@ -0,0 +1,25 @@ +#!/bin/bash - +# hivex Python bindings +# Copyright (C) 2009-2011 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. + +set -e +shopt -s nullglob + +for f in $(srcdir)t/*.py; do + basename "$f" + @PYTHON@ "$f" +done -- 1.7.5.4
Thanks. I will push this shortly. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
Uh-oh. I had just tried building, not installing, before posting the patch. There are another few issues that need to be sorted out: 1. In the ocaml directory, "make install" does not find .mli files. I think this is easily fixed, see below. 2. I have not found any simple way to make ExtUtils::MakeMaker do out-of-tree builds, yet. Maybe it's easiest to just "cp -rsu" things to $(builddir) there. 3. Some pod2html calls still aren't quite right. I had thought that being able to compile bindings for multiple Python versions would be easier. *sigh* -Hilko diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 89a59cd..de6b321 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -90,5 +90,5 @@ SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly # Do the installation by hand, because we want to run ocamlfind. -install_files = META *.so *.a *.cma *.cmi *.mli +install_files = META *.so *.a *.cma *.cmi $(srcdir)/*.mli if HAVE_OCAMLOPT
Do these patches address the issue where "./configure --prefix=foo" causes non-sudo 'make install' to fail because of something in the Python? I assume no, since you're discussing building and not installing. (I don't think I reported that bug, come to think about it...) --Alex On Aug 11, 2011, at 14:38 , Hilko Bengen wrote:
Uh-oh. I had just tried building, not installing, before posting the patch. There are another few issues that need to be sorted out:
1. In the ocaml directory, "make install" does not find .mli files. I think this is easily fixed, see below.
2. I have not found any simple way to make ExtUtils::MakeMaker do out-of-tree builds, yet. Maybe it's easiest to just "cp -rsu" things to $(builddir) there.
3. Some pod2html calls still aren't quite right.
I had thought that being able to compile bindings for multiple Python versions would be easier. *sigh*
-Hilko
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 89a59cd..de6b321 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -90,5 +90,5 @@ SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
# Do the installation by hand, because we want to run ocamlfind. -install_files = META *.so *.a *.cma *.cmi *.mli +install_files = META *.so *.a *.cma *.cmi $(srcdir)/*.mli
if HAVE_OCAMLOPT
_______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
* Alex Nelson:
Do these patches address the issue where "./configure --prefix=foo" causes non-sudo 'make install' to fail because of something in the Python? I assume no, since you're discussing building and not installing.
Building Debian packages (http://packages.debian.org/search?keywords=hivex) involves using a custom prefix. But yes, my reason for modifying the build scripts for out-of-tree builds is to be able to build bindings for multiploe Python versions. Cheers, -Hilko
* Hilko Bengen:
Uh-oh. I had just tried building, not installing, before posting the patch. There are another few issues that need to be sorted out:
1. In the ocaml directory, "make install" does not find .mli files. I think this is easily fixed, see below.
And another one in the ocaml directory: .cmi files of the test cases are built in $(srcdir). Cheers, -Hilko diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index de6b321..654914a 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -65,5 +65,5 @@ noinst_DATA += $(TESTS) # https://www.redhat.com/archives/libguestfs/2011-May/thread.html#00015 -t/%: $(srcdir)/t/%.cmo mlhivex.cma +t/%: $(builddir)/t/%.cmo mlhivex.cma mkdir -p t $(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \
On Thu, Aug 11, 2011 at 11:38:12PM +0200, Hilko Bengen wrote:
2. I have not found any simple way to make ExtUtils::MakeMaker do out-of-tree builds, yet. Maybe it's easiest to just "cp -rsu" things to $(builddir) there.
I changed the 'cp -u ...' in your original patch to something that uses 'cmp'. See: http://git.annexia.org/?p=hivex.git;a=commitdiff;h=b22f2651674b4628978bd5971... This was needed in order to make builds work where srcdir == builddir (I tested both ways, but I too did not test 'make install'). I'll take a look at the patches tomorrow. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Here's the fix for perl. Both in-tree and out-of-tree build and install worked. -Hilko diff --git a/perl/Makefile.am b/perl/Makefile.am index ddc40b7..1722bcf 100644 --- a/perl/Makefile.am +++ b/perl/Makefile.am @@ -47,4 +47,5 @@ all: Makefile-pl src_deps Makefile-pl: Makefile.PL + -[ $(srcdir) != $(builddir) ] && cp -rsu $(abs_srcdir)/. $(builddir)/. perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix)
This patch hopefully fixes building and installing the OCaml bindings both in-tree and out-of-tree. -Hilko diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 89a59cd..ca4c111 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -64,8 +64,7 @@ TESTS = \ noinst_DATA += $(TESTS) # https://www.redhat.com/archives/libguestfs/2011-May/thread.html#00015 -t/%: $(srcdir)/t/%.cmo mlhivex.cma - mkdir -p t +t/%: t/%.cmo mlhivex.cma $(LIBTOOL) --mode=execute -dlopen $(top_builddir)/lib/libhivex.la \ $(OCAMLFIND) ocamlc -dllpath $(abs_builddir) -package unix \ -linkpkg mlhivex.cma $< -o $@ @@ -73,6 +72,7 @@ t/%: $(srcdir)/t/%.cmo mlhivex.cma .mli.cmi: $(OCAMLFIND) ocamlc -package unix -c $< -o $@ .ml.cmo: + mkdir -p `dirname $@` $(OCAMLFIND) ocamlc -package unix -c $< -o $@ .ml.cmx: $(OCAMLFIND) ocamlopt -package unix -c $< -o $@ @@ -89,7 +89,7 @@ include .depend SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly # Do the installation by hand, because we want to run ocamlfind. -install_files = META *.so *.a *.cma *.cmi *.mli +install_files = META *.so *.a *.cma *.cmi $(srcdir)/*.mli if HAVE_OCAMLOPT install_files += *.cmx *.cmxa
On Fri, Aug 12, 2011 at 01:33:39AM +0200, Hilko Bengen wrote:
This patch hopefully fixes building and installing the OCaml bindings both in-tree and out-of-tree.
Thanks. I also checked that in- and out-of-tree builds and installs work. Pushing shortly .. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
participants (3)
-
Alex Nelson -
Hilko Bengen -
Richard W.M. Jones