configure 10.4 KB
Newer Older
gerd's avatar
gerd committed
1 2
#! /bin/sh

3
# $Id$
gerd's avatar
gerd committed
4 5

# defaults:
6
with_lex=1
gerd's avatar
gerd committed
7
with_wlex=1
8
with_wlex_compat=1
9
with_ulex=1
gerd's avatar
gerd committed
10
with_pp=1
11
lexlist="utf8,iso88591,iso88592,iso88593,iso88594,iso88595,iso88596,iso88597,iso88598,iso88599,iso885910,iso885913,iso885914,iso885915,iso885916"
gerd's avatar
gerd committed
12
version="1.2.0test2"
gerd's avatar
gerd committed
13 14
exec_suffix=""

15 16 17
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"
18
help_ulex="Enable/disable ulex-based lexical analyzer for UTF-8"
gerd's avatar
gerd committed
19
help_pp="Enable/disable the build of the preprocessor (pxp-pp)"
gerd's avatar
gerd committed
20

gerd's avatar
gerd committed
21
options="lex wlex wlex_compat ulex pp"
22
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"
gerd's avatar
gerd committed
23

24
print_options () {
gerd's avatar
gerd committed
25 26 27 28 29 30 31 32 33 34
	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
35
	printf '    -lexlist %s\n' "$lexlist"
gerd's avatar
gerd committed
36 37 38 39
}


usage () {
40 41 42 43 44 45 46 47 48 49 50
    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

gerd's avatar
gerd committed
51 52 53 54 55 56 57 58 59 60 61 62 63
	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
64 65 66 67
-lexlist <comma-separated-list-of-encodings>:
  Supported encodings are:
    $formatted_lexlist
    all: selects all of them
gerd's avatar
gerd committed
68 69 70 71

Defaults are:

_EOF_
72
	print_options >&2
gerd's avatar
gerd committed
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
	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
			;;
102 103 104 105 106 107 108 109 110
	        -lexlist)
		        if [ "$2" = "all" ]; then
			    lexlist="$lexlist_options"
			else
			    lexlist="$2"
			fi
			shift
			shift
			;;
gerd's avatar
gerd committed
111 112 113 114
		-version*)
			echo "$version"
			exit 0
			;;
gerd's avatar
gerd committed
115 116 117 118 119 120 121 122
		*)
			usage
	esac
done

######################################################################
# Check ocamlfind

123
printf "%s" "Checking for ocamlfind... "
gerd's avatar
gerd committed
124 125 126 127 128 129 130 131 132 133
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

gerd's avatar
gerd committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
######################################################################
# 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


156 157 158 159 160 161 162 163 164 165 166 167 168 169
######################################################################
# 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

gerd's avatar
gerd committed
170 171 172
######################################################################
# Check netstring

173
printf "%s" "Checking for netstring... "
gerd's avatar
gerd committed
174 175 176 177 178 179 180 181 182 183 184 185
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

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
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

gerd's avatar
gerd committed
208
if [ $with_wlex -gt 0 ]; then
209
	printf "%s" "Checking for wlexing... "
gerd's avatar
gerd committed
210
	if ocamlfind query wlexing >/dev/null 2>/dev/null; then
211 212 213 214 215 216 217 218 219 220 221 222
		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
gerd's avatar
gerd committed
223 224 225 226
	else
		echo "not found"
		echo "wlex support is disabled"
		with_wlex=0
gerd's avatar
gerd committed
227
		with_wlex_compat=0
gerd's avatar
gerd committed
228 229 230
	fi
fi

231 232 233 234 235 236 237 238 239 240 241 242 243 244
######################################################################
# 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

gerd's avatar
gerd committed
245 246 247 248 249 250
# If ulex not found/disabled, also disable pxp-pp:

if [ $with_ulex -eq 0 ]; then
    with_pp=0
fi

251

gerd's avatar
gerd committed
252 253 254 255 256 257 258 259 260
######################################################################
# 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;;
261
let _ = lb.lex_curr_p;;
gerd's avatar
gerd committed
262 263 264 265 266 267 268 269 270 271 272 273
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.*

gerd's avatar
gerd committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287
######################################################################
# 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"
gerd's avatar
gerd committed
288
    camlp4_loc="-ppopt -DOCAML_NEW_LOC"
gerd's avatar
gerd committed
289 290 291 292
fi

rm -f tmp.*

gerd's avatar
gerd committed
293

gerd's avatar
gerd committed
294 295 296
######################################################################
# Check cygwin

297
printf "%s" "Checking for cygwin... "
gerd's avatar
gerd committed
298 299 300 301 302 303 304 305 306
u=`uname`
case "$u" in
	CYGWIN*)
		echo "found"
		exec_suffix=".exe"
		;;
	*)
		echo "not found"
		;;
307
esac
gerd's avatar
gerd committed
308 309 310 311 312 313

######################################################################
# Summary

echo
echo "Effective options:"
314
print_options
gerd's avatar
gerd committed
315 316 317
echo

pkglist="pxp pxp-engine"
gerd's avatar
gerd committed
318 319 320 321

if [ $with_pp -gt 0 ]; then
    pkglist="$pkglist pxp-pp"
fi
322 323 324 325 326 327 328 329 330 331

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":
gerd's avatar
gerd committed
332
reqall="pxp-engine"
333
for lexname in $lexlist; do
334 335 336 337 338 339 340 341
    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
342 343 344 345 346
	reqall="$reqall pxp-lex-$lexname"
    fi
    genpkglist="$genpkglist pxp-lex-$lexname"
done

347
if [ $with_wlex -gt 0 -a $with_ulex -eq 0 ]; then
348
    reqall="$reqall pxp-wlex-utf8"
349 350 351 352 353 354
fi
if [ $with_ulex -gt 0 ]; then
    reqall="$reqall pxp-ulex-utf8"
fi

if [ $with_wlex -gt 0 ]; then
355 356 357 358 359 360 361
    genpkglist="$genpkglist pxp-wlex-utf8"
fi

if [ $with_wlex_compat -gt 0 ]; then
    genpkglist="$genpkglist pxp-wlex"
fi

362 363 364 365
if [ $with_ulex -gt 0 ]; then
    genpkglist="$genpkglist pxp-ulex-utf8"
fi

366 367
for lexname in $lexlist_options; do
    allgenpkglist="$allgenpkglist pxp-lex-$lexname"
gerd's avatar
gerd committed
368 369
done

370 371
allgenpkglist="$allgenpkglist pxp-wlex pxp-wlex-utf8"

gerd's avatar
gerd committed
372
######################################################################
373
# Write META for pkglist
gerd's avatar
gerd committed
374 375 376 377 378 379 380 381

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

382 383 384 385 386 387 388
######################################################################
# 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"
389
	touch "gensrc/$pkg/gen_dir"
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
	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

417 418 419 420 421 422 423 424 425 426 427
######################################################################
# 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

gerd's avatar
gerd committed
428 429 430 431 432 433 434
######################################################################
# Write Makefile.conf

echo "Writing Makefile.conf"
cat <<_EOF_ >Makefile.conf
VERSION = $version
PKGLIST = $pkglist
435 436
GENPKGLIST = $genpkglist
ALLGENPKGLIST = $allgenpkglist
gerd's avatar
gerd committed
437
EXEC_SUFFIX = $exec_suffix
gerd's avatar
gerd committed
438
LEXBUF_307 = $lexbuf_307
439
LEX_OPT = $lex_opt
gerd's avatar
gerd committed
440
CAMLP4_LOC = $camlp4_loc
gerd's avatar
gerd committed
441 442
CAMLP4_STYLE = $camlp4_style
CAMLP4_OPTS = $camlp4_opts
gerd's avatar
gerd committed
443 444 445 446 447
_EOF_

######################################################################
# Finish

448
echo
gerd's avatar
gerd committed
449 450 451 452 453 454 455 456
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."