# $Id: configure 38 2015-04-07 12:50:18Z gerd $ ####################################################################### # 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_FOO=XXX # with_FOO=XXX : } ocamlc=`get_path ocamlc` set_defaults version="1.8.1" exec_suffix="" ####################################################################### # Option parsing #ehelp_FOO="XXX" #whelp_FOO="XXX" # Which options exist? eoptions for enable/disable, woptions for with/without: eoptions="" woptions="" # Packages to include anyway: requires="" 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 for opt in $woptions; 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 () { 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 for opt in $woptions; do e="help=\$whelp_$opt" eval "$e" uopt=`echo $opt | sed -e 's/_/-/g'` echo "-with-$uopt:" >&2 echo "-without-$uopt:" >&2 echo " $help" >&2 done } while [ "$#" -gt 0 ]; do case "$1" in -enable-*) opt=`echo "$1" | sed -e 's/-enable-//' -e 's/-/_/g'` check_eopt "$opt" eval "enable_$opt=2" shift ;; -disable-*) opt=`echo "$1" | sed -e 's/-disable-//' -e 's/-/_/g'` check_eopt "$opt" eval "enable_$opt=-1" shift ;; -with-*) opt=`echo "$1" | sed -e 's/-with-//' -e 's/-/_/g'` check_wopt "$opt" eval "with_$opt=2" shift ;; -without-*) opt=`echo "$1" | sed -e 's/-without-//' -e 's/-/_/g'` check_wopt "$opt" eval "with_$opt=-1" shift ;; -version) echo "$version" exit 0 ;; *) usage esac done echo "Welcome to Xstrp4 version $version" >&2 ###################################################################### # Check ocamlfind printf "%s" "Checking for findlib... " if ocamlfind query stdlib >/dev/null 2>/dev/null; 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" echo "ERROR" exit 1 fi ###################################################################### # Check camlp4 version printf "%s" "Checking for camlp4... " if camlp4; then if camlp4 -loaded-modules >/dev/null 2>/dev/null; then echo "3.10 style" camlp4_style="310" camlp4_opts="-package camlp4 -syntax camlp4o -ppopt pa_extend.cmo -ppopt q_MLast.cmo" else echo "3.09 style" echo "This is no longer supported. Upgrade to at least O'Caml 3.10" echo "ERROR" exit 1 fi else echo "not found" echo "Make sure the camlp4 command is in your PATH" echo "ERROR" exit 1 fi ###################################################################### # Write Makefile.conf echo "Writing Makefile.conf" cat <<_EOF_ >Makefile.conf # The Xstrp4 version: VERSION = $version # Camlp4 style: CAMLP4_STYLE = $camlp4_style # Camlp4 options: CAMLP4_OPTS = $camlp4_opts _EOF_ ###################################################################### # Finish echo echo "Please check Makefile.conf." echo echo "You can now compile Xstrp4 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(s)."