[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

autoconf macros for OCaml



Hi,

here are two macros which can be useful to check for an installed
OCaml library:

AC_DEFUN([AC_OCAML_CHECK_LIB],
[AC_MSG_CHECKING(for $2 (bytecode)); \
 if $OCAMLC -o foo.exe $COMPFLAGS $2.cma 2> /dev/null ||  $OCAMLC -o foo.exe $COMPFLAGS $2.cmo 2>/dev/null; then\
  AC_MSG_RESULT yes; $1=$3 ;\
 else 
  AC_MSG_RESULT no; $1=$4;\
fi
])

AC_DEFUN([AC_OCAML_CHECK_LIBOPT],
[AC_MSG_CHECKING(for $2 (native)); \
 if $OCAMLOPT -o foo.exe $COMPFLAGS $2.cmxa 2> /dev/null ||  $OCAMLOPT -o foo.exe $COMPFLAGS $2.cmx 2>/dev/null; then\
  AC_MSG_RESULT yes; $1=$3 ;\
 else 
  AC_MSG_RESULT no; $1=$4;\
fi
])

They can be used this way:
AC_OCAML_CHECK(variable,libname,value-if-installed,value-if-not-installed)

And an example of usage:

AC_OCAML_CHECK_LIB(CRYPTOKIT,cryptokit,yes,no)
AC_OCAML_CHECK_LIBOPT(CRYPTOKITOPT,cryptokit,yes,no)

if test "$CRYPTOKIT" = no ; then ...

This is just a first attempt for this kind of macros. I'm not familiar
with M4 macros.

Friendly,

Maxence



Reply to: