Skip to content

Commit

Permalink
Use ocaml-autoconf macros
Browse files Browse the repository at this point in the history
  • Loading branch information
kerneis committed Jun 17, 2013
1 parent 38c51e9 commit 5f164d1
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 127 deletions.
15 changes: 5 additions & 10 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,10 @@ configure: configure.in aclocal.m4



ifndef CAMLNATTL
ifeq (@HAS_OCAML_NATIVE_TOOLS@, 1)
CAMLNATTL := 1
endif
endif

ifndef MINGW
MINGW=@MINGW@
endif

ifndef FLEXLINK
FLEXLINK=@FLEXLINK@
endif

ifndef EMUL
EMUL=@EMUL@
endif
Expand Down Expand Up @@ -113,6 +103,11 @@ BEFOREDEPS += $(OBJDIR)/cilversion.ml
BEFOREDEPS += $(OBJDIR)/feature_config.ml

# Include now the common set of rules for OCAML
CAMLLEX = @OCAMLLEX@
CAMLDEP = @OCAMLDEP@
CAMLCMPLR = @OCAMLC@
CAMLCMPLR_OPT = @OCAMLOPT@
CAMLYACC = @OCAMLYACC@ -v
include ocamlutil/Makefile.ocaml

OBEXEEXT = $(EXEEXT:asm=native)
Expand Down
1 change: 1 addition & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
# PARTICULAR PURPOSE.

m4_include([m4/cil.m4])
m4_include([m4/ocaml.m4])
110 changes: 16 additions & 94 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ CIL_VERSION_MINOR=7
CIL_VERSION_REV=0
CIL_VERSION=$CIL_VERSION_MAJOR.$CIL_VERSION_MINOR.$CIL_VERSION_REV

# Assume at first that no native versions of OCaml tools are available
HAS_OCAML_NATIVE_TOOLS=0


# make sure I haven't forgotten to run autoconf
if test configure -ot configure.in; then
AC_MSG_ERROR(configure is older than configure.in; you forgot to run autoconf)
Expand Down Expand Up @@ -110,98 +106,25 @@ else
fi
fi

# is ocaml available?
# needed binaries: ocamllex ocamlyacc ocamldep ocamlopt ocamlc
ocamlDownloadInstructions="
OCaml can be downloaded from http://caml.inria.fr/ocaml/.
After downloading and unpacking the source distribution, in the ocaml
directory, do
./configure
make world
make opt
make install
Then come back here and re-run ./configure."

# required major/minor.
# required major/minor
reqMaj=3
reqMin=08
knownMaj=4
knownMin=00
AC_MSG_CHECKING(ocaml version is at least $reqMaj.$reqMin)
if binaryExists ocamlc; then
# what version?
ver=`ocamlc -v | grep version | sed 's/^.*version //'`
diagnostic "ver is $ver"
# major: anything before the .
major=`echo $ver | sed 's/\..*$//'`
diagnostic "major is $major"
# minor: numbers after the .
# (the outer level of bracket-quotation protects the inner brackets)
[minor=`echo $ver | sed 's/^[^.]*\.\([0-9][0-9]*\).*$/\1/'`]
diagnostic "minor is $minor"

# I would think autoconf would already have a facility for doing
# these kinds of major/minor version checks, but I can't find it
if test $major -gt $reqMaj -o $major -ge $reqMaj -a $minor -ge $reqMin; then
AC_MSG_RESULT([version is $ver, ok])

# sm: added this test when we found that CCured needed to be changed
# a little when 3.06 came out (it had previously worked with 3.04)
if test "$major" -gt $knownMaj -o "$major" -ge $knownMaj -a "$minor" -gt $knownMin; then
AC_MSG_WARN([Your ocaml version is $ver, but the latest version this program
is known to work with is $knownMaj.$knownMin. If you have
trouble compiling, please try using an earlier version
or see if there is a later version of this program.])
fi
else
AC_MSG_ERROR([
I found OCaml version $ver; this program requires at least $reqMaj.$reqMin.
Please download a newer OCaml distribution.
$ocamlDownloadInstructions
])
fi
# Testing OCaml availability
AC_PROG_OCAML
if test "$OCAMLC" = "no"; then
AC_MSG_ERROR([You must install the OCaml compiler])
fi

# check for existence of other binaries
AC_MSG_CHECKING(existence of related ocaml tools)
if binaryExists ocamllex && \
binaryExists ocamlyacc && \
binaryExists ocamldep && \
binaryExists ocamlopt; then
AC_MSG_RESULT(ok)
else
AC_MSG_ERROR([
At least one of ocamllex, ocamlyacc, ocamldep or ocamlopt is missing.
In particular, ocamlopt requires you to "make opt" when building
OCaml from source. Please make sure all these tools are built and
in the path.
])
fi
AC_PROG_OCAMLLEX
if test "$OCAMLLEX" = "no"; then
AC_MSG_ERROR([You must install ocamllex])
fi

# check if native versions of OCaml tools are available
AC_MSG_CHECKING(availability of native ocaml tools versions)
if binaryExists ocamlc.opt && \
binaryExists ocamllex.opt && \
binaryExists ocamldep.opt && \
binaryExists ocamlopt.opt; then
veropt=`ocamlc.opt -v | grep version | sed 's/^.*version //'`
if [[ "$ver" == "$veropt" ]]; then
AC_MSG_RESULT(ok)
HAS_OCAML_NATIVE_TOOLS=1
else
AC_MSG_RESULT([no, version mismatch: $veropt])
fi
else
AC_MSG_RESULT(no)
fi
else
AC_MSG_ERROR([
The "ocamlc" OCaml compiler was not found in the path: $PATH.
AC_PROG_OCAMLYACC
if test "$OCAMLYACC" = "no"; then
AC_MSG_ERROR([You must install ocamlyacc])
fi

Most of this program is written in the OCaml language, so its compiler
is required.
$ocamlDownloadInstructions
])
AC_PROG_FINDLIB
if test "$OCAMLFIND" = "no"; then
AC_MSG_ERROR([You must install OCaml findlib (the ocamlfind command)])
fi

#
Expand Down Expand Up @@ -560,7 +483,6 @@ AC_SUBST(THREAD_IS_KEYWORD)
AC_SUBST(UNDERSCORE_NAME)
AC_SUBST(EXTRAFEATURES)
AC_SUBST(EXTRASRCDIRS)
AC_SUBST(HAS_OCAML_NATIVE_TOOLS)

# finish the configure script and generate various files; ./configure
# will apply variable substitutions to <filename>.in to generate <filename>;
Expand Down
Loading

0 comments on commit 5f164d1

Please sign in to comment.