mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
Fix out-of-tree builds of OCaml components
- Add $(srcdir), $(builddir) to Makefiles where required - Post-process ocamldep output - generate ocaml/.depends
This commit is contained in:
committed by
Hilko Bengen
parent
bb9636acac
commit
802c5d2055
@@ -142,11 +142,12 @@ bin_PROGRAMS += virt-builder virt-builder-repository
|
|||||||
|
|
||||||
virt_builder_SOURCES = $(SOURCES_C)
|
virt_builder_SOURCES = $(SOURCES_C)
|
||||||
virt_builder_CPPFLAGS = \
|
virt_builder_CPPFLAGS = \
|
||||||
-I. \
|
-I$(builddir) -I$(srcdir) \
|
||||||
-I$(top_builddir) \
|
-I$(top_builddir) \
|
||||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||||
-I$(shell $(OCAMLC) -where) \
|
-I$(shell $(OCAMLC) -where) \
|
||||||
-I$(top_srcdir)/gnulib/lib \
|
-I$(top_srcdir)/gnulib/lib \
|
||||||
|
-I$(top_builddir)/common/utils \
|
||||||
-I$(top_srcdir)/common/utils \
|
-I$(top_srcdir)/common/utils \
|
||||||
-I$(top_srcdir)/lib
|
-I$(top_srcdir)/lib
|
||||||
virt_builder_CFLAGS = \
|
virt_builder_CFLAGS = \
|
||||||
@@ -163,7 +164,7 @@ XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
|||||||
|
|
||||||
virt_builder_repository_SOURCES = $(REPOSITORY_SOURCES_C)
|
virt_builder_repository_SOURCES = $(REPOSITORY_SOURCES_C)
|
||||||
virt_builder_repository_CPPFLAGS = \
|
virt_builder_repository_CPPFLAGS = \
|
||||||
-I. \
|
-I$(builddir) -I$(srcdir) \
|
||||||
-I$(top_builddir) \
|
-I$(top_builddir) \
|
||||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||||
-I$(shell $(OCAMLC) -where) \
|
-I$(shell $(OCAMLC) -where) \
|
||||||
@@ -446,7 +447,7 @@ CLEANFILES += \
|
|||||||
console-*.out
|
console-*.out
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.mli *.ml osinfo_config.mli osinfo_config.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml osinfo_config.mli osinfo_config.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ mlgettext.cmxa: $(XOBJECTS)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ check-valgrind:
|
|||||||
$(MAKE) VG="@VG@" check
|
$(MAKE) VG="@VG@" check
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ $(MLPROGRESS_CMA): $(OBJECTS) libmlprogress.a
|
|||||||
-o mlprogress
|
-o mlprogress
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ check-valgrind:
|
|||||||
$(MAKE) VG="@VG@" check
|
$(MAKE) VG="@VG@" check
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ check-valgrind:
|
|||||||
$(MAKE) VG="@VG@" check
|
$(MAKE) VG="@VG@" check
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ c_utils_unit_tests_LINK = \
|
|||||||
$(c_utils_unit_tests_THEOBJECTS) -o $@
|
$(c_utils_unit_tests_THEOBJECTS) -o $@
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ check-valgrind:
|
|||||||
$(MAKE) VG="@VG@" check
|
$(MAKE) VG="@VG@" check
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ $(MLXML_CMA): $(OBJECTS) libmlxml.a
|
|||||||
-o mlxml
|
-o mlxml
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ CLEANFILES += \
|
|||||||
settings-*.img
|
settings-*.img
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -339,11 +339,11 @@ XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
|||||||
|
|
||||||
OCAMLPACKAGES = \
|
OCAMLPACKAGES = \
|
||||||
-package str,unix,hivex \
|
-package str,unix,hivex \
|
||||||
-I $(top_srcdir)/common/mlaugeas \
|
-I $(top_builddir)/common/mlaugeas \
|
||||||
-I $(top_srcdir)/common/mlstdutils \
|
-I $(top_builddir)/common/mlstdutils \
|
||||||
-I $(top_srcdir)/common/mlutils \
|
-I $(top_builddir)/common/mlutils \
|
||||||
-I $(top_builddir)/common/utils/.libs \
|
-I $(top_builddir)/common/utils/.libs \
|
||||||
-I $(top_srcdir)/common/mlpcre \
|
-I $(top_builddir)/common/mlpcre \
|
||||||
-I $(top_builddir)/common/mlpcre/.libs \
|
-I $(top_builddir)/common/mlpcre/.libs \
|
||||||
-I $(top_builddir)/gnulib/lib/.libs
|
-I $(top_builddir)/gnulib/lib/.libs
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ camldaemon.o: $(OBJECTS)
|
|||||||
$(OBJECTS)
|
$(OBJECTS)
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ generator: $(objects)
|
|||||||
$^ -o $@
|
$^ -o $@
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ stamp-virt-get-kernel.pod: virt-get-kernel.pod
|
|||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.ml *.mli
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,12 @@ ocaml
|
|||||||
# Output file is always created in the current directory.
|
# Output file is always created in the current directory.
|
||||||
output=.depend
|
output=.depend
|
||||||
|
|
||||||
includes=""
|
subdir=$(realpath --relative-to=@abs_top_builddir@ .)
|
||||||
|
srcdir=$(realpath --relative-to=. @abs_top_srcdir@/${subdir})
|
||||||
|
srcdir_re=$(realpath --relative-to=. @abs_top_srcdir@/${subdir} | sed 's/\./[.]/g')
|
||||||
|
top_builddir=$(realpath --relative-to=. @abs_top_builddir@)
|
||||||
|
|
||||||
|
includes="-I @abs_top_srcdir@/$subdir -I @abs_top_builddir@/$subdir"
|
||||||
for i in $include_dirs; do
|
for i in $include_dirs; do
|
||||||
includes="$includes -I @abs_top_srcdir@/$i -I @abs_top_builddir@/$i"
|
includes="$includes -I @abs_top_srcdir@/$i -I @abs_top_builddir@/$i"
|
||||||
done
|
done
|
||||||
@@ -58,7 +63,22 @@ rm -f $output $output-t
|
|||||||
|
|
||||||
echo "# OCaml dependencies generated by $0" > $output-t
|
echo "# OCaml dependencies generated by $0" > $output-t
|
||||||
echo >> $output-t
|
echo >> $output-t
|
||||||
@OCAMLFIND@ ocamldep @OCAMLDEP_ALL@ @OCAMLDEP_ONE_LINE@ $includes "$@" >> $output-t
|
|
||||||
|
# Rewrite paths
|
||||||
|
# 1. Normalize absolute srcdir to relative path
|
||||||
|
# 2. Object files (*.cm*, *.o), in srcdir: Rewrite to builddir
|
||||||
|
# 3. Generated _config.ml in srcdir: Rewrite to builddir
|
||||||
|
# 4. Other object files below abs_top_srcdir: rewrite to corresponding builddir
|
||||||
|
# 5. Eliminate "./" prefix
|
||||||
|
@OCAMLFIND@ ocamldep @OCAMLDEP_ALL@ @OCAMLDEP_ONE_LINE@ $includes "$@" \
|
||||||
|
| sed \
|
||||||
|
-e "s,@abs_top_srcdir@/${subdir},.,g" \
|
||||||
|
-e "s,\B${srcdir_re}/\\([^ ]*[.]\\)\\(cm[^ ]*\\|o\\),\\1\\2,g" \
|
||||||
|
-e "s,\B${srcdir_re}/\\([^ /]*_config[.]ml\\),\\1,g" \
|
||||||
|
-e "s,@abs_top_srcdir@/\\([^ ]*[.]\\)\\(cm[^ ]*\\|o\\),${top_builddir}/\\1\\2,g" \
|
||||||
|
-e 's,\(^\| \)./,\1,g' \
|
||||||
|
>> $output-t
|
||||||
|
|
||||||
chmod -w $output-t
|
chmod -w $output-t
|
||||||
|
|
||||||
mv $output-t $output
|
mv $output-t $output
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ generator_built = \
|
|||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
$(generator_built) \
|
$(generator_built) \
|
||||||
.depend \
|
|
||||||
guestfs-c.c guestfs-c.h \
|
guestfs-c.c guestfs-c.h \
|
||||||
html/.gitignore \
|
html/.gitignore \
|
||||||
META.in \
|
META.in \
|
||||||
@@ -171,7 +170,7 @@ check-valgrind:
|
|||||||
$(MAKE) VG="@VG@" TESTS="$(test_progs_all)" check
|
$(MAKE) VG="@VG@" TESTS="$(test_progs_all)" check
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ check-valgrind:
|
|||||||
$(MAKE) VG="@VG@" check
|
$(MAKE) VG="@VG@" check
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.ml *.mli
|
.depend: $(srcdir)/*.ml $(srcdir)/*.mli
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ check-valgrind:
|
|||||||
$(MAKE) VG="@VG@" check
|
$(MAKE) VG="@VG@" check
|
||||||
|
|
||||||
# OCaml dependencies.
|
# OCaml dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -79,12 +79,12 @@ guestfs_am_v_jar = $(guestfs_am_v_jar_@AM_V@)
|
|||||||
guestfs_am_v_jar_ = $(guestfs_am_v_jar_@AM_DEFAULT_V@)
|
guestfs_am_v_jar_ = $(guestfs_am_v_jar_@AM_DEFAULT_V@)
|
||||||
guestfs_am_v_jar_0 = @echo " JAR " $@;
|
guestfs_am_v_jar_0 = @echo " JAR " $@;
|
||||||
|
|
||||||
%.cmi: %.mli
|
%.cmi: $(srcdir)/%.mli
|
||||||
$(guestfs_am_v_ocamlcmi)$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
$(guestfs_am_v_ocamlcmi)$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
||||||
%.cmo: %.ml
|
%.cmo: $(srcdir)/%.ml
|
||||||
$(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
$(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
||||||
if HAVE_OCAMLOPT
|
if HAVE_OCAMLOPT
|
||||||
%.cmx: %.ml
|
%.cmx: $(srcdir)/%.ml
|
||||||
$(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
$(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ v2v_unit_tests_LINK = \
|
|||||||
$(v2v_unit_tests_THEOBJECTS) -o $@
|
$(v2v_unit_tests_THEOBJECTS) -o $@
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh $^
|
$(top_builddir)/ocaml-dep.sh $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ stamp-virt-v2v-test-harness.pod: virt-v2v-test-harness.pod
|
|||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
# Dependencies.
|
# Dependencies.
|
||||||
.depend: *.mli *.ml
|
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||||
$(top_builddir)/ocaml-dep.sh -I .. $^
|
$(top_builddir)/ocaml-dep.sh -I .. $^
|
||||||
-include .depend
|
-include .depend
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user