1 dnl autoconf macros for OCaml
3 dnl Copyright © 2009 Richard W.M. Jones
4 dnl Copyright © 2009 Stefano Zacchiroli
5 dnl Copyright © 2000-2005 Olivier Andrieu
6 dnl Copyright © 2000-2005 Jean-Christophe Filliâtre
7 dnl Copyright © 2000-2005 Georges Mariano
9 dnl For documentation, please read the ocaml.m4 man page.
11 AC_DEFUN([AC_PROG_OCAML],
14 AC_CHECK_TOOL([OCAMLC],[ocamlc],[no])
16 if test "$OCAMLC" != "no"; then
17 OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
18 AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
19 OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
20 AC_MSG_RESULT([OCaml library path is $OCAMLLIB])
22 AC_SUBST([OCAMLVERSION])
25 # checking for ocamlopt
26 AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
28 if test "$OCAMLOPT" = "no"; then
29 AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
31 TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
32 if test "$TMPVERSION" != "$OCAMLVERSION" ; then
33 AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
42 # checking for ocamlc.opt
43 AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
44 if test "$OCAMLCDOTOPT" != "no"; then
45 TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
46 if test "$TMPVERSION" != "$OCAMLVERSION" ; then
47 AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
53 # checking for ocamlopt.opt
54 if test "$OCAMLOPT" != "no" ; then
55 AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
56 if test "$OCAMLOPTDOTOPT" != "no"; then
57 TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
58 if test "$TMPVERSION" != "$OCAMLVERSION" ; then
59 AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
61 OCAMLOPT=$OCAMLOPTDOTOPT
71 # checking for ocamldep
72 AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no])
74 # checking for ocamlmktop
75 AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no])
77 # checking for ocamlmklib
78 AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no])
80 # checking for ocamldoc
81 AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no])
83 # checking for ocamlbuild
84 AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no])
88 AC_DEFUN([AC_PROG_OCAMLLEX],
90 # checking for ocamllex
91 AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no])
92 if test "$OCAMLLEX" != "no"; then
93 AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
94 if test "$OCAMLLEXDOTOPT" != "no"; then
95 OCAMLLEX=$OCAMLLEXDOTOPT
101 AC_DEFUN([AC_PROG_OCAMLYACC],
103 AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no])
104 AC_SUBST([OCAMLYACC])
108 AC_DEFUN([AC_PROG_CAMLP4],
110 AC_REQUIRE([AC_PROG_OCAML])dnl
112 # checking for camlp4
113 AC_CHECK_TOOL([CAMLP4],[camlp4],[no])
114 if test "$CAMLP4" != "no"; then
115 TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
116 if test "$TMPVERSION" != "$OCAMLVERSION" ; then
117 AC_MSG_RESULT([versions differs from ocamlc])
123 # checking for companion tools
124 AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no])
125 AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no])
126 AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no])
127 AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no])
128 AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no])
129 AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no])
130 AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no])
131 AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no])
132 AC_SUBST([CAMLP4BOOT])
135 AC_SUBST([CAMLP4OOF])
136 AC_SUBST([CAMLP4ORF])
137 AC_SUBST([CAMLP4PROF])
143 AC_DEFUN([AC_PROG_FINDLIB],
145 AC_REQUIRE([AC_PROG_OCAML])dnl
147 # checking for ocamlfind
148 AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no])
149 AC_SUBST([OCAMLFIND])
153 dnl Thanks to Jim Meyering for working this next bit out for us.
154 dnl XXX We should define AS_TR_SH if it's not defined already
155 dnl (eg. for old autoconf).
156 AC_DEFUN([AC_CHECK_OCAML_PKG],
158 AC_REQUIRE([AC_PROG_FINDLIB])dnl
160 AC_MSG_CHECKING([for OCaml findlib package $1])
165 for pkg in $1 $2 ; do
166 if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
167 AC_MSG_RESULT([found])
168 AS_TR_SH([OCAML_PKG_$1])=$pkg
173 if test "$found" = "no" ; then
174 AC_MSG_RESULT([not found])
175 AS_TR_SH([OCAML_PKG_$1])=no
178 AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
182 AC_DEFUN([AC_CHECK_OCAML_MODULE],
184 AC_MSG_CHECKING([for OCaml module $2])
186 cat > conftest.ml <<EOF
190 for $1 in $$1 $4 ; do
191 if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then
197 if test "$found" ; then
200 AC_MSG_RESULT([not found])
207 dnl XXX Cross-compiling
208 AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
210 AC_MSG_CHECKING([for OCaml compiler word size])
211 cat > conftest.ml <<EOF
212 print_endline (string_of_int Sys.word_size)
214 OCAML_WORD_SIZE=`ocaml conftest.ml`
215 AC_MSG_RESULT([$OCAML_WORD_SIZE])
216 AC_SUBST([OCAML_WORD_SIZE])