#! /bin/sh # $Id$ ####################################################################### # 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 set_defaults () { with_cgi=1 with_ajp=0 version="1.2.1" exec_suffix="" requires="netstring,unix,pxp-engine,pxp-lex-iso88591,wdialog,postgresql,netunidata.iso" i_options="" bytelink_options="" natlink_options="" # Remember that the following variables are written into Makefile.conf prefix="/usr/local" wtimer_dir='$(PREFIX)/share/wtimer' wtimerlib_dir='$(PREFIX)/lib/wtimer' bin_dir='$(PREFIX)/bin' sbin_dir='$(PREFIX)/sbin' etc_dir='$(PREFIX)/etc' ui_dir='$(WTIMER_DIR)/ui' cgi_dir='$(WTIMERLIB_DIR)/cgi' static_dir='$(WTIMER_DIR)/static' ddl_dir='$(WTIMER_DIR)/ddl' dbvariant=pg } ####################################################################### # Option parsing options="" print_options () { echo " -prefix $prefix" echo " -wtimerdir $wtimer_dir" echo " -libdir $wtimerlib_dir" echo " -bindir $bin_dir" echo " -sbindir $sbin_dir" echo " -etcdir $etc_dir" #echo " -dbvariant $dbvariant" 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 } usage () { cat <<_EOF_ usage: ./configure [ options ] _EOF_ echo "-prefix <dir>:" echo " Use this directory as common prefix for the other paths" echo "-wtimerdir <dir>:" echo " Install shared application core into this directory" echo "-libdir <dir>:" echo " Install binary application core into this directory" echo "-bindir <dir>:" echo " Install binaries into this directory" echo "-sbindir <dir>:" echo " Install system binaries into this directory" echo "-etcdir <dir>:" echo " Install configuration files into this directory" #echo "-dbvariant (pg|my)" #echo " Choose either PostgreSQL (pg) or MySQL (my) as db backend" for opt in $options; do e="help=\$help_$opt" eval "$e" uopt=`echo $opt | sed -e 's/_/-/g'` echo "-with-$uopt:" echo "-without-$uopt:" echo " $help" done cat <<_EOF_ Defaults are: _EOF_ set_defaults print_options exit 1 } check_opt () { for x in $options; do if [ "$x" = "$1" ]; then return 0 fi done echo "Unknown option: $1" >&2 exit 1 } set_defaults 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 ;; -prefix) prefix="$2"; shift; shift ;; -wtimerdir) wtimer_dir="$2"; shift; shift ;; -libdir) wtimerlib_dir="$2"; shift; shift ;; -bindir) bin_dir="$2"; shift; shift ;; -sbindir) sbin_dir="$2"; shift; shift ;; -etcdir) etc_dir="$2"; shift; shift ;; #-dbvariant) # case "$2" in # pg|my) dbvariant="$2"; shift; shift ;; # *) # echo "Bad -dbvariant!" >&2; exit 1 ;; # esac # ;; -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 ###################################################################### # immutable strings printf "%s" "Checking for -safe-string... " string_opts="" if ocamlc -safe-string >/dev/null 2>/dev/null; then echo "yes" string_opts="-safe-string" else echo "no" fi ###################################################################### # Check netstring printf "%s" "Checking for ocamlnet (netstring)... " if ocamlfind query netstring >/dev/null 2>/dev/null; then echo "found" else echo "not found" echo "Sorry, installation is not possible without the netstring" echo "component of ocamlnet." exit 1 fi ###################################################################### # Check cgi printf "%s" "Checking for ocamlnet (netcgi2)... " if ocamlfind query netcgi2 >/dev/null 2>/dev/null; then echo "found" else echo "not found" echo "Sorry, installation is not possible without the netcgi2" echo "component of ocamlnet." exit 1 fi ###################################################################### # Check pxp printf "%s" "Checking for pxp (pxp-engine, pxp-lex-iso88591)... " if ocamlfind query pxp-engine >/dev/null 2>/dev/null; then if ocamlfind query pxp-lex-iso88591 >/dev/null 2>/dev/null; then echo "found" else echo "latter is missing" echo "Sorry, installation is not possible without the" echo "ISO-8859-1 lexer of PXP. Reinstall PXP correctly." exit 1 fi else echo "not found" echo "Sorry, installation is not possible without PXP." exit 1 fi ###################################################################### # Check wdialog printf "%s" "Checking for wdialog... " if ocamlfind query wdialog >/dev/null 2>/dev/null; then echo "found" else echo "not found" echo "Sorry, installation is not possible without wdialog." exit 1 fi ###################################################################### # Check ocamlodbc printf "%s" "Checking for postgresql... " if ocamlfind query postgresql >/dev/null 2>/dev/null; then echo "found" else echo "not found" echo "Sorry, installation is not possible without postgresql." exit 1 fi ###################################################################### # Summary echo echo "Effective options:" print_options echo ###################################################################### # Write Makefile.conf echo "Writing Makefile.conf" cat <<_EOF_ >Makefile.conf VERSION = $version EXEC_SUFFIX = $exec_suffix REQUIRES = $requires I_OPTIONS = $i_options BYTELINK_OPTIONS = $bytelink_options NATLINK_OPTIONS = $natlink_options STRING_OPTIONS = $string_opts PREFIX = $prefix PACK_PREFIX = WTIMER_DIR = $wtimer_dir WTIMERLIB_DIR = $wtimerlib_dir BIN_DIR = $bin_dir SBIN_DIR = $sbin_dir ETC_DIR = $etc_dir UI_DIR = $ui_dir CGI_DIR = $cgi_dir STATIC_DIR = $static_dir DDL_DIR = $ddl_dir _EOF_ ###################################################################### # Finish echo echo "You can now compile wtimer 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 application."