#! /bin/sh ######################################################################### # # # OCaml # # # # Xavier Leroy, projet Cristal, INRIA Rocquencourt # # # # Copyright 1999 Institut National de Recherche en Informatique et # # en Automatique. All rights reserved. This file is distributed # # under the terms of the GNU Library General Public License, with # # the special exception on linking described in file LICENSE. # # # ######################################################################### configure_options="$*" where='' installbindir='' installdir='' tk_defs='' tk_libs='' tk_x11=yes use_findlib=no verbose=no optcomps=no # The inf(), wrn(), err() functions below can be used to provide a consistent # way to notify the user. The notification is always given to the stdout # descriptor. inf() { printf "%b\n" "$*" 1>&3 } wrn() { printf "[WARNING] %b\n" "$*" 1>&3 } err() { printf "[ERROR!]%b\n" "$*" 1>&3 exit 2 } exec 3>&1 # Parse command-line arguments if echo "$configure_options" | grep -q -e '--\?[a-zA-Z0-9-]\+='; then err "Arguments to this script look like '-libdir /foo/bar', not '-libdir=/foo/bar' (note the '=')." fi while : ; do case "$1" in "") break;; -installbindir|--installbindir) installbindir=$2; shift;; -installdir|--installdir) installdir=$2; shift;; -libdir|--libdir) where=$2; shift;; -tkdefs*|--tkdefs*) tk_defs=$2; shift;; -tklibs*|--tklibs*) tk_libs=$2; shift;; -tk-no-x11|--tk-no-x11) tk_x11=no;; -use-findlib|--use-findlib) use_findlib=yes;; -verbose|--verbose) verbose=yes;; *) err "Unknown option \"$1\".";; esac shift done export verbose # Where to install if test -n "$where"; then : elif test $use_findlib = yes; then where=`ocamlfind printconf stdlib` else where=`ocamlc -where 2> /dev/null || echo '/usr/local/lib/ocaml'` fi if test -n "$installdir" ; then : elif test "$use_findlib" = yes; then installdir="`ocamlfind printconf destdir`/labltk" else installdir='$(LIBDIR)/labltk' fi if test -z "$installbindir"; then installbindir='$(BINDIR)' fi # Sanity checks case "$where" in /*) ;; *) err "The ocaml library directory must be absolute.";; esac case "$installdir" in /*|'$'*) ;; *) err "The installation directory must be absolute.";; esac case "$installbindir" in /*|'$'*) ;; *) err "The binary installation directory must be absolute.";; esac # Generate the files cd config/auto-aux rm -f Makefile touch Makefile # Write options to Makefile echo "# generated by ./configure $configure_options" >> Makefile # Include OCaml configuration echo "include $where/Makefile.config" >> Makefile # Where to install echo "USE_FINDLIB=$use_findlib" >> Makefile echo "INSTALLDIR=$installdir" >> Makefile echo "INSTALLBINDIR=$installbindir" >> Makefile # Which compiler to use ocamlc_where=`ocamlc -where 2> /dev/null` ocamlc_ver=`ocamlc -version 2> /dev/null` ocamlc_opt_ver=`ocamlc.opt -version 2> /dev/null` ocamlopt_ver=`$ocamlopt -version 2> /dev/null` ocamlopt_opt_ver=`$ocamlopt.opt -version 2> /dev/null` if test x"$where" = x"$ocamlc_where" \ && test -n "$ocamlc_opt_ver" && test x"$ocamlc_opt_ver" = x"$ocamlc_ver" \ && (test -z "$ocamlopt_ver" || test x"$ocamlopt_ver" = x"$ocamlopt_opt_ver") then optcomps=yes echo "OPT=.opt" >> Makefile else echo "OPT=" >> Makefile fi # Look for tcl/tk inf "Configuring LablTk..." if test $tk_x11 = no; then has_tk=true else tk_x11_include=`cat $where/Makefile.config | grep '^X11_INCLUDES=' | sed -e 's/^X11_INCLUDES=//'` tk_x11_libs=`cat $where/Makefile.config | grep '^X11_LIBS=' | sed -e 's/^X11_LIBS=//'` has_tk=true fi cc=`cat $where/Makefile.config | grep '^CC=' | sed -e 's/^CC=//'` cclibs=`cat $where/Makefile.config | grep '^NATIVECCLIBS=' | sed -e 's/^NATIVECCLIBS=//'` export cc cclibs if test $has_tk = true; then tcl_version='' tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` for tk_incs in \ "-I/usr/local/include" \ "-I/opt/local/include" \ "-I/sw/include" \ "-I/usr/pkg/include" \ "-I/usr/include" \ "-I/usr/local/include/tcl8.6 -I/usr/local/include/tk8.6" \ "-I/usr/include/tcl8.6 -I/usr/include/tk8.6" \ "-I/usr/local/include/tcl8.5 -I/usr/local/include/tk8.5" \ "-I/usr/include/tcl8.5 -I/usr/include/tk8.5" \ "-I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4" \ "-I/usr/include/tcl8.4 -I/usr/include/tk8.4" \ "-I/usr/local/include/tcl8.3 -I/usr/local/include/tk8.3" \ "-I/usr/include/tcl8.3 -I/usr/include/tk8.3" \ "-I/usr/local/include/tcl8.2 -I/usr/local/include/tk8.2" \ "-I/usr/include/tcl8.2 -I/usr/include/tk8.2" do if test -z "$tcl_version"; then tk_defs="$tk_incs" tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` fi; done if test -n "$tcl_version" && test "x$tcl_version" != "xnone"; then inf "tcl.h and tk.h version $tcl_version found with \"$tk_defs\"." case $tcl_version in 8.6) tclmaj=8 tclmin=6 tkmaj=8 tkmin=6 ;; 8.5) tclmaj=8 tclmin=5 tkmaj=8 tkmin=5 ;; 8.4) tclmaj=8 tclmin=4 tkmaj=8 tkmin=4 ;; 8.3) tclmaj=8 tclmin=3 tkmaj=8 tkmin=3 ;; 8.2) tclmaj=8 tclmin=2 tkmaj=8 tkmin=2 ;; 8.1) tclmaj=8 tclmin=1 tkmaj=8 tkmin=1 ;; 8.0) tclmaj=8 tclmin=0 tkmaj=8 tkmin=0 ;; 7.6) tclmaj=7 tclmin=6 tkmaj=4 tkmin=2 ;; 7.5) tclmaj=7 tclmin=5 tkmaj=4 tkmin=1 ;; *) wrn "This version is not known." ; has_tk=false ;; esac else inf "tcl.h and/or tk.h not found." has_tk=false fi fi system=`cat $where/Makefile.config | grep '^SYSTEM=' | sed -e 's/^SYSTEM=//'` if test $has_tk = true && test -z "$tk_libs"; then tklibdir="" if test -n "$tk_defs"; then tkinclude="$tk_defs" else tkinclude="$tk_x11_include" fi case "$tkinclude" in -I/opt/local/include*) tklibdir="/opt/local/lib" ;; -I/usr/local/include*) tklibdir="/usr/local/lib" ;; -I/sw/include*) tklibdir="/sw/lib" ;; -I/usr/pkg/include*) tklibdir="/usr/pkg/lib" ;; esac if test -n "$tklibdir"; then case "$system" in *bsd*) tk_libs="-R$tklibdir -L$tklibdir" ;; *) tk_libs="-L$tklibdir" ;; esac else tk fi fi tkauxlibs="$cclibs" if test $has_tk = true; then if test -n "$tk_libs" && \ sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tcl_DoOneEvent then tk_libs="$tk_libs $dllib" elif sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent then tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib" elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent then tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib" elif test -z "$tk_libs" && tk_libs=-L/usr/local/lib && \ sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent then tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib" elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent then tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib" else inf "Tcl library not found." has_tk=false fi fi if test $has_tk = true; then if sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then inf "Tcl/Tk libraries found." else has_tk=false for tklibdir in "/usr/local/lib" "/opt/local/lib" "/sw/lib" "/usr/pkg/lib"; do if test $found = no && sh ./hasgot -L$tklibdir $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid then has_tk=true case "$system" in *bsd*) tk_libs="-R$tklibdir -L$tklibdir $tk_libs";; *) tk_libs="-L$tklibdir $tk_libs";; esac fi done if test $has_tk = true; then inf "Tcl/Tk libraries found." else inf "Tcl library found." wrn "Tk library not found." fi fi fi if test $has_tk = true; then if test $tk_x11 = yes; then echo "TK_DEFS=$tk_defs "'$(X11_INCLUDES)' >> Makefile echo "TK_LINK=$tk_libs "'$(X11_LINK)' >> Makefile else echo "TK_DEFS=$tk_defs" >> Makefile echo "TK_LINK=$tk_libs" >> Makefile fi otherlibraries="$otherlibraries labltk" else echo "TK_DEFS=" >> Makefile echo "TK_LINK=" >> Makefile fi mv Makefile .. # Print a summary inf inf "** Configuration summary **" inf if test $has_tk = true; then inf "Configuration for the \"labltk\" library:" inf " use tcl/tk version ....... $tcl_version" inf " options for compiling .... $tk_defs $tk_x11_include" inf " options for linking ...... $tk_libs $tk_x11_libs" inf " use native compilers ..... $optcomps" else inf "The \"labltk\" library: not supported" fi