From 9ec726606c5437d853bb75678124b3223848b2ec Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 15 Sep 2017 10:46:12 +0100 Subject: [PATCH] build: Use ocamldep -all and -one-line flags instead of hacking the output. We ran some sed scripts over the output of ocamldep to get them into a single line format. This actually broke the output of ocamldep, combining multiple dependencies into single lines. I didn't debug exactly why our sed rules were broken because modern ocamldep has an option (-one-line) which make this hacking unnecessary. Another useful option (-all) is added so that all dependencies are made explicit. Since old ocamldep in RHEL 6 doesn't support these options, we have to detect them at configure time. The historical reason we were trying to combine entries into a single line was so we could sort them. That was only needed back when we used to commit the dependency files (so the files were stable), but we haven't committed dependency files in a long time. --- m4/guestfs_ocaml.m4 | 20 ++++++++++++++++++++ ocaml-dep.sh.in | 5 +---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/m4/guestfs_ocaml.m4 b/m4/guestfs_ocaml.m4 index e577b313c..e944f363f 100644 --- a/m4/guestfs_ocaml.m4 +++ b/m4/guestfs_ocaml.m4 @@ -56,6 +56,26 @@ AM_CONDITIONAL([HAVE_OCAMLOPT], AM_CONDITIONAL([HAVE_OCAMLDOC], [test "x$OCAMLDOC" != "xno"]) +dnl Check if ocamldep has options -all and -one-line (not present in RHEL 6). +AC_MSG_CHECKING([if ocamldep has the ‘-all’ option]) +if ocamldep -all >&AS_MESSAGE_LOG_FD 2>&1; then + AC_MSG_RESULT([yes]) + OCAMLDEP_ALL="-all" +else + AC_MSG_RESULT([no]) + OCAMLDEP_ALL="" +fi +AC_SUBST([OCAMLDEP_ALL]) +AC_MSG_CHECKING([if ocamldep has the ‘-one-line’ option]) +if ocamldep -one-line >&AS_MESSAGE_LOG_FD 2>&1; then + AC_MSG_RESULT([yes]) + OCAMLDEP_ONE_LINE="-one-line" +else + AC_MSG_RESULT([no]) + OCAMLDEP_ONE_LINE="" +fi +AC_SUBST([OCAMLDEP_ONE_LINE]) + if test "x$enable_daemon" = "xyes"; then OCAML_PKG_hivex=no AC_CHECK_OCAML_PKG(hivex) diff --git a/ocaml-dep.sh.in b/ocaml-dep.sh.in index 61acaf209..ceeb92aa4 100755 --- a/ocaml-dep.sh.in +++ b/ocaml-dep.sh.in @@ -54,9 +54,6 @@ done rm -f $output $output-t -@OCAMLFIND@ ocamldep $includes "$@" | - @SED@ 's/ *$//' | - @SED@ -e :a -e '/ *\\$/N; s/ *\\\n */ /; ta' | - sort > $output-t +@OCAMLFIND@ ocamldep @OCAMLDEP_ALL@ @OCAMLDEP_ONE_LINE@ $includes "$@" > $output-t mv $output-t $output