#! /bin/sh
# $Id: configure,v 1.10.2.1 2003/10/03 21:52:12 gerd Exp $
# defaults:
with_lex_iso88591=1
with_lex_utf8=1
with_wlex=1
version="1.1.6"
exec_suffix=""
help_lex_iso88591="Enable/disable ocamllex-based lexical analyzer for ISO-8859-1"
help_lex_utf8="Enable/disable ocamllex-based lexical analyzer for UTF-8"
help_wlex="Enable/disable wlex-based lexical analyzer for ISO-8859-1 and UTF-8"
options="lex_iso88591 lex_utf8 wlex"
print_options () {
for opt in $options; do
e="o=\$with_$opt"
eval "$e"
uopt=`echo $opt | sed -e 's/_/-/g'`
if [ $o -gt 0 ]; then
echo " -with-$uopt"
else
echo " -without-$uopt"
fi
done
}
usage () {
cat <<_EOF_ >&2
usage: ./configure [ options ]
_EOF_
for opt in $options; do
e="help=\$help_$opt"
eval "$e"
uopt=`echo $opt | sed -e 's/_/-/g'`
echo "-with-$uopt:" >&2
echo "-without-$uopt:" >&2
echo " $help" >&2
done
cat <<_EOF_ >&2
Defaults are:
_EOF_
print_options >&2
exit 1
}
check_opt () {
for x in $options; do
if [ "$x" = "$1" ]; then
return 0
fi
done
echo "Unknown option: $1" >&2
exit 1
}
while [ "$#" -gt 0 ]; do
case "$1" in
-with-*)
opt=`echo "$1" | sed -e 's/-with-//' -e 's/-/_/g'`
check_opt "$opt"
eval "with_$opt=1"
shift
;;
-without-*)
opt=`echo "$1" | sed -e 's/-without-//' -e 's/-/_/g'`
check_opt "$opt"
eval "with_$opt=0"
shift
;;
-version*)
echo "$version"
exit 0
;;
*)
usage
esac
done
######################################################################
# Check ocamlfind
printf "%s" "Checking for ocamlfind... "
if ocamlfind query stdlib >/dev/null 2>/dev/null; then
echo "found"
else
echo "not found"
echo "Sorry, installation is not possible without ocamlfind (findlib)!"
echo "Make sure that ocamlfind is in your PATH, or download findlib"
echo "from www.ocaml-programming.de"
exit 1
fi
######################################################################
# Check netstring
printf "%s" "Checking for netstring... "
if ocamlfind query netstring >/dev/null 2>/dev/null; then
echo "found"
else
echo "not found"
echo "Sorry, installation is not possible without netstring!"
echo "Please download netstring from www.ocaml-programming.de"
exit 1
fi
######################################################################
# Check wlex
if [ $with_wlex -gt 0 ]; then
printf "%s" "Checking for wlexing... "
if ocamlfind query wlexing >/dev/null 2>/dev/null; then
echo "found"
else
echo "not found"
echo "wlex support is disabled"
with_wlex=0
fi
fi
######################################################################
# Check Lexing module
printf "%s" "Checking Lexing.lexbuf type... "
cat <<EOF >tmp.ml
open Lexing
let lb = from_string "";;
let _ = lb.lex_mem;;
let _ = lb.lex_start_p;;
let _ = lb.lex_curr_p;;
EOF
lexbuf_307=""
if ocamlc -c tmp.ml >/dev/null 2>/dev/null; then
echo "new style"
lexbuf_307="-D LEXBUF_307"
else
echo "old style"
fi
rm -f tmp.*
######################################################################
# Pregenerated wlex lexers
if [ $with_wlex -gt 0 ]; then
printf "%s" "Selecting pregenerated wide lexer... "
case `ocamlc -version` in
3.06*)
echo "Using 3.06 version"
suffix="306"
;;
3.07*)
echo "Using 3.07 version"
suffix="307"
;;
*)
echo "No lexer matches"
echo "You need the 'wlex' tool to generate the wide lexer,"
echo "because there is no pregenerated lexer for your"
echo "version of O'Caml."
suffix=""
;;
esac
if [ -n "$suffix" ]; then
s="src-pre/pxp-wlex"
d="src/pxp-wlex"
cp "$s/pxp_wlex.ml.$suffix" "$d/pxp_wlex.ml"
fi
fi
######################################################################
# Check cygwin
printf "%s" "Checking for cygwin... "
u=`uname`
case "$u" in
CYGWIN*)
echo "found"
exec_suffix=".exe"
;;
*)
echo "not found"
;;
esac
######################################################################
# Summary
echo
echo "Effective options:"
print_options
echo
pkglist="pxp pxp-engine"
reqall="pxp-engine"
for opt in $options; do
e="o=\$with_$opt"
eval "$e"
if [ $o -gt 0 ]; then
uopt=`echo "$opt" | sed -e 's/_/-/g'`
pkglist="$pkglist pxp-$uopt"
# Don't include pxp-lex* into reqall if pxp-wlex is available
if [ "$with_wlex" -gt 0 ]; then
case "$opt" in
lex_*)
true ;;
*)
reqall="$reqall pxp-$uopt" ;;
esac
else
reqall="$reqall pxp-$uopt"
fi
fi
done
######################################################################
# Write META.in
for pkg in $pkglist; do
echo "Writing src/$pkg/META"
sed -e "s/@VERSION@/$version/g" \
-e "s/@REQALL@/$reqall/g" \
src/$pkg/META.in >src/$pkg/META
done
######################################################################
# Write Makefile.conf
echo "Writing Makefile.conf"
cat <<_EOF_ >Makefile.conf
VERSION = $version
PKGLIST = $pkglist
EXEC_SUFFIX = $exec_suffix
LEXBUF_307 = $lexbuf_307
_EOF_
######################################################################
# Finish
echo
echo "You can now compile PXP by invoking"
echo " make all"
echo "for the bytecode compiler, and optionally by invoking"
echo " make opt"
echo "for the native-code compiler (if supported on your architecture)."
echo "Finally, a"
echo " make install"
echo "will install the package."