Skip to content

When ocamlfind is there (and not unplugged), use it to call ocaml tools during compilation #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 40 additions & 31 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,40 @@ checkcmxalib()
return $r
}


# check required programs
# check required program

searchbinreq $ocaml
searchbinreq $ocamlc
searchbinreq $ocamldep
searchbinreq $ocamlmklib
if searchbin $ocamldoc; then
ocamldoc=''

# rely on ocamlfind or not

searchbin ocamlfind
if test $? -eq 1 && test $ocamlfind != "no"; then
# set installation method
instmeth='findlib'
if test "$installdir" = "auto"
then installdir="$(ocamlfind printconf destdir | tr -d '\r')"; fi

# use wrapper to call compilers
ocamlc='ocamlfind ocamlc'
ocamlopt='ocamlfind opt'
ocamlmklib='ocamlfind ocamlmklib'
ocamldep='ocamlfind ocamldep'
ocamldoc='ocamlfind ocamldoc'
else
# set installation method
searchbin install
if test $? -eq 1; then instmeth='install'
else echo "no installation method found"; exit 2; fi
if test "$installdir" = "auto"; then installdir="$ocamllibdir"; fi

# check required tools
searchbinreq $ocamlc
searchbinreq $ocamldep
searchbinreq $ocamlmklib
fi

if $ocamldoc -version >/dev/null 2>/dev/null; then
ocamldoc=''
fi

if test -n "$CC"; then
Expand All @@ -208,7 +233,7 @@ else
ccopt="-O3 -Wall -Wextra $CFLAGS"
fi

case "$("$ocamlc" -config | tr -d '\r' | sed -ne '/^system:/s/.*: //p')" in
case "$($ocamlc -config | tr -d '\r' | sed -ne '/^system:/s/.*: //p')" in
win32|win64)
# MSVC
objsuffix='obj'
Expand Down Expand Up @@ -236,8 +261,7 @@ esac

hasocamlopt='no'

searchbin $ocamlopt
if test $? -eq 1; then hasocamlopt='yes'; fi
if $ocamlopt -version >/dev/null 2>/dev/null; then hasocamlopt='yes'; fi


# check C compiler
Expand All @@ -254,7 +278,7 @@ fi
# directories

if test "$ocamllibdir" = "auto"
then ocamllibdir="$(ocamlc -where | tr -d '\r')"
then ocamllibdir="$($ocamlc -where | tr -d '\r')"
fi

if test ! -f "$ocamllibdir/caml/mlvalues.h"
Expand All @@ -275,37 +299,22 @@ then
fi


# installation method

searchbin ocamlfind
if test $? -eq 1 && test $ocamlfind != "no"; then
instmeth='findlib'
if test "$installdir" = "auto"
then installdir="$(ocamlfind printconf destdir | tr -d '\r')"; fi
else
searchbin install
if test $? -eq 1; then instmeth='install'
else echo "no installation method found"; exit 2; fi
if test "$installdir" = "auto"; then installdir="$ocamllibdir"; fi
fi


# detect OCaml's word-size

echo "print_int (Sys.word_size);;" > tmp.ml
wordsize="$(ocaml tmp.ml)"
wordsize="$($ocaml tmp.ml)"
echo "OCaml's word size is $wordsize"
rm -f tmp.ml


# check GMP, MPIR

if test "$gmp" = 'gmp' || test "$gmp" = 'auto'; then
if pkg-config gmp 2>/dev/null; then
if ${prefixnonocaml}pkg-config gmp 2>/dev/null; then
echo 'package gmp: found'
gmp='OK'
cclib="$cclib $(pkg-config --libs gmp)"
ccinc="$ccinc $(pkg-config --cflags gmp)"
cclib="$cclib $(${prefixnonocaml}pkg-config --libs gmp)"
ccinc="$ccinc $(${prefixnonocaml}pkg-config --cflags gmp)"
ccdef="-DHAS_GMP $ccdef"
else
checkinc gmp.h
Expand Down Expand Up @@ -335,7 +344,7 @@ if test "$gmp" != 'OK'; then echo "cannot find GMP nor MPIR"; exit 2; fi

# OCaml version

ocamlver="$(ocamlc -version)"
ocamlver="$($ocamlc -version)"

# OCaml version 4.07 or later is required

Expand Down
Loading