1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
|
#! /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=${LABLTK_DEFS}
tk_libs=${LABLTK_LIBS}
tk_x11=no
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;;
-tk-x11|--tk-x11)
tk_x11=yes;;
-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 "x$MAKE" = x; then
MAKE=make
fi
if test $tk_x11 = no; then
has_tk=true
# May still need to read headers
if test -z "$tk_defs"; then
tk_x11_include="-I/usr/local/include"
fi
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=//'`
tk_x11_include=`$MAKE where=$where includes -f readconf.mk`
tk_x11_libs=`$MAKE where=$where libs -f readconf.mk`
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 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/X11/include" \
"-I/usr/local/include/tcl9.0 -I/usr/local/include/tk9.0" \
"-I/usr/include/tcl9.0 -I/usr/include/tk9.0" \
"-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 $tk_x11_include"
tcl_version=`sh ./runtest $tk_defs 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
9.0) tclmaj=9 tclmin=0 tkmaj=9 tkmin=0 ;;
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=""
case "$tk_defs" 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" ;;
-I/usr/X11/include*) tklibdir="/usr/X11/lib" ;;
esac
if test -n "$tklibdir"; then
case "$system" in
*bsd*) tk_libs="-R$tklibdir -L$tklibdir" ;;
*) tk_libs="-L$tklibdir" ;;
esac
else
tk_libs=""
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" "/usr/lib";
do
if test $has_tk = false &&
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
echo "TK_DEFS=$tk_defs" >> Makefile
if test $tk_x11 = yes; then
echo "TK_LINK=$tk_libs $tk_x11_libs" >> Makefile
else
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"
inf " use ocamlfind ............ $use_findlib"
else
inf "The \"labltk\" library: not supported"
fi
|