3 # $Id: configure 1080 2007-01-07 16:00:50Z gerd $
4 # Adapted from the ocamlnet configure script.
6 #######################################################################
9 # Split $PATH into words:
12 spacepath
=`echo $PATH`
17 # Does $1 exist in $PATH?
18 for d
in $spacepath; do
19 if test -x "$d/$1"; then
28 for d
in $spacepath; do
29 if test -x "$d/$1"; then
36 #######################################################################
66 staticpagesdir
="/var/www"
69 commandpipe
="/var/run/ocsigen_command"
72 ocsigen_user
="www-data"
73 ocsigen_group
="www-data"
78 version
=`head -n 1 $my_pwd/VERSION`
81 ########################################################################
85 ehelp_debug
="Enable/disable debug output"
86 ehelp_annot
="Enable/disable .annot files"
87 ehelp_bytecode
="Enable/disable bytecode version of Ocsigen"
88 ehelp_nativecode
="Enable/disable nativecode version of Ocsigen"
89 ehelp_natdynlink
="Enable/disable nativecode dynamic linking"
90 ehelp_ocamlduce
="Enable/disable Ocamlduce for typing pages (requires ocamlduce to be installed); default is detected"
91 ehelp_newocamlnet
="Use new/old versions of Ocamlnet (>= 2.0)"
92 ehelp_sqlite
="Compile ocsipersist with SQLite for persistent storage (default)"
93 ehelp_dbm
="Compile ocsipersist with DBM for persistent storage; default is detected"
94 ehelp_camlzip
="Compile deflatemod extension (requires camlzip); default is detected"
96 ## Which options exist? eoptions for enable/disable, woptions for with/without:
97 eoptions
="debug annot bytecode nativecode natdynlink ocamlduce newocamlnet sqlite dbm camlzip"
102 # Packages to include anyway:
103 requires
="lwt netstring ssl sqlite3"
108 # $1: the name of the library (findlib)
109 # # $2: a typical file in $incdirs
110 # if [ "$enable_findlib" -gt 0 ]; then
111 ocamlfind query
"$1" >/dev
/null
2>/dev
/null
114 # stdlib=`ocamlc -where`
115 # for dir in $incdirs; do
118 # dir=`echo "$dir" | sed -e "s|^\+|$stdlib/|"` ;;
120 # if [ -f "$dir/$2" ]; then
130 for opt
in $eoptions; do
133 uopt
=`echo $opt | sed -e 's/_/-/g'`
134 if [ $o -gt 0 ]; then
135 echo " --enable-$uopt"
137 echo " --disable-$uopt"
140 for opt
in $woptions; do
143 uopt
=`echo $opt | sed -e 's/_/-/g'`
144 if [ $o -gt 0 ]; then
147 echo " --without-$uopt"
151 "") bindir2
="<prefix>/bin";;
155 case "$examplesdir" in
156 "") examplesdir2
="<prefix>/lib/<name>/examples";;
157 *) examplesdir2
=$examplesdir;;
161 "") libdir2
="<prefix>/<ocamlfind install directory>";;
166 "") stubdir2
="<first line of OCaml's ld.conf>";;
167 *) stubdir2
=$stubdir;;
171 "") logdir2
="<prefix>/var/log/<name>";;
175 case "$extralibdir" in
176 "") extralibdir2
="<prefix>/lib";;
177 *) extralibdir2
=$extralibdir;;
181 "") mandir2
="<prefix>/share/man/man1";;
186 "") docdir2
="<prefix>/share/doc";;
191 echo " --temproot $temproot"
192 echo " --prefix $prefix"
193 echo " --ocsigen-user $ocsigen_user"
194 echo " --ocsigen-group $ocsigen_group"
195 echo " --bindir $bindir2"
196 echo " --libdir $libdir2"
197 echo " --stubdir $stubdir2"
198 echo " --logdir $logdir2"
199 echo " --extralibdir $extralibdir"
200 echo " --examplesdir $examplesdir2"
201 echo " --mandir $mandir2"
202 echo " --docdir $docdir2"
203 echo " --sysconfdir $sysconfdir"
204 echo " --staticpagesdir $staticpagesdir"
205 echo " --uploaddir $uploaddir"
206 echo " --datadir $datadir"
208 echo " --commandpipe $commandpipe"
215 usage: ./configure [ options ]
218 for opt
in $eoptions; do
219 e
="help=\$ehelp_$opt"
221 uopt
=`echo $opt | sed -e 's/_/-/g'`
222 echo "--enable-$uopt:" >&2
223 echo "--disable-$uopt:" >&2
227 for opt
in $woptions; do
228 e
="help=\$whelp_$opt"
230 uopt
=`echo $opt | sed -e 's/_/-/g'`
231 echo "--with-$uopt:" >&2
232 echo "--without-$uopt:" >&2
238 Root directory to install the package (usually /) (Everything will be in this directory)
241 Temporary root directory to install the package (usually always "" but for package makers)
244 Subdirectory where to install binaries and libs (usually /usr or /usr/local)
247 Install binaries into this directory
250 Install Ocsigen's extensions into this directory
253 Install Ocsigen's shared stub library into this directory
256 Use this directory for Ocsigen's logs
259 Install Ocsigen's extensions' extra libraries (e.g. ocsidbm) into this directory
262 Install Ocsigen's examples sites into this directory
265 Install man pages in this directory
268 Install documentation in this directory
271 Create configuration directory in this directory
274 Install default static pages directory in this directory
277 By default, files will be uploaded in this directory
280 The directory for data written by the server will be in this directory
283 The name of the server (and directories)
286 The name of the ocsigen user
289 The name of the ocsigen group
292 The name of the named pipe used to command the server
303 for x
in $eoptions; do
304 if [ "$x" = "$1" ]; then
308 echo "Unknown option: $1" >&2
314 for x
in $woptions; do
315 if [ "$x" = "$1" ]; then
319 echo "Unknown option: $1" >&2
324 echo "Welcome to Ocsigen version $version" >&2
326 while [ "$#" -gt 0 ]; do
329 opt
=`echo "$1" | sed -e 's/--enable-//' -e 's/-/_/g'`
335 opt
=`echo "$1" | sed -e 's/--disable-//' -e 's/-/_/g'`
337 eval "enable_$opt=-1"
341 opt
=`echo "$1" | sed -e 's/--with-//' -e 's/-/_/g'`
347 opt
=`echo "$1" | sed -e 's/--without-//' -e 's/-/_/g'`
452 echo "Unknown option: $1" >&2
458 "") bindir
="$prefix/bin";;
461 case "$examplesdir" in
462 "") examplesdir
="$prefix/lib/\$(OCSIGENNAME)/examples";;
466 "") libdir
="\$(shell \$(OCAMLFIND) printconf destdir)";;
470 "") stubdir
="\$(shell head -n1 \$(shell \$(OCAMLFIND) printconf ldconf))";;
474 "") logdir
="/var/log/\$(OCSIGENNAME)";;
477 case "$extralibdir" in
478 "") extralibdir
="$prefix/lib";;
482 "") mandir
="$prefix/share/man/man1";;
486 "") docdir
="$prefix/share/doc";;
492 ######################################################################
495 printf "%s" "Checking for findlib... "
496 if ocamlfind query stdlib
>/dev
/null
2>/dev
/null
; then
500 echo "Make sure that ocamlfind is in your PATH, or install findlib"
501 echo "(from www.ocaml-programming.de)"
506 ######################################################################
509 printf "%s" "Checking for lwt... "
510 if ocamlfind query lwt
>/dev
/null
2>/dev
/null
; then
514 echo "Make sure that ocamlfind is in your PATH, or install lwt"
515 echo "(from www.ocsigen.org)"
520 ######################################################################
523 printf "%s" "Checking for ssl... "
524 if ocamlfind query ssl
>/dev
/null
2>/dev
/null
; then
528 echo "Required library ssl not found!"
532 ######################################################################
535 printf "%s" "Checking for obrowser... "
536 if ocamlfind query obrowser
>/dev
/null
2>/dev
/null
; then
540 echo "Required dependency obrowser not found!"
544 ######################################################################
547 printf "%s" "Checking for netstring (from Ocamlnet)... "
548 if ocamlfind query netstring
>/dev
/null
2>/dev
/null
; then
552 echo "Required library netstring not found!"
557 ######################################################################
560 if [ "$enable_sqlite" -gt 0 ]; then
561 printf "%s" "Checking for sqlite3... "
562 if ocamlfind query sqlite3
>/dev
/null
2>/dev
/null
; then
566 echo "Required library sqlite3 not found!"
570 ocamlsqlite3dir
=`ocamlfind query sqlite3`
574 ######################################################################
577 if [ "$enable_camlzip" -gt 0 ]; then
578 printf "%s" "Checking for camlzip... "
579 if ocamlfind query camlzip
>/dev
/null
2>/dev
/null
; then
581 camlzipdir
=`ocamlfind query camlzip`
583 elif ocamlfind query
zip >/dev
/null
2>/dev
/null
; then
585 camlzipdir
=`ocamlfind query zip`
587 elif [ "$enable_camlzip" -gt 1 ]; then
588 echo "not found, but --enable-camlzip specified"
596 ######################################################################
599 printf "%s" "Checking for Cryptokit... "
600 if ocamlfind query cryptokit
>/dev
/null
2>/dev
/null
; then
604 echo "Required library cryptokit not found!"
608 cryptokitdir
=`ocamlfind query cryptokit`
611 ######################################################################
614 if [ "$enable_ocamlduce" -gt 0 ]; then
615 printf "%s" "Checking for ocamlduce... "
616 if which ocamlduce
>/dev
/null
2>/dev
/null
; then
618 elif [ "$enable_ocamlduce" -gt 1 ]; then
619 echo "not found, but --enable-ocamlduce specified"
628 ######################################################################
631 if [ "$enable_dbm" -gt 0 ]; then
632 printf "%s" "Checking for dbm... "
633 if ocamlc
-o /dev
/null dbm.cma
>/dev
/null
2>/dev
/null
; then
635 elif [ "$enable_dbm" -gt 1 ]; then
636 echo "not found, but --enable-dbm specified"
645 ######################################################################
646 # Check whether OCaml version is > 3.10
647 echo "Checking for OCaml version"
648 version
=`ocamlc -version|sed 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
649 ocamlversion
=`n1=${version%%.*}; n2=${version##*.}; \
650 if [ $n1 -eq 3 ] && [ $n2 -le 9 ]; then \
656 case "$ocamlversion" in
657 "OLD") echo; echo "OCaml >= 3.10 is required. Aborting."; exit 1;;
661 ######################################################################
663 #printf "%s" "Finding out which camlp4o to use... "
664 #if which camlp4o.byte >/dev/null 2>/dev/null; then
665 # echo "camlp4o.byte"
666 # camlp4o="camlp4o.byte"
672 ######################################################################
674 ######################################################################
678 echo "Effective options:"
683 #Convert 0/1 values to YES/NO
684 if [ $enable_debug -gt 0 ] ; then
689 if [ $enable_annot -gt 0 ] ; then
694 if [ $enable_bytecode -gt 0 ] ; then
695 enable_bytecode
="YES"
699 if [ $enable_nativecode -gt 0 ] ; then
700 enable_nativecode
="YES"
701 echo "WARNING: Native code version with dynlink requires ocaml >= 3.11"
703 enable_nativecode
="NO"
705 if [ $enable_natdynlink -gt 0 ] ; then
706 enable_natdynlink
="YES"
708 enable_natdynlink
="NO"
710 if [ $enable_ocamlduce -gt 0 ] ; then
711 enable_ocamlduce
="YES"
713 enable_ocamlduce
="NO"
715 if [ $enable_newocamlnet -gt 0 ] ; then
716 enable_newocamlnet
="YES"
718 enable_newocamlnet
="NO"
720 if [ $enable_dbm -gt 0 ] ; then
725 if [ $enable_sqlite -gt 0 ] ; then
730 if [ $enable_camlzip -gt 0 ] ; then
739 ocamlinclude
=`ocamlfind printconf stdlib`
741 ######################################################################
742 # Write Makefile.conf
744 echo "Writing Makefile.config"
745 cat <<_EOF_ > $my_pwd/Makefile.config
746 # Which ocamlfind/camlp4/ ... version to use?
747 # ocamlfind will choose automatically the compiler.
754 CAMLMKTOPNAME=ocamlmktop
756 CAMLCPNAME=ocamlcp -p a # No: profiling is incompatible with the -pp option
760 CAMLINCLUDE=-I $ocamlinclude
762 ## The root directory for the package install (usually /)
765 # Temporary root directory to install the package (usually always "" but for package makers)
768 # Do you want the bytecode version ? YES/NO
769 BYTECODE=$enable_bytecode
771 # Do you want the native code version (ocsigen.opt) ? YES/NO
772 NATIVECODE=$enable_nativecode
774 # Do you want to use dynamic linking for native code? YES/NO
775 NATDYNLINK=$enable_natdynlink
777 # Do you want the ocamlduce extension? (YES/NO)
778 # (You need ocamlduce to be installed)
779 OCAMLDUCE=$enable_ocamlduce
780 # If you have OCamlduce installed, which ocamlducefind do you want?
781 OCAMLDUCEFIND=ocamlducefind
783 # The directory for ocsigen server (binary):
784 BINDIR = $root$bindir
786 # The directory for ocsigen manpage:
787 MANDIR = $root$mandir
789 # Where to install the directory for ocsigen extensions:
790 MODULEINSTALLDIR = $root$libdir
792 # Where to install stub libraries
793 STUBDIR = $root$stubdir
795 # Where to install the directory for ocsigen extensions' libraries (e.g. ocsidbm):
796 EXTRALIBDIR = $root$extralibdir/\$(OCSIGENNAME)
798 # Where to install examples:
799 EXAMPLESINSTALLDIR = $root$examplesdir
801 # User who will run Ocsigen server (not root) (eg, for debian, www-data)
802 # (This user must exist on your system)
803 OCSIGENUSER=$ocsigen_user
805 # group who will run Ocsigen server (not root) (eg, for debian, www-data)
806 # (This group must exist)
807 OCSIGENGROUP=$ocsigen_group
809 # The name of the server (and the directory for the extensions)
813 LOGDIR = $root$logdir
816 CONFIGDIR = $root$sysconfdir/\$(OCSIGENNAME)
818 # Where to put static pages:
819 STATICPAGESDIR =$root$staticpagesdir/\$(OCSIGENNAME)
821 # Where to put dynamic data:
822 DATADIR = $root$datadir/\$(OCSIGENNAME)
824 # Default directory for file upload:
825 UPLOADDIR = $root$uploaddir
827 # Where to put Ocsigen documentation:
828 DOCDIR = $root$docdir/\$(OCSIGENNAME)
830 # Do you want debugging information? (-g)
833 # Do you want annot files? (-dtypes)
836 # The name of the named pipe used to command the server
837 COMMANDPIPE=$root$commandpipe
839 # The directory where ocamlsqlite3 is installed
840 OCAMLSQLITE3DIR=$ocamlsqlite3dir
842 # The directory where camlzip is installed
843 CAMLZIPDIR=$camlzipdir
845 # The directory where cryptokit is installed
846 CRYPTOKITINSTALLDIR=$cryptokitdir
848 # The name of camlzip package:
849 CAMLZIPNAME=$camlzipname
851 # Do you want deflatemod? (requires camlzip)
852 CAMLZIP=$enable_camlzip
854 # Do you want ocsipersist with sqlite?
855 OCSIPERSISTSQLITE=$enable_sqlite
857 # Do you want ocsipersist with dbm?
858 OCSIPERSISTDBM=$enable_dbm
861 # The source directory
866 # If you are using ocamlnet 1, write NO here
867 NEWOCAMLNET=$enable_newocamlnet
869 # Profiling (always put NO here - but if you want to debug ocsigen):
873 OCAMLVERSION=$ocamlversion
876 LIBDIRS= -I ../baselib -I ../http -I ../xmlp4 -I ../server -I ../extensions -I ../eliom
877 LIBDIRS2= -I ../../baselib -I ../../http -I ../../xmlp4 -I ../../server -I ../../extensions -I ../../eliom
878 LIBDIRS3= -I baselib -I http -I xmlp4 -I server -I extensions -I eliom
880 include \$(SRC)/Makefile.options
884 ######################################################################
891 echo "Please check Makefile.config."
893 echo "You can now compile Ocsigen by invoking"
897 echo "Finally, if you want system-wide install, (become root if needed and) do"
899 echo "to install the package, or"
900 echo " make installnodoc"
901 echo "to install the package without generating the documentation."