Fix outstanding bugs
[pkg-ocaml-ocsigen.git] / configure
blob0dba7a3a58723605384c0ba86407e6a5efa55015
1 #! /bin/sh
3 # $Id: configure 1080 2007-01-07 16:00:50Z gerd $
4 # Adapted from the ocamlnet configure script.
6 #######################################################################
7 # Helpers:
9 # Split $PATH into words:
10 oldifs="$IFS"
11 IFS=" :"
12 spacepath=`echo $PATH`
13 IFS="$oldifs"
16 in_path () {
17 # Does $1 exist in $PATH?
18 for d in $spacepath; do
19 if test -x "$d/$1"; then
20 return 0
22 done
23 return 1
27 get_path () {
28 for d in $spacepath; do
29 if test -x "$d/$1"; then
30 echo "$d/$1"
31 return
33 done
36 #######################################################################
37 # Defaults
39 #--- Options ---
40 # value 0: off
41 # value 1: on
42 # defaults:
44 set_defaults () {
45 name="ocsigen"
46 enable_bytecode=1
47 enable_nativecode=1
48 enable_natdynlink=1
49 enable_debug=0
50 enable_annot=0
51 enable_ocamlduce=1
52 enable_newocamlnet=1
53 enable_sqlite=1
54 enable_camlzip=1
55 enable_dbm=1
56 prefix="/usr/local"
57 bindir=""
58 examplesdir=""
59 libdir=""
60 stubdir=""
61 logdir=""
62 extralibdir=""
63 mandir=""
64 docdir=""
65 sysconfdir="/etc"
66 staticpagesdir="/var/www"
67 uploaddir="/tmp"
68 datadir="/var/lib"
69 commandpipe="/var/run/ocsigen_command"
70 temproot=""
71 root=""
72 ocsigen_user="www-data"
73 ocsigen_group="www-data"
76 set_defaults
77 my_pwd=`dirname $0`
78 version=`head -n 1 $my_pwd/VERSION`
79 full_pwd=`pwd`
81 ########################################################################
82 ## Option parsing
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"
98 woptions=""
102 # Packages to include anyway:
103 requires="lwt netstring ssl sqlite3"
107 check_library () {
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
112 return
113 # else
114 # stdlib=`ocamlc -where`
115 # for dir in $incdirs; do
116 # case "$dir" in
117 # +*)
118 # dir=`echo "$dir" | sed -e "s|^\+|$stdlib/|"` ;;
119 # esac
120 # if [ -f "$dir/$2" ]; then
121 # return 0
122 # fi
123 # done
124 return 1 # not found
125 # fi
129 print_options () {
130 for opt in $eoptions; do
131 e="o=\$enable_$opt"
132 eval "$e"
133 uopt=`echo $opt | sed -e 's/_/-/g'`
134 if [ $o -gt 0 ]; then
135 echo " --enable-$uopt"
136 else
137 echo " --disable-$uopt"
139 done
140 for opt in $woptions; do
141 e="o=\$with_$opt"
142 eval "$e"
143 uopt=`echo $opt | sed -e 's/_/-/g'`
144 if [ $o -gt 0 ]; then
145 echo " --with-$uopt"
146 else
147 echo " --without-$uopt"
149 done
150 case "$bindir" in
151 "") bindir2="<prefix>/bin";;
152 *) bindir2=$bindir;;
153 esac
155 case "$examplesdir" in
156 "") examplesdir2="<prefix>/lib/<name>/examples";;
157 *) examplesdir2=$examplesdir;;
158 esac
160 case "$libdir" in
161 "") libdir2="<prefix>/<ocamlfind install directory>";;
162 *) libdir2=$libdir;;
163 esac
165 case "$stubdir" in
166 "") stubdir2="<first line of OCaml's ld.conf>";;
167 *) stubdir2=$stubdir;;
168 esac
170 case "$logdir" in
171 "") logdir2="<prefix>/var/log/<name>";;
172 *) logdir2=$logdir;;
173 esac
175 case "$extralibdir" in
176 "") extralibdir2="<prefix>/lib";;
177 *) extralibdir2=$extralibdir;;
178 esac
180 case "$mandir" in
181 "") mandir2="<prefix>/share/man/man1";;
182 *) mandir2=$mandir;;
183 esac
185 case "$docdir" in
186 "") docdir2="<prefix>/share/doc";;
187 *) docdir2=$docdir;;
188 esac
190 echo " --root $root"
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"
207 echo " --name $name"
208 echo " --commandpipe $commandpipe"
212 usage () {
213 set_defaults
214 cat <<_EOF_ >&2
215 usage: ./configure [ options ]
217 _EOF_
218 for opt in $eoptions; do
219 e="help=\$ehelp_$opt"
220 eval "$e"
221 uopt=`echo $opt | sed -e 's/_/-/g'`
222 echo "--enable-$uopt:" >&2
223 echo "--disable-$uopt:" >&2
224 echo " $help" >&2
225 echo "" >&2
226 done
227 for opt in $woptions; do
228 e="help=\$whelp_$opt"
229 eval "$e"
230 uopt=`echo $opt | sed -e 's/_/-/g'`
231 echo "--with-$uopt:" >&2
232 echo "--without-$uopt:" >&2
233 echo " $help" >&2
234 echo "" >&2
235 done
236 cat <<_EOF_ >&2
237 --root dir
238 Root directory to install the package (usually /) (Everything will be in this directory)
240 --temproot dir
241 Temporary root directory to install the package (usually always "" but for package makers)
243 --prefix dir
244 Subdirectory where to install binaries and libs (usually /usr or /usr/local)
246 --bindir dir
247 Install binaries into this directory
249 --libdir dir
250 Install Ocsigen's extensions into this directory
252 --stubdir dir
253 Install Ocsigen's shared stub library into this directory
255 --logdir dir
256 Use this directory for Ocsigen's logs
258 --extralibdir dir
259 Install Ocsigen's extensions' extra libraries (e.g. ocsidbm) into this directory
261 --examplesdir dir
262 Install Ocsigen's examples sites into this directory
264 --mandir dir
265 Install man pages in this directory
267 --docdir dir
268 Install documentation in this directory
270 --sysconfdir dir
271 Create configuration directory in this directory
273 --staticpagesdir dir
274 Install default static pages directory in this directory
276 --uploaddir dir
277 By default, files will be uploaded in this directory
279 --datadir dir
280 The directory for data written by the server will be in this directory
282 --name name
283 The name of the server (and directories)
285 --ocsigen-user name
286 The name of the ocsigen user
288 --ocsigen-group name
289 The name of the ocsigen group
291 --commandpipe name
292 The name of the named pipe used to command the server
294 Defaults are:
296 _EOF_
297 print_options >&2
298 exit 1
302 check_eopt () {
303 for x in $eoptions; do
304 if [ "$x" = "$1" ]; then
305 return 0
307 done
308 echo "Unknown option: $1" >&2
309 exit 1
313 check_wopt () {
314 for x in $woptions; do
315 if [ "$x" = "$1" ]; then
316 return 0
318 done
319 echo "Unknown option: $1" >&2
320 exit 1
324 echo "Welcome to Ocsigen version $version" >&2
326 while [ "$#" -gt 0 ]; do
327 case "$1" in
328 --enable-*)
329 opt=`echo "$1" | sed -e 's/--enable-//' -e 's/-/_/g'`
330 check_eopt "$opt"
331 eval "enable_$opt=2"
332 shift
334 --disable-*)
335 opt=`echo "$1" | sed -e 's/--disable-//' -e 's/-/_/g'`
336 check_eopt "$opt"
337 eval "enable_$opt=-1"
338 shift
340 --with-*)
341 opt=`echo "$1" | sed -e 's/--with-//' -e 's/-/_/g'`
342 check_wopt "$opt"
343 eval "with_$opt=2"
344 shift
346 --without-*)
347 opt=`echo "$1" | sed -e 's/--without-//' -e 's/-/_/g'`
348 check_wopt "$opt"
349 eval "with_$opt=-1"
350 shift
352 --root)
353 root="$2"
354 shift
355 shift
357 --temproot)
358 temproot="$2"
359 shift
360 shift
362 --prefix)
363 prefix="$2"
364 shift
365 shift
367 --bindir)
368 bindir="$2"
369 shift
370 shift
372 --libdir)
373 libdir="$2"
374 shift
375 shift
377 --stubdir)
378 stubdir="$2"
379 shift
380 shift
382 --logdir)
383 logdir="$2"
384 shift
385 shift
387 --extralibdir)
388 extralibdir="$2"
389 shift
390 shift
392 --examplesdir)
393 examplesdir="$2"
394 shift
395 shift
397 --mandir)
398 mandir="$2"
399 shift
400 shift
402 --docdir)
403 docdir="$2"
404 shift
405 shift
407 --staticpagesdir)
408 staticpagesdir="$2"
409 shift
410 shift
412 --sysconfdir)
413 sysconfdir="$2"
414 shift
415 shift
417 --uploaddir)
418 uploaddir="$2"
419 shift
420 shift
422 --datadir)
423 datadir="$2"
424 shift
425 shift
427 --name)
428 name="$2"
429 shift
430 shift
432 --ocsigen-user)
433 ocsigen_user="$2"
434 shift
435 shift
437 --ocsigen-group)
438 ocsigen_group="$2"
439 shift
440 shift
442 --commandpipe)
443 commandpipe="$2"
444 shift
445 shift
447 --version)
448 echo "$version"
449 exit 0
452 echo "Unknown option: $1" >&2
453 usage
454 esac
455 done
457 case "$bindir" in
458 "") bindir="$prefix/bin";;
459 esac
461 case "$examplesdir" in
462 "") examplesdir="$prefix/lib/\$(OCSIGENNAME)/examples";;
463 esac
465 case "$libdir" in
466 "") libdir="\$(shell \$(OCAMLFIND) printconf destdir)";;
467 esac
469 case "$stubdir" in
470 "") stubdir="\$(shell head -n1 \$(shell \$(OCAMLFIND) printconf ldconf))";;
471 esac
473 case "$logdir" in
474 "") logdir="/var/log/\$(OCSIGENNAME)";;
475 esac
477 case "$extralibdir" in
478 "") extralibdir="$prefix/lib";;
479 esac
481 case "$mandir" in
482 "") mandir="$prefix/share/man/man1";;
483 esac
485 case "$docdir" in
486 "") docdir="$prefix/share/doc";;
487 esac
492 ######################################################################
493 # Check ocamlfind
495 printf "%s" "Checking for findlib... "
496 if ocamlfind query stdlib >/dev/null 2>/dev/null; then
497 echo "found"
498 else
499 echo "not found"
500 echo "Make sure that ocamlfind is in your PATH, or install findlib"
501 echo "(from www.ocaml-programming.de)"
502 exit 1
506 ######################################################################
507 # Check lwt
509 printf "%s" "Checking for lwt... "
510 if ocamlfind query lwt >/dev/null 2>/dev/null; then
511 echo "found"
512 else
513 echo "not found"
514 echo "Make sure that ocamlfind is in your PATH, or install lwt"
515 echo "(from www.ocsigen.org)"
516 exit 1
520 ######################################################################
521 # Check SSL
523 printf "%s" "Checking for ssl... "
524 if ocamlfind query ssl >/dev/null 2>/dev/null; then
525 echo "found"
526 else
527 echo "not found"
528 echo "Required library ssl not found!"
529 exit 1
532 ######################################################################
533 # Check Obrowser
535 printf "%s" "Checking for obrowser... "
536 if ocamlfind query obrowser >/dev/null 2>/dev/null; then
537 echo "found"
538 else
539 echo "not found"
540 echo "Required dependency obrowser not found!"
541 exit 1
544 ######################################################################
545 # Check Ocamlnet
547 printf "%s" "Checking for netstring (from Ocamlnet)... "
548 if ocamlfind query netstring >/dev/null 2>/dev/null; then
549 echo "found"
550 else
551 echo "not found"
552 echo "Required library netstring not found!"
553 exit 1
557 ######################################################################
558 # Check SQLITE3
560 if [ "$enable_sqlite" -gt 0 ]; then
561 printf "%s" "Checking for sqlite3... "
562 if ocamlfind query sqlite3 >/dev/null 2>/dev/null; then
563 echo "found"
564 else
565 echo "not found"
566 echo "Required library sqlite3 not found!"
567 exit 1
570 ocamlsqlite3dir=`ocamlfind query sqlite3`
574 ######################################################################
575 # Check Camlzip
577 if [ "$enable_camlzip" -gt 0 ]; then
578 printf "%s" "Checking for camlzip... "
579 if ocamlfind query camlzip >/dev/null 2>/dev/null; then
580 echo "found camlzip"
581 camlzipdir=`ocamlfind query camlzip`
582 camlzipname=camlzip
583 elif ocamlfind query zip >/dev/null 2>/dev/null; then
584 echo "found zip"
585 camlzipdir=`ocamlfind query zip`
586 camlzipname=zip
587 elif [ "$enable_camlzip" -gt 1 ]; then
588 echo "not found, but --enable-camlzip specified"
589 exit 1
590 else
591 echo "not found"
592 enable_camlzip=0
596 ######################################################################
597 # Check Cryptokit
599 printf "%s" "Checking for Cryptokit... "
600 if ocamlfind query cryptokit >/dev/null 2>/dev/null; then
601 echo "found"
602 else
603 echo "not found"
604 echo "Required library cryptokit not found!"
605 exit 1
608 cryptokitdir=`ocamlfind query cryptokit`
611 ######################################################################
612 # Check ocamlduce
614 if [ "$enable_ocamlduce" -gt 0 ]; then
615 printf "%s" "Checking for ocamlduce... "
616 if which ocamlduce >/dev/null 2>/dev/null; then
617 echo "found"
618 elif [ "$enable_ocamlduce" -gt 1 ]; then
619 echo "not found, but --enable-ocamlduce specified"
620 exit 1
621 else
622 echo "not found"
623 enable_ocamlduce=0
628 ######################################################################
629 # Check dbm
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
634 echo "found"
635 elif [ "$enable_dbm" -gt 1 ]; then
636 echo "not found, but --enable-dbm specified"
637 exit 1
638 else
639 echo "not found"
640 enable_dbm=0
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 \
651 echo "OLD"; \
652 else \
653 echo "NEW"; \
656 case "$ocamlversion" in
657 "OLD") echo; echo "OCaml >= 3.10 is required. Aborting."; exit 1;;
658 esac
661 ######################################################################
662 # Check camlp4o
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"
667 #else
668 # echo "camlp4o"
669 # camlp4o="camlp4o"
672 ######################################################################
674 ######################################################################
675 # Summary
677 echo
678 echo "Effective options:"
679 print_options
680 echo
683 #Convert 0/1 values to YES/NO
684 if [ $enable_debug -gt 0 ] ; then
685 enable_debug="YES"
686 else
687 enable_debug="NO"
689 if [ $enable_annot -gt 0 ] ; then
690 enable_annot="YES"
691 else
692 enable_annot="NO"
694 if [ $enable_bytecode -gt 0 ] ; then
695 enable_bytecode="YES"
696 else
697 enable_bytecode="NO"
699 if [ $enable_nativecode -gt 0 ] ; then
700 enable_nativecode="YES"
701 echo "WARNING: Native code version with dynlink requires ocaml >= 3.11"
702 else
703 enable_nativecode="NO"
705 if [ $enable_natdynlink -gt 0 ] ; then
706 enable_natdynlink="YES"
707 else
708 enable_natdynlink="NO"
710 if [ $enable_ocamlduce -gt 0 ] ; then
711 enable_ocamlduce="YES"
712 else
713 enable_ocamlduce="NO"
715 if [ $enable_newocamlnet -gt 0 ] ; then
716 enable_newocamlnet="YES"
717 else
718 enable_newocamlnet="NO"
720 if [ $enable_dbm -gt 0 ] ; then
721 enable_dbm="YES"
722 else
723 enable_dbm="NO"
725 if [ $enable_sqlite -gt 0 ] ; then
726 enable_sqlite="YES"
727 else
728 enable_sqlite="NO"
730 if [ $enable_camlzip -gt 0 ] ; then
731 enable_camlzip="YES"
732 else
733 enable_camlzip="NO"
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.
748 OCAMLFIND=ocamlfind
749 CAMLP4=camlp4
750 CAMLLEX=ocamllex
751 CAMLYACC=ocamlyacc
752 CAMLCNAME=ocamlc
753 CAMLOPTNAME=ocamlopt
754 CAMLMKTOPNAME=ocamlmktop
755 CAMLMKLIB=ocamlmklib
756 CAMLCPNAME=ocamlcp -p a # No: profiling is incompatible with the -pp option
757 CHOWN=chown
758 CC=gcc
760 CAMLINCLUDE=-I $ocamlinclude
762 ## The root directory for the package install (usually /)
763 #ROOT = $root
765 # Temporary root directory to install the package (usually always "" but for package makers)
766 TEMPROOT = $temproot
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)
810 OCSIGENNAME=$name
812 # ocsigen's logs:
813 LOGDIR = $root$logdir
815 # Config files:
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)
831 DEBUG=$enable_debug
833 # Do you want annot files? (-dtypes)
834 ANNOT=$enable_annot
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
862 SRC=$full_pwd
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):
870 PROFILING=NO
872 # Ocaml version
873 OCAMLVERSION=$ocamlversion
875 # Do not modify this
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
882 _EOF_
884 ######################################################################
885 # Finish
887 echo
890 echo
891 echo "Please check Makefile.config."
892 echo
893 echo "You can now compile Ocsigen by invoking"
894 echo " make depend"
895 echo " make"
896 echo
897 echo "Finally, if you want system-wide install, (become root if needed and) do"
898 echo " make install"
899 echo "to install the package, or"
900 echo " make installnodoc"
901 echo "to install the package without generating the documentation."