1 dnl autoconf macros for OCaml
3 dnl from a configure.in by Jean-Christophe FilliĆ¢tre,
4 dnl from a first script by Georges Mariano
6 dnl defines AC_PROG_OCAML that will check the OCaml compiler
7 dnl and set the following variables :
8 dnl OCAMLC "ocamlc" if present in the path, or a failure
9 dnl or "ocamlc.opt" if present with same version number as ocamlc
10 dnl OCAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or "no"
11 dnl OCAMLBEST either "byte" if no native compiler was found,
12 dnl or "opt" otherwise
13 dnl OCAMLDEP "ocamldep"
14 dnl OCAMLLIB the path to the ocaml standard library
15 dnl OCAMLVERSION the ocaml version number
16 AC_DEFUN(AC_PROG_OCAML,
19 AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,AC_MSG_ERROR(Cannot find ocamlc.))
20 OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
21 AC_MSG_RESULT(OCaml version is $OCAMLVERSION)
22 OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
23 AC_MSG_RESULT(OCaml library path is $OCAMLLIB)
24 # checking for ocamlopt
25 AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt)
27 if test -z "$OCAMLOPT"; then
28 AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.)
30 TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
31 if test "$TMPVERSION" != "$OCAMLVERSION" ; then
32 AC_MSG_RESULT(versions differs from ocamlc; ocamlopt discarded.)
38 # checking for ocamlc.opt
39 AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt)
40 if test -z "$OCAMLCDOTOPT"; then
41 TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
42 if test "$TMPVERSION" != "$OCAMLVERSION" ; then
43 AC_MSG_RESULT(versions differs from ocamlc; ocamlc.opt discarded.)
48 # checking for ocamlopt.opt
49 if test "$OCAMLOPT" ; then
50 AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt)
51 if test "$OCAMLOPTDOTOPT"; then
52 TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
53 if test "$TMPVER" != "$OCAMLVERSION" ; then
54 AC_MSG_RESULT(version differs from ocamlc; ocamlopt.opt discarded.)
56 OCAMLOPT=$OCAMLOPTDOTOPT
60 # checking for ocamldep
61 AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,AC_MSG_ERROR(Cannot find ocamldep.))
63 #checking for ocamlmktop
64 AC_CHECK_PROG(OCAMLMKTOP,ocamlmktop,ocamlmktop, AC_MSG_WARN(Cannot find ocamlmktop.))
65 #checking for ocamlmklib
66 AC_CHECK_PROG(OCAMLMKLIB,ocamlmklib,ocamlmklib, AC_MSG_WARN(Cannot find ocamlmklib.))
67 # checking for ocamldoc
68 AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc, AC_MSG_WARN(Cannot find ocamldoc.))
75 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.))
105 dnl AC_PROG_CAMLP4 checks for Camlp4
106 AC_DEFUN(AC_PROG_CAMLP4,
108 AC_REQUIRE([AC_PROG_OCAML])
109 # checking for camlp4
110 AC_CHECK_PROG(CAMLP4,camlp4,camlp4)
111 if test "$CAMLP4"; then
112 TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
113 if test "$TMPVERSION" != "$OCAMLVERSION" ; then
114 AC_MSG_RESULT(versions differs from ocamlc)
121 dnl macro AC_PROG_FINDLIB will check for the presence of
122 dnl ocamlfind if configure is called with --with-findlib
123 AC_DEFUN(AC_PROG_FINDLIB,
125 AC_ARG_WITH(findlib,[ --with-findlib use findlib package system],
126 use_findlib="$withval")
127 # checking for ocamlfind
128 if test "$use_findlib" ; then
129 AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind,
130 AC_MSG_ERROR(ocamlfind not found))
139 dnl AC_CHECK_OCAML_PKG checks wether a findlib package is present
140 dnl defines pkg_name to "yes"
141 AC_DEFUN(AC_CHECK_OCAML_PKG,
143 AC_REQUIRE([AC_PROG_FINDLIB])
144 if test "$use_findlib" ; then
145 AC_MSG_CHECKING(findlib package $1)
146 if $OCAMLFIND query $1 >/dev/null 2>/dev/null; then
150 AC_MSG_WARN(not found)
158 dnl AC_ARG_OCAML_INSTALLDIR adds a --with-installdir option
159 AC_DEFUN(AC_ARG_OCAML_INSTALLDIR,
161 AC_ARG_WITH(installdir,[ --with-installdir=DIR specify installation directory],INSTALLDIR="$withval")
162 if test -z "$INSTALLDIR" ; then
163 if test -z "$use_findlib" ; then
164 INSTALLDIR='$(OCAMLLIB)/site-lib/$(NAME)'