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 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
|
#! /bin/sh
# $Id$
# defaults:
with_lex=1
with_wlex=1
with_wlex_compat=1
with_ulex=1
with_pp=1
lexlist="utf8,iso88591,iso88592,iso88593,iso88594,iso88595,iso88596,iso88597,iso88598,iso88599,iso885910,iso885913,iso885914,iso885915,iso885916"
version="1.2.9"
exec_suffix=""
help_lex="Enable/disable ocamllex-based lexical analyzer for the -lexlist encodings"
help_wlex="Enable/disable wlex-based lexical analyzer for UTF-8"
help_wlex_compat="Enable/disable wlex-style compatibility package for UTF-8 and ISO-8859-1"
help_ulex="Enable/disable ulex-based lexical analyzer for UTF-8"
help_pp="Enable/disable the build of the preprocessor (pxp-pp)"
options="lex wlex wlex_compat ulex pp"
lexlist_options="utf8 usascii iso88591 iso88592 iso88593 iso88594 iso88595 iso88596 iso88597 iso88598 iso88599 iso885910 iso885913 iso885914 iso885915 iso885916 koi8r windows1250 windows1251 windows1252 windows1253 windows1254 windows1255 windows1256 windows1257 windows1258 cp437 cp737 cp775 cp850 cp852 cp855 cp856 cp857 cp860 cp861 cp862 cp863 cp864 cp865 cp866 cp869 cp874 cp1006 macroman"
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
printf ' -lexlist %s\n' "$lexlist"
}
usage () {
formatted_lexlist=""
n=0
for lexname in $lexlist_options; do
formatted_lexlist=`printf '%s%-12s' "$formatted_lexlist" $lexname`
n=`expr $n + 1`
if [ $n -eq 5 ]; then
n=0
formatted_lexlist=`printf '%s\n ' "$formatted_lexlist"`
fi
done
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
-lexlist <comma-separated-list-of-encodings>:
Supported encodings are:
$formatted_lexlist
all: selects all of them
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
;;
-enable-*)
opt=`echo "$1" | sed -e 's/-enable-//' -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
;;
-disable-*)
opt=`echo "$1" | sed -e 's/-disable-//' -e 's/-/_/g'`
check_opt "$opt"
eval "with_$opt=0"
shift
;;
-lexlist)
if [ "$2" = "all" ]; then
lexlist="$lexlist_options"
else
lexlist="$2"
fi
shift
shift
;;
-prefix|--prefix)
echo "[prefix ignored]"; shift 2 ;;
--prefix=)
echo "[prefix ignored]"; shift ;;
-destdir|--destdir)
echo "[destdir ignored]"; shift 2 ;;
--destdir=)
echo "[destdir ignored]"; 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 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"
camlp4_style="309"
camlp4_opts="-package camlp4 -syntax camlp4o -ppopt pa_extend.cmo -ppopt q_MLast.cmo -ppopt -loc -ppopt loc"
fi
else
echo "not found"
echo "Make sure the camlp4 command is in your PATH"
exit 1
fi
######################################################################
# Check ocamllex.opt
printf "%s" "Checking for ocamllex.opt..."
r=`ocamllex.opt -help 2>&1`
lex_opt=""
case "$r" in
*usage*)
echo "found"
lex_opt=".opt" ;;
*)
echo "not found" ;;
esac
######################################################################
# 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
printf "%s" "Checking for netunidata... "
if ocamlfind query netunidata >/dev/null 2>/dev/null; then
echo "found"
netunidata="netunidata"
else
echo "not found"
netunidata=""
fi
######################################################################
# Check wlex
if [ $with_wlex_compat -gt 0 ]; then
if [ $with_wlex -eq 0 ]; then
echo "WARNING! -with-wlex-compat implies -with-wlex"
with_wlex=1
fi
if [ $with_lex -eq 0 ]; then
echo "WARNING! -with-wlex-compat implies -with-lex for ISO-8859-1"
with_lex=1
lexlist="iso88591"
fi
if grep iso88591 >/dev/null 2>/dev/null <<EOF
$lexlist
EOF
then :
else
echo "WARNING! -with-wlex-compat implies -lexlist iso88591"
lexlist="$lexlist,iso88591"
fi
fi
if [ $with_wlex -gt 0 ]; then
printf "%s" "Checking for wlexing... "
if ocamlfind query wlexing >/dev/null 2>/dev/null; then
printf "%s" "library found, "
out=`wlex -help 2>&1`
case "$out" in
usage*) echo "generator found" ;;
*)
echo "generator not found"
echo "*** It is now required that the full 'wlex' tool is installed, sorry."
echo "wlex support is disabled"
with_wlex=0
with_wlex_compat=0 ;;
esac
else
echo "not found"
echo "wlex support is disabled"
with_wlex=0
with_wlex_compat=0
fi
fi
######################################################################
# ulex
if [ $with_ulex -gt 0 ]; then
printf "%s" "Checking for ulex... "
if ocamlfind query ulex >/dev/null 2>/dev/null; then
echo "found"
else
echo "not found"
echo "ulex support is disabled"
with_ulex=0
fi
fi
# If ulex not found/disabled, also disable pxp-pp:
if [ $with_ulex -eq 0 ]; then
with_pp=0
fi
######################################################################
# Check Lexing.lexbuf type
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.*
######################################################################
# Check type of camlp4 locations
printf "%s" "Checking type of camlp4 location... "
cat <<EOF >tmp.ml
open Stdpp;;
raise_with_loc (0,0) Not_found;;
EOF
if ocamlc -c -I +camlp4 tmp.ml >/dev/null 2>/dev/null; then
echo "old style"
camlp4_loc=""
else
echo "new style"
camlp4_loc="-ppopt -DOCAML_NEW_LOC"
fi
rm -f tmp.*
######################################################################
# immutable strings
printf "%s" "Checking for -safe-string... "
string_opts=""
if ocamlc -safe-string; then
echo "yes"
string_opts="-safe-string"
else
echo "no"
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"
if [ $with_pp -gt 0 ]; then
pkglist="$pkglist pxp-pp"
fi
genpkglist=""
# Generated packages
allgenpkglist=""
# Package names that can possibly be generated
lexlist=`echo "$lexlist" | sed -e 's/,/ /g'`
# reqall: the predecessor list for package "pxp":
reqall="pxp-engine"
for lexname in $lexlist; do
include=1
if [ "$lexname" = "utf8" ]; then
if [ $with_wlex -gt 0 -o $with_ulex -gt 0 ]; then
# Leave UTF-8 out
include=0
fi
fi
if [ $include -gt 0 ]; then
reqall="$reqall pxp-lex-$lexname"
fi
genpkglist="$genpkglist pxp-lex-$lexname"
done
if [ $with_wlex -gt 0 -a $with_ulex -eq 0 ]; then
reqall="$reqall pxp-wlex-utf8"
fi
if [ $with_ulex -gt 0 ]; then
reqall="$reqall pxp-ulex-utf8"
fi
if [ $with_wlex -gt 0 ]; then
genpkglist="$genpkglist pxp-wlex-utf8"
fi
if [ $with_wlex_compat -gt 0 ]; then
genpkglist="$genpkglist pxp-wlex"
fi
if [ $with_ulex -gt 0 ]; then
genpkglist="$genpkglist pxp-ulex-utf8"
fi
for lexname in $lexlist_options; do
allgenpkglist="$allgenpkglist pxp-lex-$lexname"
done
allgenpkglist="$allgenpkglist pxp-wlex pxp-wlex-utf8"
######################################################################
# Write META for pkglist
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 META and Makefile for lexlist
for enc in $lexlist; do
pkg="pxp-lex-$enc"
echo "Writing gensrc/$pkg/META and Makefile"
mkdir -p "gensrc/$pkg"
touch "gensrc/$pkg/gen_dir"
sed -e "s/@VERSION@/$version/g" \
-e "s/@ENCNAME@/$enc/g" \
gensrc/pxp-lex-pattern/META.in >gensrc/$pkg/META
echo "# THIS IS A GENERATED FILE - DO NOT EDIT MANUALLY!" >gensrc/$pkg/Makefile
sed -e "s/@ENCNAME@/$enc/g" \
gensrc/pxp-lex-pattern/Makefile.in >>gensrc/$pkg/Makefile
done
######################################################################
# Write META for wlex
if [ $with_wlex -gt 0 ]; then
pkg="pxp-wlex-utf8"
echo "Writing gensrc/$pkg/META"
sed -e "s/@VERSION@/$version/g" \
-e "s/@ENCNAME@/$enc/g" \
gensrc/$pkg/META.in >gensrc/$pkg/META
fi
if [ $with_wlex_compat -gt 0 ]; then
pkg="pxp-wlex"
echo "Writing gensrc/$pkg/META"
sed -e "s/@VERSION@/$version/g" \
-e "s/@ENCNAME@/$enc/g" \
gensrc/$pkg/META.in >gensrc/$pkg/META
fi
######################################################################
# Write META for ulex
if [ $with_ulex -gt 0 ]; then
pkg="pxp-ulex-utf8"
echo "Writing gensrc/$pkg/META"
sed -e "s/@VERSION@/$version/g" \
-e "s/@ENCNAME@/$enc/g" \
gensrc/$pkg/META.in >gensrc/$pkg/META
fi
######################################################################
# Write Makefile.conf
echo "Writing Makefile.conf"
cat <<_EOF_ >Makefile.conf
VERSION = $version
PKGLIST = $pkglist
GENPKGLIST = $genpkglist
ALLGENPKGLIST = $allgenpkglist
EXEC_SUFFIX = $exec_suffix
LEXBUF_307 = $lexbuf_307
LEX_OPT = $lex_opt
CAMLP4_LOC = $camlp4_loc
CAMLP4_STYLE = $camlp4_style
CAMLP4_OPTS = $camlp4_opts
NETUNIDATA = $netunidata
STRING_OPTS = $string_opts
_EOF_
######################################################################
# make oasis happy: setup.save will be picked up by "make postconf"
# and will be appended to setup.data. That way the config update
# will reach oasis.
rm -f setup.save
echo "pkg_version=\"$version\"" >>setup.save
echo "prefix=\"<not interpreted>\"" >>setup.save
echo "destdir=\"\"" >>setup.save
for opt in $options; do
e="o=\$with_$opt"
eval "$e"
if [ $o -gt 0 ]; then
echo "$opt=\"true\"" >>setup.save
else
echo "$opt=\"false\"" >>setup.save
fi
done
######################################################################
# 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."
|