Plasma GitLab Archive
Projects Blog Knowledge

#! /bin/sh

# $Id: configure,v 1.6 2003/03/23 11:29:32 gerd Exp $

#######################################################################
# 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=1
    version="1.0"
    exec_suffix=""
    requires="netstring,unix,pxp-engine,pxp-lex-iso88591,wdialog"
    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

help_cgi="Create/omit the CGI binary"
help_ajp="Create/omit the AJP (mod_jserv/mod_jk) binary"
options="cgi ajp"

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

######################################################################
# 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 (cgi)... "
if ocamlfind query cgi >/dev/null 2>/dev/null; then
    echo "found"
else
    echo "not found"
    echo "Sorry, installation is not possible without the cgi"
    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 ocamlodbc... "
if ocamlfind query ocamlodbc >/dev/null 2>/dev/null; then
    echo "found (via findlib)"
    requires="$requires,ocamlodbc"
else
    if ocamlc -I +ocamlodbc ocamlodbc.cma -o .dummy.out; then
	echo "found (via -I +ocamlodbc)"
	i_options="$i_options -I +ocamlodbc"
	bytelink_options="ocamlodbc.cma"
	natlink_options="ocamlodbc.cmxa"
	rm -f .dummy.out
    else
	echo "not found"
	echo "Sorry, installation is not possible without ocamlodbc."
	exit 1
    fi
fi

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

echo
echo "Effective options:"
print_options
echo

goals=""

if [ "$with_cgi" -gt 0 ]; then goals="$goals wtimer.cgi"; fi
if [ "$with_ajp" -gt 0 ]; then goals="$goals wtimerd"; fi

######################################################################
# Write Makefile.conf

echo "Writing Makefile.conf"
cat <<_EOF_ >Makefile.conf
VERSION = $version
GOALS = $goals
EXEC_SUFFIX = $exec_suffix
REQUIRES = $requires
I_OPTIONS = $i_options
BYTELINK_OPTIONS = $bytelink_options
NATLINK_OPTIONS = $natlink_options
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
DBVARIANT = $dbvariant
_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."

This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml