Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: release-0.3
Fetching contributors…

Cannot retrieve contributors at this time

executable file 310 lines (256 sloc) 6.71 kb
#! /bin/sh
# adapted from ocamlnet's configure
#######################################################################
# Helpers:
# Split $PATH into words:
oldifs="$IFS"
IFS=" :"
spacepath=`echo $PATH`
IFS="$oldifs"
in_path () {
# Does $1 exist in $PATH?
for d in $spacepath; do
if test -x "$d/$1"; then
return 0
fi
done
return 1
}
get_path () {
for d in $spacepath; do
if test -x "$d/$1"; then
echo "$d/$1"
return
fi
done
}
#######################################################################
# Defaults
#--- Options ---
# value 0: off
# value 1: on
# defaults:
set_defaults () {
enable_ocamljs=1
enable_ssl=0
enable_type_conv=1
bindir=`dirname $ocamlc`
libdir=`ocamlc -where`
}
ocamlc=`get_path ocamlc`
set_defaults
version="0.3"
exec_suffix=""
#######################################################################
# Option parsing
ehelp_ocamljs="Enable/disable parts that depend on ocamljs"
ehelp_ssl="Enable/disable parts that depend on ocaml-ssl"
ehelp_type_conv="Enable/disable parts that depend on type-conv"
# Which options exist? eoptions for enable/disable, woptions for with/without:
eoptions="ocamljs ssl type_conv"
# Packages to include anyway:
requires="unix,equeue,rpc"
check_library () {
# $1: the name of the library (findlib)
ocamlfind query "$1" >/dev/null 2>/dev/null
return
return 1 # not found
}
check_libraryjs () {
# $1: the name of the library (findlib)
ocamlfindjs query "$1" >/dev/null 2>/dev/null
return
return 1 # not found
}
print_options () {
for opt in $eoptions; do
e="o=\$enable_$opt"
eval "$e"
uopt=`echo $opt | sed -e 's/_/-/g'`
if [ $o -gt 0 ]; then
echo " -enable-$uopt"
else
echo " -disable-$uopt"
fi
done
echo " -bindir $bindir"
echo " -libdir $libdir"
}
usage () {
set_defaults
cat <<_EOF_ >&2
usage: ./configure [ options ]
_EOF_
for opt in $eoptions; do
e="help=\$ehelp_$opt"
eval "$e"
uopt=`echo $opt | sed -e 's/_/-/g'`
echo "-enable-$uopt:" >&2
echo "-disable-$uopt:" >&2
echo " $help" >&2
done
cat <<_EOF_ >&2
-bindir dir
Install binaries into this directory
-libdir dir
Install libraries into this directory (default same as ocamlc -where)
Defaults are:
_EOF_
print_options >&2
exit 1
}
check_eopt () {
for x in $eoptions; do
if [ "$x" = "$1" ]; then
return 0
fi
done
echo "Unknown option: $1" >&2
exit 1
}
echo "Welcome to orpc version $version" >&2
while [ "$#" -gt 0 ]; do
case "$1" in
-enable-*)
opt=`echo "$1" | sed -e 's/-enable-//' -e 's/-/_/g'`
check_eopt "$opt"
eval "enable_$opt=1"
shift
;;
-disable-*)
opt=`echo "$1" | sed -e 's/-disable-//' -e 's/-/_/g'`
check_eopt "$opt"
eval "enable_$opt=0"
shift
;;
-bindir)
bindir="$2"
shift
shift
;;
-libdir)
libdir="$2"
shift
shift
;;
-version)
echo "$version"
exit 0
;;
*)
usage
esac
done
######################################################################
# Check ocamlfind
printf "%s" "Checking for findlib... "
if check_library stdlib; then
echo "found"
else
echo "not found"
echo "Make sure that ocamlfind is in your PATH, or download findlib"
echo "from www.ocaml-programming.de"
exit 1
fi
######################################################################
# Check that rpc is available:
printf "%s" "Checking for rpc... "
if check_library rpc; then
echo "found"
else
echo "not found"
echo "Sorry, installation is not possible without Ocamlnet rpc."
echo "Get Ocamlnet from:"
echo "http://projects.camlcity.org/projects/ocamlnet.html"
exit 1
fi
######################################################################
# Check that ocamljs is available:
if [ $enable_ocamljs -gt 0 ]; then
printf "%s" "Checking for ocamljs... "
if check_libraryjs ocamljs; then
echo "found"
else
echo "not found"
echo "Ocamljs is required for -enable-ocamljs."
echo "Try -disable-ocamljs, or get ocamljs from:"
echo "http://code.google.com/p/ocamljs/"
exit 1
fi
printf "%s" "Checking for nethttpd... "
if check_library nethttpd; then
echo "found"
else
echo "not found"
echo "Required library nethttpd not found!"
echo "Make sure Ocamlnet is configured -with-nethttpd."
exit 1
fi
fi
######################################################################
# Check that ocaml-ssl is available:
if [ $enable_ssl -gt 0 ]; then
printf "%s" "Checking for ocaml-ssl... "
if check_library ssl; then
echo "found"
else
echo "not found"
echo "ocaml-ssl is required for -enable-ssl."
echo "Try -disable-ssl, or get ocaml-ssl from:"
echo "http://savonet.sourceforge.net/"
exit 1
fi
fi
######################################################################
# Check that type-conv is available:
if [ $enable_type_conv -gt 0 ]; then
printf "%s" "Checking for type-conv... "
if check_library "type-conv"; then
echo "found"
else
echo "not found"
echo "type-conv is required for -enable-type_conv."
echo "Try -disable-type_conv, or get type-conv from:"
echo "http://www.ocaml.info/home/ocaml_sources.html#type-conv"
exit 1
fi
fi
######################################################################
# Summary
echo
echo "Effective options:"
print_options
echo
pkglist="generator orpc orpc-onc lwt-equeue"
if [ $enable_ocamljs -gt 0 ]; then
pkglist="$pkglist orpc-js-client orpc-js-server"
fi
######################################################################
# Write Makefile.conf
echo "Writing Makefile.conf"
cat <<_EOF_ >Makefile.conf
# Makefile.conf written by configure
# The orpc version
VERSION = $version
# The packages to build in the right order:
PKGLIST = $pkglist
# Required packages (findlib):
REQUIRES = $requires
# Where binaries are installed:
BINDIR = $bindir
# Where libraries are installed:
LIBDIR = $libdir
ENABLE_OCAMLJS = $enable_ocamljs
ENABLE_SSL = $enable_ssl
ENABLE_TYPE_CONV = $enable_type_conv
_EOF_
######################################################################
# Finish
echo
echo "Please check Makefile.conf."
echo
echo "You can now compile orpc by invoking"
echo " make all"
echo "Finally, a"
echo " make install"
echo "will install the package(s)."
Jump to Line
Something went wrong with that request. Please try again.