These are generated in many different ways in the various
subdirectories, and sometimes not generated correctly.  Introduce a
script to do this in one place, and hopefully correctly.

This is mostly simple refactoring, but I got rid of a couple of
things:

(1) The ‘make depend’ rule doesn't appear to be needed.  automake (or
make?)  seems to rebuild the ‘.depend’ file automatically just because
it is included.

(2) I got rid of the hairy path rewriting sed expression.  Possibly
that is needed for srcdir != builddir.
---
 .gitignore                    |  1 +
 builder/Makefile.am           | 17 +++---------
 common/mlpcre/Makefile.am     | 15 ++--------
 common/mlprogress/Makefile.am | 17 +++---------
 common/mlstdutils/Makefile.am | 17 +++---------
 common/mlutils/Makefile.am    | 15 ++--------
 common/mlvisit/Makefile.am    | 17 +++---------
 common/mlxml/Makefile.am      | 15 ++--------
 configure.ac                  |  2 ++
 customize/Makefile.am         | 17 +++---------
 daemon/Makefile.am            | 15 ++--------
 dib/Makefile.am               | 17 +++---------
 generator/Makefile.am         | 15 ++--------
 get-kernel/Makefile.am        | 17 ++----------
 mllib/Makefile.am             | 15 ++--------
 ocaml-dep.sh.in               | 64 +++++++++++++++++++++++++++++++++++++++++++
 ocaml/Makefile.am             | 13 ++-------
 resize/Makefile.am            | 15 ++--------
 sparsify/Makefile.am          | 17 +++---------
 sysprep/Makefile.am           | 17 +++---------
 v2v/Makefile.am               | 15 ++--------
 v2v/test-harness/Makefile.am  | 15 ++--------
 22 files changed, 131 insertions(+), 237 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0e7a649f8..4d738d10f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -380,6 +380,7 @@ Makefile.in
 /mllib/getopt_tests
 /mllib/JSON_tests
 /mllib/oUnit-*
+/ocaml-dep.sh
 /ocaml/bindtests.bc
 /ocaml/bindtests.opt
 /ocaml/bindtests.ml
diff --git a/builder/Makefile.am b/builder/Makefile.am
index 1b51376be..e1c7bd016 100644
--- a/builder/Makefile.am
+++ b/builder/Makefile.am
@@ -310,23 +310,14 @@ CLEANFILES += \
        console-*.img \
        console-*.out
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I 
$(abs_top_builddir)/common/mlpcre -I $(abs_top_builddir)/mllib -I 
$(abs_top_builddir)/customize $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
 
 # virt-builder's default repository
 
diff --git a/common/mlpcre/Makefile.am b/common/mlpcre/Makefile.am
index aa638cd94..fd4027a1f 100644
--- a/common/mlpcre/Makefile.am
+++ b/common/mlpcre/Makefile.am
@@ -124,19 +124,10 @@ check-valgrind:
        $(MAKE) VG="@VG@" check
 
 # Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../../ocaml -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/common/mlprogress/Makefile.am b/common/mlprogress/Makefile.am
index d4a229451..189aa5453 100644
--- a/common/mlprogress/Makefile.am
+++ b/common/mlprogress/Makefile.am
@@ -92,20 +92,11 @@ $(MLPROGRESS_CMA): $(OBJECTS) libmlprogress.a
            -cclib -lprogress \
            -o mlprogress
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../../ocaml -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/common/mlstdutils/Makefile.am b/common/mlstdutils/Makefile.am
index ccf7c6884..5208e491f 100644
--- a/common/mlstdutils/Makefile.am
+++ b/common/mlstdutils/Makefile.am
@@ -147,18 +147,9 @@ endif
 check-valgrind:
        $(MAKE) VG="@VG@" check
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/common/mlutils/Makefile.am b/common/mlutils/Makefile.am
index f29ffc062..ab92424d5 100644
--- a/common/mlutils/Makefile.am
+++ b/common/mlutils/Makefile.am
@@ -135,17 +135,8 @@ c_utils_unit_tests_LINK = \
          $(c_utils_unit_tests_THEOBJECTS) -o $@
 
 # Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/common/mlvisit/Makefile.am b/common/mlvisit/Makefile.am
index 2019efd75..fcf3bc0be 100644
--- a/common/mlvisit/Makefile.am
+++ b/common/mlvisit/Makefile.am
@@ -134,20 +134,11 @@ endif
 check-valgrind:
        $(MAKE) VG="@VG@" check
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../../ocaml -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/common/mlxml/Makefile.am b/common/mlxml/Makefile.am
index 1a989949f..87d3f67c5 100644
--- a/common/mlxml/Makefile.am
+++ b/common/mlxml/Makefile.am
@@ -89,19 +89,10 @@ $(MLXML_CMA): $(OBJECTS) libmlxml.a
            -o mlxml
 
 # Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/configure.ac b/configure.ac
index 7f9c1dac0..254200cc9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,6 +166,8 @@ AC_CONFIG_FILES([inspector/test-virt-inspector.sh],
                 [chmod +x,-w inspector/test-virt-inspector.sh])
 AC_CONFIG_FILES([installcheck.sh],
                 [chmod +x,-w installcheck.sh])
+AC_CONFIG_FILES([ocaml-dep.sh],
+                [chmod +x,-w ocaml-dep.sh])
 AC_CONFIG_FILES([p2v/virt-p2v-make-disk],
                 [chmod +x,-w p2v/virt-p2v-make-disk])
 AC_CONFIG_FILES([p2v/virt-p2v-make-kickstart],
diff --git a/customize/Makefile.am b/customize/Makefile.am
index f660346f6..9e82039b5 100644
--- a/customize/Makefile.am
+++ b/customize/Makefile.am
@@ -303,20 +303,11 @@ CLEANFILES += \
        password-*.log \
        settings-*.img
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlutils -I $(abs_top_builddir)/mllib $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 63b28f52d..b26c43ed2 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -329,17 +329,8 @@ camldaemon.o: $(OBJECTS)
            $(OBJECTS)
 
 # OCaml dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I 
$(abs_top_builddir)/common/mlpcre $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 # Tests.
@@ -420,4 +411,4 @@ stamp-guestfsd.pod: guestfsd.pod
          $<
        touch $@
 
-.PHONY: depend force
+.PHONY: force
diff --git a/dib/Makefile.am b/dib/Makefile.am
index cc1287b35..d3a40b9b0 100644
--- a/dib/Makefile.am
+++ b/dib/Makefile.am
@@ -142,20 +142,11 @@ stamp-virt-dib.pod: virt-dib.pod
          $<
        touch $@
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I 
$(abs_top_builddir)/mllib $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/generator/Makefile.am b/generator/Makefile.am
index 1936d0898..35b7a4209 100644
--- a/generator/Makefile.am
+++ b/generator/Makefile.am
@@ -182,18 +182,9 @@ generator: $(objects)
            $(OCAMLPACKAGES) -linkpkg mlstdutils.cma \
            $^ -o $@
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml) 
$(wildcard $(abs_srcdir)/common/mlstdutils/*.mli) $(wildcard 
$(abs_srcdir)/common/mlstdutils/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../common/mlstdutils -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 noinst_DATA = stamp-generator
diff --git a/get-kernel/Makefile.am b/get-kernel/Makefile.am
index 6cc7ec2fb..022678a2a 100644
--- a/get-kernel/Makefile.am
+++ b/get-kernel/Makefile.am
@@ -125,20 +125,9 @@ stamp-virt-get-kernel.pod: virt-get-kernel.pod
          $<
        touch $@
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I 
$(abs_top_builddir)/mllib $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
-
-.PHONY: depend
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index 49bd5e7fb..82b9482d9 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
@@ -240,19 +240,10 @@ check-valgrind:
        $(MAKE) VG="@VG@" check
 
 # Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/ocaml-dep.sh.in b/ocaml-dep.sh.in
new file mode 100755
index 000000000..8f48fdb64
--- /dev/null
+++ b/ocaml-dep.sh.in
@@ -0,0 +1,64 @@
+#!/bin/bash -
+# (C) Copyright 2009-2017 Red Hat Inc.
+# @configure_input@
+#
+# 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.
+
+# This is a smarter wrapper around ocamldep(1) which is used to create
+# the .depend files which are present in each subdirectory that builds
+# OCaml code.
+#
+# Usage:
+#   .depend: *.mli *.ml
+#       $(top_builddir)/ocaml-dep.sh $^
+#   -include .depend
+
+set -e
+
+# List of directories that contain common OCaml libraries.  If it
+# contains OCaml code that can be included from another directory,
+# then it should go here.  Note that OCaml modules in these
+# directories must have unique names (eg. not ‘Utils’) else
+# dependencies don't get built right.
+include_dirs="
+common/mlpcre
+common/mlprogress
+common/mlstdutils
+common/mlutils
+common/mlvisit
+common/mlxml
+customize
+mllib
+ocaml
+"
+
+# Output file is always created in the current directory.
+output=.depend
+
+includes=""
+for i in $include_dirs; do
+    includes="$includes -I @abs_top_srcdir@/$i -I @abs_top_builddir@/$i"
+done
+
+rm -f $output $output-t
+
+echo "  OCAMLDEP $output"
+
+@OCAMLFIND@ ocamldep $includes "$@" |
+    @SED@ 's/ *$//' |
+    @SED@ -e :a -e '/ *\\$/N; s/ *\\\n */ /; ta' |
+    sort > $output-t
+
+mv $output-t $output
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index 91be080bf..c6a458a2a 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -185,17 +185,8 @@ guestfs.cmx: guestfs.ml
        $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package 
unix -c $< -o $@
 endif
 
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml) 
$(wildcard $(abs_srcdir)/t/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
diff --git a/resize/Makefile.am b/resize/Makefile.am
index af65acbf5..e39f9da35 100644
--- a/resize/Makefile.am
+++ b/resize/Makefile.am
@@ -137,19 +137,10 @@ check-valgrind:
        $(MAKE) VG="@VG@" check
 
 # Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I 
$(abs_top_builddir)/mllib $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
index c8062f353..5c57e8aa5 100644
--- a/sparsify/Makefile.am
+++ b/sparsify/Makefile.am
@@ -143,20 +143,11 @@ endif ENABLE_APPLIANCE
 check-valgrind:
        $(MAKE) VG="@VG@" check
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I 
$(abs_top_builddir)/mllib $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index f42722453..ee0b3e5dc 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -216,20 +216,11 @@ check-valgrind-local-guests:
          $(top_builddir)/run --test @VG@ virt-sysprep -n -c 
"$(libvirt_ro_uri)" -d "$$g" || exit $$?; \
        done
 
-# Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I 
$(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+# OCaml dependencies.
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index f1f8fb824..7f260e3c0 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -515,19 +515,10 @@ v2v_unit_tests_LINK = \
          $(v2v_unit_tests_THEOBJECTS) -o $@
 
 # Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I 
$(abs_top_builddir)/common/mlxml -I $(abs_top_builddir)/mllib -I 
$(abs_top_builddir)/customize $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh $^
 -include .depend
 
 endif
 
-.PHONY: depend docs
+.PHONY: docs
diff --git a/v2v/test-harness/Makefile.am b/v2v/test-harness/Makefile.am
index bcfcdf21d..8691c57c3 100644
--- a/v2v/test-harness/Makefile.am
+++ b/v2v/test-harness/Makefile.am
@@ -126,20 +126,11 @@ stamp-virt-v2v-test-harness.pod: virt-v2v-test-harness.pod
        touch $@
 
 # Dependencies.
-depend: .depend
-
-.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
-       rm -f $@ $@-t
-       $(OCAMLFIND) ocamldep -I ../../ocaml -I $(abs_srcdir) -I 
$(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlxml -I 
$(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize -I 
$(abs_top_builddir)/v2v $^ | \
-         $(SED) 's/ *$$//' | \
-         $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
-         $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
-         sort > $@-t
-       mv $@-t $@
-
+.depend: *.mli *.ml
+       $(top_builddir)/ocaml-dep.sh -I .. $^
 -include .depend
 
 endif
 endif
 
-.PHONY: depend docs
+.PHONY: docs
-- 
2.13.1

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to