1
dnl autoconf macros for OCaml
3
dnl modified by Richard W.M. Jones
4
dnl from a configure.in by Jean-Christophe Filli�tre,
5
dnl from a first script by Georges Mariano
7
dnl defines AC_PROG_OCAML that will check the OCaml compiler
8
dnl and set the following variables :
9
dnl OCAMLC "ocamlc" if present in the path, or a failure
10
dnl or "ocamlc.opt" if present with same version number as ocamlc
11
dnl OCAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or "no"
12
dnl OCAMLBEST either "byte" if no native compiler was found,
13
dnl or "opt" otherwise
14
dnl OCAMLDEP "ocamldep"
15
dnl OCAMLLIB the path to the ocaml standard library
16
dnl OCAMLVERSION the ocaml version number
17
AC_DEFUN(AC_PROG_OCAML,
20
AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,AC_MSG_ERROR(Cannot find ocamlc.))
21
OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
22
AC_MSG_RESULT(OCaml version is $OCAMLVERSION)
23
OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
24
AC_MSG_RESULT(OCaml library path is $OCAMLLIB)
25
# checking for ocamlopt
26
AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt)
28
if test -z "$OCAMLOPT"; 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.)
39
# checking for ocamlc.opt
40
AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt)
41
if test -z "$OCAMLCDOTOPT"; then
42
TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
43
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
44
AC_MSG_RESULT(versions differs from ocamlc; ocamlc.opt discarded.)
49
# checking for ocamlopt.opt
50
if test "$OCAMLOPT" ; then
51
AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt)
52
if test "$OCAMLOPTDOTOPT"; then
53
TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
54
if test "$TMPVER" != "$OCAMLVERSION" ; then
55
AC_MSG_RESULT(version differs from ocamlc; ocamlopt.opt discarded.)
57
OCAMLOPT=$OCAMLOPTDOTOPT
61
# checking for ocamldep
62
AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,AC_MSG_ERROR(Cannot find ocamldep.))
64
#checking for ocamlmktop
65
AC_CHECK_PROG(OCAMLMKTOP,ocamlmktop,ocamlmktop, AC_MSG_WARN(Cannot find ocamlmktop.))
66
#checking for ocamlmklib
67
AC_CHECK_PROG(OCAMLMKLIB,ocamlmklib,ocamlmklib, AC_MSG_WARN(Cannot find ocamlmklib.))
68
# checking for ocamldoc
69
AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc, AC_MSG_WARN(Cannot find ocamldoc.))
76
AC_SUBST(OCAMLVERSION)
83
dnl macro AC_PROG_OCAML_TOOLS will check OCamllex and OCamlyacc :
84
dnl OCAMLLEX "ocamllex" or "ocamllex.opt" if present
85
dnl OCAMLYACC "ocamlyac"
86
AC_DEFUN(AC_PROG_OCAML_TOOLS,
88
# checking for ocamllex and ocamlyacc
89
AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex)
90
if test "$OCAMLLEX"; then
91
AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt)
92
if test "$OCAMLLEXDOTOPT"; then
93
OCAMLLEX=$OCAMLLEXDOTOPT
96
AC_MSG_ERROR(Cannot find ocamllex.)
98
AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,AC_MSG_ERROR(Cannot find ocamlyacc.))
104
dnl AC_PROG_CAMLP4 checks for Camlp4
105
AC_DEFUN(AC_PROG_CAMLP4,
107
AC_REQUIRE([AC_PROG_OCAML])
108
# checking for camlp4
109
AC_CHECK_PROG(CAMLP4,camlp4,camlp4)
110
if test "$CAMLP4"; then
111
TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
112
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
113
AC_MSG_RESULT(versions differs from ocamlc)
119
dnl macro AC_PROG_FINDLIB will check for the presence of
121
AC_DEFUN(AC_PROG_FINDLIB,
123
# checking for ocamlfind
124
AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind,
125
AC_MSG_WARN([ocamlfind not found]))
130
dnl AC_CHECK_OCAML_PKG checks wether a findlib package is present
131
dnl defines pkg_name to "yes"
132
AC_DEFUN(AC_CHECK_OCAML_PKG,
134
AC_REQUIRE([AC_PROG_FINDLIB])
135
AC_MSG_CHECKING(findlib package $1)
136
if $OCAMLFIND query $1 >/dev/null 2>/dev/null; then
138
eval "pkg_`echo $1 | tr - _`=yes"
140
AC_MSG_RESULT(not found)
141
eval "pkg_`echo $1 | tr - _`=no"
146
dnl AC_CHECK_OCAML_MODULE looks for a module in a given path
147
dnl 1st arg -> name (just for printing messages)
148
dnl 2nd arg -> env var name (set to include path, or "no" if not found)
149
dnl 3rd arg -> module to check
150
dnl 4th arg -> default include dirs to check
151
AC_DEFUN([AC_CHECK_OCAML_MODULE],
153
AC_MSG_CHECKING(for module $1)
154
cat > conftest.ml <<EOF
158
for $2 in $$2 $4 ; do
159
if $OCAMLC -c -I "$$2" conftest.ml >&5 2>&5 ; then
164
if test "$found" ; then
167
AC_MSG_RESULT(not found)