3 # Adapted from the ocamlnet configure script.
5 #######################################################################
9 # $1: the name of the binary
10 echo -n "Checking for $1 ... "
11 if which "$1" >/dev
/null
2>/dev
/null
; then
22 echo "Required command '$1' not found!"
23 [ -z "$2" ] ||
echo "===> $2"
28 # $1: the name of the binary
30 if test_binary
$1; then
39 # $1: the name of the library (findlib)
40 echo -n "Checking for $1 ... "
41 if ocamlfind query
$1 >/dev
/null
2>/dev
/null
; then
52 echo "Required library $1 not found!"
53 [ -z "$2" ] ||
echo "===> $2"
58 # $1: the name of the library (findlib)
60 if test_library
$1; then
67 #######################################################################
90 sysconfdir
="/etc/\$(PROJECTNAME)"
91 staticpagesdir
="/var/www/\$(PROJECTNAME)"
93 datadir
="/var/lib/\$(PROJECTNAME)"
96 ocsigen_user
="www-data"
97 ocsigen_group
="www-data"
102 version
=`head -n 1 $my_pwd/VERSION`
105 ########################################################################
108 ## Which options exist? eoptions for enable/disable, woptions for with/without:
109 eoptions
="debug annot natdynlink"
110 woptions
="sqlite dbm camlzip preempt"
113 for opt
in $eoptions; do
116 uopt
=`echo $opt | sed -e 's/_/-/g'`
117 if [ $o -gt 0 ]; then
118 echo " --enable-$uopt"
120 echo " --disable-$uopt"
123 for opt
in $woptions; do
126 uopt
=`echo $opt | sed -e 's/_/-/g'`
127 if [ $o -gt 0 ]; then
130 echo " --without-$uopt"
134 "") bindir2
="<prefix>/bin";;
139 "") logdir2
="<prefix>/var/log/<name>";;
144 "") libdir2
="\$(shell \${OCAMLFIND} printconf destdir)";;
149 "") mandir2
="<prefix>/share/man/man1";;
154 "") docdir2
="<prefix>/share/doc/\$(PROJECTNAME)";;
160 echo " --temproot $temproot"
161 echo " --prefix $prefix"
162 echo " --ocsigen-user $ocsigen_user"
163 echo " --ocsigen-group $ocsigen_group"
164 echo " --bindir $bindir2"
165 echo " --libdir $libdir2"
166 echo " --sysconfdir $sysconfdir"
167 echo " --mandir $mandir2"
168 echo " --docdir $docdir2"
169 echo " --logdir $logdir2"
170 echo " --staticpagesdir $staticpagesdir"
171 echo " --uploaddir $uploaddir"
172 echo " --datadir $datadir"
173 echo " --commandpipe $commandpipe"
180 usage: ./configure [ options ]
182 --enable-debug, --disable-debug Enable/disable debug output
183 --enable-annot, --disable-annot Enable/disable .annot files generation
184 --enable-natdynlink, --disable-natdynlink Enable/disable nativecode dynamic linking
186 --with-sqlite, --without-sqlite Compile ocsipersist with SQLite for persistent storage
187 --with-dbm, --without-dbm Compile ocsipersist with DBM for persistent storage
188 --with-camlzip, --without-camlzip Compile deflatemod extension, requires camlzip
190 --name=NAME The name of the server binary and ocamlfind package.
192 --ocsigen-user=NAME The name of the ocsigen user
193 --ocsigen-group=NAME The name of the ocsigen group
195 --root=DIR Root directory to install the package, every other options are relatives to this path. (usually /)
196 --temproot=DIR Temporary root directory to install the package (usually always "" but for package makers)
197 --prefix=DIR Subdirectory where to install binaries and libs (usually /usr or /usr/local)
199 --bindir=DIR Install binaries into this directory
200 --libdir=DIR Common directory for Ocsigen server's libraries
202 --sysconfdir=DIR Create configuration files in this directory
203 --mandir=DIR Install man pages in this directory
204 --docdir=DIR Install documentation in this directory
206 --logdir=DIR Use this directory for Ocsigen's logs
207 --datadir=DIR The directory for data written by the server
209 --staticpagesdir=DIR Install default static pages in this directory
210 --uploaddir=DIR By default, files will be uploaded in this directory
212 --commandpipe=FILE The name of the named pipe used to command the server
223 for x
in $eoptions; do
224 if [ "$x" = "$1" ]; then
228 echo "Unknown option: $1" >&2
234 for x
in $woptions; do
235 if [ "$x" = "$1" ]; then
239 echo "Unknown option: $1" >&2
243 echo "\n\tWelcome to Ocsigen server, version $version.\n" >&2
245 while [ "$#" -gt 0 ]; do
248 opt
=`echo "$1" | sed -e 's/--enable-//' -e 's/-/_/g'`
254 opt
=`echo "$1" | sed -e 's/--disable-//' -e 's/-/_/g'`
256 eval "enable_$opt=-1"
260 opt
=`echo "$1" | sed -e 's/--with-//' -e 's/-/_/g'`
266 opt
=`echo "$1" | sed -e 's/--without-//' -e 's/-/_/g'`
352 echo "Unknown option: $1" >&2
358 "") bindir
="$prefix/bin";;
362 "") logdir
="/var/log/\$(PROJECTNAME)";;
366 "") libdir
="\$(shell \${OCAMLFIND} printconf destdir)";;
367 *) libdir
=$root$libdir
371 "") mandir
="$prefix/share/man/man1";;
375 "") docdir
="$prefix/share/doc/\$(PROJECTNAME)";;
378 case "$commandpipe" in
379 "") commandpipe
="/var/run/\$(PROJECTNAME)_command";;
384 check_binary ocamlc
"See: http://www.ocaml.org/"
386 check_ocamlversion
() {
388 echo -n "Checking for OCaml version... "
389 version
=`ocamlc -version`
391 n1
=`echo $version | sed 's/^\([0-9][0-9]*\)\..*$/\1/'`
392 n2
=`echo $version | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/'`
393 # n3=`echo $version | sed 's/^[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/'`
394 if [ $n1 -eq 3 ] && [ $n2 -lt 12 ]; then
396 echo "OCaml >= 3.12 is required. Aborting.";
404 check_binary ocamlfind
"See: http://projects.camlcity.org/projects/findlib.html"
406 check_library react
"See: http://erratique.ch/software/react"
407 check_library ssl
"See: http://sourceforge.net/projects/savonet/files/ocaml-ssl"
409 check_library lwt
"See: http://ocsigen.org/lwt"
410 check_library lwt.unix
"Missing support for 'unix' in lwt."
411 check_library lwt.react
"Missing support for 'react' in lwt."
412 check_library lwt.ssl
"Missing support for 'ssl' in lwt."
413 #check_library lwt.extra "Missing support for 'extra' in lwt."
415 check_library netstring \
416 "See ocamlnet: http://projects.camlcity.org/projects/ocamlnet.html"
417 check_library netsys \
418 "See ocamlnet: http://projects.camlcity.org/projects/ocamlnet.html"
420 check_library pcre
"See: http://ocaml.info/home/ocaml_sources.html"
421 check_library cryptokit
"See: http://pauillac.inria.fr/~xleroy/software.html#cryptokit"
423 check_library tyxml
"See: http://ocsigen.org/tyxml/"
426 case "$with_sqlite" in
427 1) if test_library sqlite3
; then with_sqlite
=1; else with_sqlite
=0; fi;;
428 2) check_library sqlite3
"See: http://ocaml.info/home/ocaml_sources.html";;
432 if [ "$with_dbm" -gt 0 ]; then
433 if test_library dbm
; then
435 elif [ "$with_dbm" -gt 1 ]; then
443 if [ "$with_camlzip" -gt 0 ]; then
444 if test_library camlzip
; then
446 elif test_library
zip; then
448 elif [ "$with_camlzip" -gt 1 ]; then
449 fail_library camlzip
"https://forge.ocamlcore.org/projects/camlzip/"
456 if [ "$with_preempt" -gt 0 ]; then
457 if test_library lwt.extra
; then
459 elif [ "$with_preempt" -gt 1 ]; then
460 fail_library lwt.extra
"Missing support for 'extra' in lwt."
466 if [ "$with_sqlite" -eq 1 ] && [ "$with_preempt" -eq -1 ]; then
467 echo "preemptive threads are needed by sqlite, enable it with -with-preempt"
471 # Check rlwrap or ledit
472 if test_binary rlwrap
; then
474 elif test_binary ledit
; then
480 ######################################################################
484 echo "Effective options:"
489 #Convert 0/1 values to YES/NO
490 if [ $enable_debug -gt 0 ] ; then
495 if [ $enable_annot -gt 0 ] ; then
500 if [ $enable_natdynlink -gt 0 ] ; then
501 enable_natdynlink
="YES"
503 enable_natdynlink
="NO"
505 if [ $with_dbm -gt 0 ] ; then
510 if [ $with_sqlite -gt 0 ] ; then
515 if [ $with_camlzip -gt 0 ] ; then
520 if [ $with_preempt -gt 0 ] ; then
526 ocamlinclude
=`ocamlfind printconf stdlib`
528 ######################################################################
529 # Write Makefile.conf
531 echo "Writing Makefile.config"
532 cat <<_EOF_ > $my_pwd/Makefile.config
534 # The name of the server, the ocamlfind package, etc.
537 #### External binaries ####
539 OCAMLFIND := ocamlfind
541 OCAMLMKLIB:= ocamlmklib
553 # User who will run Ocsigen server (not root) (eg, for debian, www-data)
554 # (This user must exist on your system)
555 OCSIGENUSER := $ocsigen_user
557 # group who will run Ocsigen server (not root) (eg, for debian, www-data)
558 # (This group must exist)
559 OCSIGENGROUP := $ocsigen_group
561 # Do you want deflatemod? YES/NO (requires camlzip)
562 CAMLZIP:=$with_camlzip
564 # The name of camlzip package:
565 CAMLZIPNAME:=$zipname
567 # Do you want ocsipersist with sqlite? YES/NO
568 OCSIPERSISTSQLITE:=$with_sqlite
570 # Do you want ocsipersist with dbm? YES/NO
571 OCSIPERSISTDBM:=$with_dbm
573 # Do you want preemptive threads ? YES/NO
574 PREEMPTIVE:=$with_preempt
576 # Do you want debugging information (-g) ? YES/NO
579 # Do you want annot files (-dtypes) ? YES/NO
582 # Profiling (always put NO here - but if you want to debug ocsigen):
589 # Temporary root directory to install the package (usually always "" but for package makers)
590 TEMPROOT := $temproot
592 # Do you want to use dynamic linking for native code? YES/NO
593 NATDYNLINK:=$enable_natdynlink
595 # The directory for ocsigen server (binary):
596 BINDIR := $root$bindir
598 # The directory for ocsigen manpage:
599 MANDIR := $root$mandir
601 # Where to install the libraries
605 LOGDIR := $root$logdir
608 CONFIGDIR := $root$sysconfdir
610 # Where to put static pages:
611 STATICPAGESDIR := $root$staticpagesdir
613 # Where to put dynamic data:
614 DATADIR := $root$datadir
616 # Default directory for file upload:
617 UPLOADDIR := $root$uploaddir
619 # Where to put Ocsigen documentation:
620 DOCDIR := $root$docdir
622 # The name of the named pipe used to command the server
623 COMMANDPIPE := $root$commandpipe
625 # The source directory
628 include \$(SRC)/Makefile.options
631 ######################################################################
636 echo "Please check Makefile.config."
638 echo "You can now compile Ocsigen Server by invoking:"
643 echo "You may want to test the server before installation:"
645 echo " make run.local"
646 echo " make run.opt.local"
648 echo "Finally, if you want system-wide install, (become root if needed and) do:"
651 echo " make install.doc"