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
(cherry picked from commit 802c5d2055)
This commit is contained in:
committed by
Richard W.M. Jones
parent
2056275f3b
commit
b99825f346
@@ -142,11 +142,12 @@ bin_PROGRAMS += virt-builder virt-builder-repository
|
||||
|
||||
virt_builder_SOURCES = $(SOURCES_C)
|
||||
virt_builder_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(builddir) -I$(srcdir) \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||
-I$(shell $(OCAMLC) -where) \
|
||||
-I$(top_srcdir)/gnulib/lib \
|
||||
-I$(top_builddir)/common/utils \
|
||||
-I$(top_srcdir)/common/utils \
|
||||
-I$(top_srcdir)/lib
|
||||
virt_builder_CFLAGS = \
|
||||
@@ -163,7 +164,7 @@ XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
||||
|
||||
virt_builder_repository_SOURCES = $(REPOSITORY_SOURCES_C)
|
||||
virt_builder_repository_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(builddir) -I$(srcdir) \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||
-I$(shell $(OCAMLC) -where) \
|
||||
@@ -446,7 +447,7 @@ CLEANFILES += \
|
||||
console-*.out
|
||||
|
||||
# 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 $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ mlgettext.cmxa: $(XOBJECTS)
|
||||
endif
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ check-valgrind:
|
||||
$(MAKE) VG="@VG@" check
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ $(MLPROGRESS_CMA): $(OBJECTS) libmlprogress.a
|
||||
-o mlprogress
|
||||
|
||||
# OCaml dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ check-valgrind:
|
||||
$(MAKE) VG="@VG@" check
|
||||
|
||||
# OCaml dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ check-valgrind:
|
||||
$(MAKE) VG="@VG@" check
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ c_utils_unit_tests_LINK = \
|
||||
$(c_utils_unit_tests_THEOBJECTS) -o $@
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ check-valgrind:
|
||||
$(MAKE) VG="@VG@" check
|
||||
|
||||
# OCaml dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ $(MLXML_CMA): $(OBJECTS) libmlxml.a
|
||||
-o mlxml
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ CLEANFILES += \
|
||||
settings-*.img
|
||||
|
||||
# OCaml dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -339,11 +339,11 @@ XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
||||
|
||||
OCAMLPACKAGES = \
|
||||
-package str,unix,hivex \
|
||||
-I $(top_srcdir)/common/mlaugeas \
|
||||
-I $(top_srcdir)/common/mlstdutils \
|
||||
-I $(top_srcdir)/common/mlutils \
|
||||
-I $(top_builddir)/common/mlaugeas \
|
||||
-I $(top_builddir)/common/mlstdutils \
|
||||
-I $(top_builddir)/common/mlutils \
|
||||
-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)/gnulib/lib/.libs
|
||||
|
||||
@@ -377,7 +377,7 @@ camldaemon.o: $(OBJECTS)
|
||||
$(OBJECTS)
|
||||
|
||||
# OCaml dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ generator: $(objects)
|
||||
$^ -o $@
|
||||
|
||||
# OCaml dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ stamp-virt-get-kernel.pod: virt-get-kernel.pod
|
||||
touch $@
|
||||
|
||||
# OCaml dependencies.
|
||||
.depend: *.ml *.mli
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -49,7 +49,12 @@ ocaml
|
||||
# Output file is always created in the current directory.
|
||||
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
|
||||
includes="$includes -I @abs_top_srcdir@/$i -I @abs_top_builddir@/$i"
|
||||
done
|
||||
@@ -58,7 +63,22 @@ rm -f $output $output-t
|
||||
|
||||
echo "# OCaml dependencies generated by $0" > $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
|
||||
|
||||
mv $output-t $output
|
||||
|
||||
@@ -26,7 +26,6 @@ generator_built = \
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(generator_built) \
|
||||
.depend \
|
||||
guestfs-c.c guestfs-c.h \
|
||||
html/.gitignore \
|
||||
META.in \
|
||||
@@ -171,7 +170,7 @@ check-valgrind:
|
||||
$(MAKE) VG="@VG@" TESTS="$(test_progs_all)" check
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ check-valgrind:
|
||||
$(MAKE) VG="@VG@" check
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.ml *.mli
|
||||
.depend: $(srcdir)/*.ml $(srcdir)/*.mli
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ check-valgrind:
|
||||
$(MAKE) VG="@VG@" check
|
||||
|
||||
# OCaml dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-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_0 = @echo " JAR " $@;
|
||||
|
||||
%.cmi: %.mli
|
||||
%.cmi: $(srcdir)/%.mli
|
||||
$(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 $@
|
||||
if HAVE_OCAMLOPT
|
||||
%.cmx: %.ml
|
||||
%.cmx: $(srcdir)/%.ml
|
||||
$(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
||||
endif
|
||||
|
||||
|
||||
@@ -536,7 +536,7 @@ v2v_unit_tests_LINK = \
|
||||
$(v2v_unit_tests_THEOBJECTS) -o $@
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh $^
|
||||
-include .depend
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ stamp-virt-v2v-test-harness.pod: virt-v2v-test-harness.pod
|
||||
touch $@
|
||||
|
||||
# Dependencies.
|
||||
.depend: *.mli *.ml
|
||||
.depend: $(srcdir)/*.mli $(srcdir)/*.ml
|
||||
$(top_builddir)/ocaml-dep.sh -I .. $^
|
||||
-include .depend
|
||||
|
||||
|
||||
Reference in New Issue
Block a user