daemon: Find -lcamlstr{nat,byt} and -lunix{nat,byt}, and require -lzstd

OCaml 5.1 changes the names of these libraries for some reason.

Also in OCaml 5.1, if using those libraries you must link with -lzstd.
Since zstd was already described as "required" (although we only used
it in the appliance), there is no official change to the requirements,
but I have added a configure time check for the library.

Thanks: Jerry James <loganjerry@gmail.com>
(cherry picked from commit f8cbd71400)
This commit is contained in:
Richard W.M. Jones
2023-10-06 11:15:55 +01:00
parent 13578ecdba
commit 5c3ca4ec85
3 changed files with 49 additions and 3 deletions

View File

@@ -374,9 +374,11 @@ OCAML_LIBS = \
-lmlstdutils \
-lmlaugeas \
-lmlhivex \
-lcamlstr \
-lunix \
-l$(CAMLRUN) -ldl -lm
-l$(CAMLSTR) \
-l$(CAMLUNIX) \
-l$(CAMLRUN) \
$(LIBZSTD_LIBS) \
-ldl -lm
CLEANFILES += camldaemon.o

View File

@@ -248,6 +248,9 @@ PKG_CHECK_MODULES([PCRE2], [libpcre2-8], [], [
PCRE_LIBS=`$PCRE2_CONFIG --libs8`
])
dnl Check for zstd (required since OCaml 5.1)
PKG_CHECK_MODULES([LIBZSTD], [libzstd])
dnl Check for Augeas >= 1.2.0 (required).
PKG_CHECK_MODULES([AUGEAS],[augeas >= 1.2.0])

View File

@@ -122,6 +122,47 @@ if test "x$enable_daemon" = "xyes"; then
AC_MSG_ERROR([could not find or link to libasmrun or libcamlrun])
fi
AC_SUBST([CAMLRUN])
dnl OCaml 5.1 changed -lcamlstr to -lcamlstrnat / -lcamlstrbyt
dnl and -lunix to -lunixnat / -lunixbyt so we need to detect
dnl the new or old libraries. As above we cannot use AC_CHECK_LIB.
AC_MSG_CHECKING([how to link the daemon with -lcamlstr*])
if test "x$OCAMLOPT" != "xno"; then
choices="camlstrnat camlstr"
else
choices="camlstrbyt camlstr"
fi
for f in $choices; do
if test -f "$OCAMLLIB/lib$f.a"; then
CAMLSTR=$f
break
fi
done
if test "x$CAMLSTR" != "x"; then
AC_MSG_RESULT([$CAMLSTR])
else
AC_MSG_ERROR([could not find or link to -lcamlstr*])
fi
AC_SUBST([CAMLSTR])
AC_MSG_CHECKING([how to link the daemon with -lunix*])
if test "x$OCAMLOPT" != "xno"; then
choices="unixnat unix"
else
choices="unixbyt unix"
fi
for f in $choices; do
if test -f "$OCAMLLIB/lib$f.a"; then
CAMLUNIX=$f
break
fi
done
if test "x$CAMLUNIX" != "x"; then
AC_MSG_RESULT([$CAMLUNIX])
else
AC_MSG_ERROR([could not find or link to -lunix*])
fi
AC_SUBST([CAMLUNIX])
fi
dnl Define HIVEX_OPEN_UNSAFE_FLAG based on test above.