diff --git a/configure b/configure index e0668df4a..c60c2aa0d 100755 --- a/configure +++ b/configure @@ -5,7 +5,7 @@ ####################################################################### # Helpers: -test_binary () { +test_binary() { # $1: the name of the binary echo -n "Checking for $1 ... " if command -v "$1" >/dev/null 2>/dev/null; then @@ -17,25 +17,24 @@ test_binary () { fi } -fail_binary () { +fail_binary() { echo echo "Required command '$1' not found!" [ -z "$2" ] || echo "===> $2" exit 1 } -check_binary () { +check_binary() { # $1: the name of the binary # $2: an URL if test_binary $1; then - return + return else - fail_binary $1 $2 + fail_binary $1 $2 fi } - -test_library () { +test_library() { # $1: the name of the library (findlib) echo -n "Checking for $1 ... " if ocamlfind query $1 >/dev/null 2>/dev/null; then @@ -47,20 +46,20 @@ test_library () { fi } -fail_library () { +fail_library() { echo echo "Required library $1 not found!" [ -z "$2" ] || echo "===> $2" exit 1 } -check_library () { +check_library() { # $1: the name of the library (findlib) # $2: an URL if test_library $1; then - return + return else - fail_library $1 "$2" + fail_library $1 "$2" fi } @@ -72,30 +71,30 @@ check_library () { # value 1: on # defaults: -set_defaults () { - with_sqlite=1 - with_pgsql=1 - with_dbm=1 - prefix="/usr/local" - bindir="" - logdir="" - libdir="" - mandir="" - docdir="" - sysconfdir="/etc/ocsigenserver" - staticpagesdir="/var/www/ocsigenserver" - uploaddir="/tmp" - datadir="/var/lib/ocsigenserver" - temproot="local" - root="" - ocsigen_user="www-data" - ocsigen_group="www-data" +set_defaults() { + with_sqlite=1 + with_pgsql=1 + with_dbm=1 + prefix="/usr/local" + bindir="" + logdir="" + libdir="" + mandir="" + docdir="" + sysconfdir="/etc/ocsigenserver" + staticpagesdir="/var/www/ocsigenserver" + uploaddir="/tmp" + datadir="/var/lib/ocsigenserver" + temproot="local" + root="" + ocsigen_user="www-data" + ocsigen_group="www-data" } set_defaults -my_pwd=`dirname $0` -version=`head -n 1 $my_pwd/VERSION` -full_pwd=`pwd` +my_pwd=$(dirname $0) +version=$(head -n 1 $my_pwd/VERSION) +full_pwd=$(pwd) ######################################################################## ## Option parsing @@ -104,74 +103,73 @@ full_pwd=`pwd` eoptions="" woptions="pgsql sqlite dbm" -print_options () { - for opt in $eoptions; do - e="o=\$enable_$opt" - eval "$e" - uopt=`echo $opt | sed -e 's/_/-/g'` - if [ $o -gt 0 ]; then - echo " --enable-$uopt" - else - echo " --disable-$uopt" - fi - done - for opt in $woptions; 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 - case "$bindir" in - "") bindir2="/bin";; - *) bindir2=$bindir;; - esac - - case "$logdir" in - "") logdir2="/var/log/";; - *) logdir2=$logdir;; - esac - - case "$libdir" in - "") libdir2="\$(shell \${OCAMLFIND} printconf destdir)";; - *) libdir2=$libdir;; - esac - - case "$mandir" in - "") mandir2="/share/man/man1";; - *) mandir2=$mandir;; - esac - - case "$docdir" in - "") docdir2="/share/doc/ocsigenserver";; - *) docdir2=$docdir;; - esac - - echo " --name $name" - echo " --root $root" - echo " --temproot $temproot" - echo " --prefix $prefix" - echo " --ocsigen-user $ocsigen_user" - echo " --ocsigen-group $ocsigen_group" - echo " --bindir $bindir2" - echo " --libdir $libdir2" - echo " --sysconfdir $sysconfdir" - echo " --mandir $mandir2" - echo " --docdir $docdir2" - echo " --logdir $logdir2" - echo " --staticpagesdir $staticpagesdir" - echo " --uploaddir $uploaddir" - echo " --datadir $datadir" - echo " --commandpipe $commandpipe" +print_options() { + for opt in $eoptions; do + e="o=\$enable_$opt" + eval "$e" + uopt=$(echo $opt | sed -e 's/_/-/g') + if [ $o -gt 0 ]; then + echo " --enable-$uopt" + else + echo " --disable-$uopt" + fi + done + for opt in $woptions; 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 + case "$bindir" in + "") bindir2="/bin" ;; + *) bindir2=$bindir ;; + esac + + case "$logdir" in + "") logdir2="/var/log/" ;; + *) logdir2=$logdir ;; + esac + + case "$libdir" in + "") libdir2="\$(shell \${OCAMLFIND} printconf destdir)" ;; + *) libdir2=$libdir ;; + esac + + case "$mandir" in + "") mandir2="/share/man/man1" ;; + *) mandir2=$mandir ;; + esac + + case "$docdir" in + "") docdir2="/share/doc/ocsigenserver" ;; + *) docdir2=$docdir ;; + esac + + echo " --name $name" + echo " --root $root" + echo " --temproot $temproot" + echo " --prefix $prefix" + echo " --ocsigen-user $ocsigen_user" + echo " --ocsigen-group $ocsigen_group" + echo " --bindir $bindir2" + echo " --libdir $libdir2" + echo " --sysconfdir $sysconfdir" + echo " --mandir $mandir2" + echo " --docdir $docdir2" + echo " --logdir $logdir2" + echo " --staticpagesdir $staticpagesdir" + echo " --uploaddir $uploaddir" + echo " --datadir $datadir" + echo " --commandpipe $commandpipe" } - -usage () { - set_defaults - cat <<_EOF_ >&2 +usage() { + set_defaults + cat <<_EOF_ >&2 usage: ./configure [ options ] --name NAME The name of the server binary and ocamlfind package. @@ -201,187 +199,184 @@ usage: ./configure [ options ] Defaults are: _EOF_ - print_options >&2 - exit 1 + print_options >&2 + exit 1 } - -check_eopt () { - for x in $eoptions; do - if [ "$x" = "$1" ]; then - return 0 - fi - done - echo "Unknown option: $1" >&2 - exit 1 +check_eopt() { + for x in $eoptions; do + if [ "$x" = "$1" ]; then + return 0 + fi + done + echo "Unknown option: $1" >&2 + exit 1 } - -check_wopt () { - for x in $woptions; do - if [ "$x" = "$1" ]; then - return 0 - fi - done - echo "Unknown option: $1" >&2 - exit 1 +check_wopt() { + for x in $woptions; do + if [ "$x" = "$1" ]; then + return 0 + fi + done + echo "Unknown option: $1" >&2 + exit 1 } echo "\n\tWelcome to Ocsigen server, version $version.\n" >&2 while [ "$#" -gt 0 ]; do - case "$1" in - --enable-*) - opt=`echo "$1" | sed -e 's/--enable-//' -e 's/-/_/g'` - check_eopt "$opt" - eval "enable_$opt=2" - shift - ;; - --disable-*) - opt=`echo "$1" | sed -e 's/--disable-//' -e 's/-/_/g'` - check_eopt "$opt" - eval "enable_$opt=-1" - shift - ;; - --with-*) - opt=`echo "$1" | sed -e 's/--with-//' -e 's/-/_/g'` - check_wopt "$opt" - eval "with_$opt=2" - shift - ;; - --without-*) - opt=`echo "$1" | sed -e 's/--without-//' -e 's/-/_/g'` - check_wopt "$opt" - eval "with_$opt=-1" - shift - ;; - --root) - root="$2" - shift - shift - ;; - --temproot) - temproot="$2" - shift - shift - ;; - --prefix) - prefix="$2" - shift - shift - ;; - --bindir) - bindir="$2" - shift - shift - ;; - --logdir) - logdir="$2" - shift - shift - ;; - --libdir) - libdir="$2" - shift - shift - ;; - --mandir) - mandir="$2" - shift - shift - ;; - --docdir) - docdir="$2" - shift - shift - ;; - --staticpagesdir) - staticpagesdir="$2" - shift - shift - ;; - --sysconfdir) - sysconfdir="$2" - shift - shift - ;; - --uploaddir) - uploaddir="$2" - shift - shift - ;; - --datadir) - datadir="$2" - shift - shift - ;; - --name) - name="$2" - shift - shift - ;; - --ocsigen-user) - ocsigen_user="$2" - shift - shift - ;; - --ocsigen-group) - ocsigen_group="$2" - shift - shift - ;; - --commandpipe) - commandpipe="$2" - shift - shift - ;; - *) - echo "Unknown option: $1" >&2 - usage - esac + case "$1" in + --enable-*) + opt=$(echo "$1" | sed -e 's/--enable-//' -e 's/-/_/g') + check_eopt "$opt" + eval "enable_$opt=2" + shift + ;; + --disable-*) + opt=$(echo "$1" | sed -e 's/--disable-//' -e 's/-/_/g') + check_eopt "$opt" + eval "enable_$opt=-1" + shift + ;; + --with-*) + opt=$(echo "$1" | sed -e 's/--with-//' -e 's/-/_/g') + check_wopt "$opt" + eval "with_$opt=2" + shift + ;; + --without-*) + opt=$(echo "$1" | sed -e 's/--without-//' -e 's/-/_/g') + check_wopt "$opt" + eval "with_$opt=-1" + shift + ;; + --root) + root="$2" + shift + shift + ;; + --temproot) + temproot="$2" + shift + shift + ;; + --prefix) + prefix="$2" + shift + shift + ;; + --bindir) + bindir="$2" + shift + shift + ;; + --logdir) + logdir="$2" + shift + shift + ;; + --libdir) + libdir="$2" + shift + shift + ;; + --mandir) + mandir="$2" + shift + shift + ;; + --docdir) + docdir="$2" + shift + shift + ;; + --staticpagesdir) + staticpagesdir="$2" + shift + shift + ;; + --sysconfdir) + sysconfdir="$2" + shift + shift + ;; + --uploaddir) + uploaddir="$2" + shift + shift + ;; + --datadir) + datadir="$2" + shift + shift + ;; + --name) + name="$2" + shift + shift + ;; + --ocsigen-user) + ocsigen_user="$2" + shift + shift + ;; + --ocsigen-group) + ocsigen_group="$2" + shift + shift + ;; + --commandpipe) + commandpipe="$2" + shift + shift + ;; + *) + echo "Unknown option: $1" >&2 + usage + ;; + esac done case "$bindir" in - "") bindir="$prefix/bin";; +"") bindir="$prefix/bin" ;; esac case "$logdir" in - "") logdir="/var/log/ocsigenserver";; +"") logdir="/var/log/ocsigenserver" ;; esac case "$libdir" in - "") libdir="\$(shell \${OCAMLFIND} printconf destdir)";; - *) libdir=$root$libdir +"") libdir="\$(shell \${OCAMLFIND} printconf destdir)" ;; +*) libdir=$root$libdir ;; esac case "$mandir" in - "") mandir="$prefix/share/man/man1";; +"") mandir="$prefix/share/man/man1" ;; esac case "$docdir" in - "") docdir="$prefix/share/doc/ocsigenserver";; +"") docdir="$prefix/share/doc/ocsigenserver" ;; esac case "$commandpipe" in - "") commandpipe="/var/run/ocsigenserver_command";; +"") commandpipe="/var/run/ocsigenserver_command" ;; esac - - check_binary ocamlc "See: http://www.ocaml.org/" -check_ocamlversion () { +check_ocamlversion() { echo -n "Checking for OCaml version... " - version=`ocamlc -version` + version=$(ocamlc -version) echo $version - n1=`echo $version | sed 's/^\([0-9][0-9]*\)\..*$/\1/'` - n2=`echo $version | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/'` + n1=$(echo $version | sed 's/^\([0-9][0-9]*\)\..*$/\1/') + n2=$(echo $version | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/') # n3=`echo $version | sed 's/^[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/'` if [ $n1 -eq 3 ] && [ $n2 -lt 12 ]; then - echo; - echo "OCaml >= 3.12 is required. Aborting."; - exit 1; + echo + echo "OCaml >= 3.12 is required. Aborting." + exit 1 fi } @@ -396,10 +391,10 @@ check_library react "See: http://erratique.ch/software/react" check_library ssl "See: http://sourceforge.net/projects/savonet/files/ocaml-ssl" check_library lwt "See: http://ocsigen.org/lwt" -check_library lwt.unix "Missing support for 'unix' in lwt." -check_library lwt_react "See: http://ocsigen.org/lwt" -check_library lwt_ssl "See: http://ocsigen.org/lwt" -check_library lwt_log "See: http://ocsigen.org/lwt" +check_library lwt.unix "Missing support for 'unix' in lwt." +check_library lwt_react "See: http://ocsigen.org/lwt" +check_library lwt_ssl "See: http://ocsigen.org/lwt" +check_library lwt_log "See: http://ocsigen.org/lwt" check_library re "See: https://github.com/ocaml/ocaml-re/" check_library cryptokit "See: http://pauillac.inria.fr/~xleroy/software.html#cryptokit" @@ -408,34 +403,34 @@ check_library xml-light "See: https://github.com/ncannasse/xml-light" # Check PostgreSQL case "$with_pgsql" in - 1) if test_library pgocaml; then with_pgsql=1; else with_pgsql=0; fi;; - 2) check_library pgocaml "https://github.com/darioteixeira/pgocaml";; +1) if test_library pgocaml; then with_pgsql=1; else with_pgsql=0; fi ;; +2) check_library pgocaml "https://github.com/darioteixeira/pgocaml" ;; esac # Check Sqlite3 case "$with_sqlite" in - 1) if test_library sqlite3; then with_sqlite=1; else with_sqlite=0; fi;; - 2) check_library sqlite3 "See: http://ocaml.info/home/ocaml_sources.html";; +1) if test_library sqlite3; then with_sqlite=1; else with_sqlite=0; fi ;; +2) check_library sqlite3 "See: http://ocaml.info/home/ocaml_sources.html" ;; esac # Check dbm if [ "$with_dbm" -gt 0 ]; then - if test_library dbm; then - echo -n - elif [ "$with_dbm" -gt 1 ]; then - fail_library dbm - else - with_dbm=0 - fi + if test_library dbm; then + echo -n + elif [ "$with_dbm" -gt 1 ]; then + fail_library dbm + else + with_dbm=0 + fi fi # Check rlwrap or ledit if test_binary rlwrap; then - rlwrap=rlwrap + rlwrap=rlwrap elif test_binary ledit; then - rlwrap=ledit + rlwrap=ledit else - rlwrap= + rlwrap= fi ###################################################################### @@ -446,31 +441,30 @@ echo "Effective options:" print_options echo - #Convert 0/1 values to YES/NO -if [ $with_dbm -gt 0 ] ; then - with_dbm="YES" +if [ $with_dbm -gt 0 ]; then + with_dbm="YES" else - with_dbm="NO" + with_dbm="NO" fi -if [ $with_sqlite -gt 0 ] ; then - with_sqlite="YES" +if [ $with_sqlite -gt 0 ]; then + with_sqlite="YES" else - with_sqlite="NO" + with_sqlite="NO" fi -if [ $with_pgsql -gt 0 ] ; then - with_pgsql="YES" +if [ $with_pgsql -gt 0 ]; then + with_pgsql="YES" else - with_pgsql="NO" + with_pgsql="NO" fi -ocamlinclude=`ocamlfind printconf stdlib` +ocamlinclude=$(ocamlfind printconf stdlib) ###################################################################### # Write Makefile.conf echo "Writing Makefile.config" -cat <<_EOF_ > $my_pwd/Makefile.config +cat <<_EOF_ >$my_pwd/Makefile.config #### External binaries ####