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
63 fail_library
"$1" "$2"
68 #######################################################################
93 version
=$
(head -n 1 $my_pwd/VERSION
)
96 ########################################################################
100 ehelp_debug
="Enable/disable debug output"
101 ehelp_annot
="Enable/disable .annot files"
102 ehelp_natdynlink
="Enable/disable nativecode dynamic linking"
103 whelp_ocamlduce
="Compile Ocamlduce support for typing pages"
105 ## Which options exist? eoptions for enable/disable, woptions for with/without:
106 eoptions
="debug annot natdynlink"
107 woptions
="ocamlduce preempt"
110 for opt
in $eoptions; do
113 uopt
=$
(echo $opt |
sed -e 's/_/-/g')
114 if [ $o -gt 0 ]; then
115 echo " --enable-$uopt"
117 echo " --disable-$uopt"
120 for opt
in $woptions; do
123 uopt
=$
(echo $opt |
sed -e 's/_/-/g')
124 if [ $o -gt 0 ]; then
127 echo " --without-$uopt"
131 "") bindir2
="<prefix>/bin";;
136 "") libdir2
="\$(shell \${OCAMLFIND} printconf destdir)";;
141 "") docdir2
="<prefix>/share/doc/\$(PROJECTNAME)";;
147 echo " --temproot $temproot"
148 echo " --prefix $prefix"
149 echo " --bindir $bindir2"
150 echo " --libdir $libdir2"
151 echo " --docdir $docdir2"
157 usage: ./configure [ options ]
159 --enable-debug, --disable-debug Enable/disable debug output
160 --enable-annot, --disable-annot Enable/disable .annot files generation
161 --enable-natdynlink, --disable-natdynlink Enable/disable nativecode dynamic linking
163 --with-preempt, --without-preempt compile with preemptive threads support.
164 --with-ocamlduce, --without-ocamlduce Compile ocamlduce based libraries.
166 --name=NAME The name of the library and ocamlfind package.
168 --root=DIR Root directory to install the package, every other options are relatives to this path. (usually /)
169 --temproot=DIR Temporary root directory to install the package (usually always "" but for package makers)
170 --prefix=DIR Subdirectory where to install binaries and libs (usually /usr or /usr/local)
172 --bindir=DIR Install binaries into this directory
173 --libdir=DIR Common directory for Ocsigen server's libraries
174 --docdir=DIR Install documentation in this directory
185 for x
in $eoptions; do
186 if [ "$x" = "$1" ]; then
190 echo "Unknown option: $1" >&2
196 for x
in $woptions; do
197 if [ "$x" = "$1" ]; then
201 echo "Unknown option: $1" >&2
206 echo "Welcome to Eliom version $version" >&2
208 while [ "$#" -gt 0 ]; do
211 opt
=$
(echo "$1" |
sed -e 's/--enable-//' -e 's/-/_/g')
217 opt
=$
(echo "$1" |
sed -e 's/--disable-//' -e 's/-/_/g')
219 eval "enable_$opt=-1"
223 opt
=$
(echo "$1" |
sed -e 's/--with-//' -e 's/-/_/g')
229 opt
=$
(echo "$1" |
sed -e 's/--without-//' -e 's/-/_/g')
270 echo "Unknown option: $1" >&2
276 "") bindir
="$prefix/bin";;
280 "") libdir
="\$(shell \${OCAMLFIND} printconf destdir)";;
281 *) libdir
=$root$libdir
285 "") docdir
="$prefix/share/doc/\$(PROJECTNAME)";;
289 check_binary ocamlc
"See: http://www.ocaml.org/"
291 check_ocamlversion
() {
293 echo -n "Checking for OCaml version... "
294 version
=$
(ocamlc
-version)
296 n1
=$
(echo $version |
sed 's/^\([0-9][0-9]*\)\..*$/\1/')
297 n2
=$
(echo $version |
sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/')
298 # n3=`echo $version | sed 's/^[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/'`
299 if [ $n1 -eq 3 ] && [ $n2 -lt 12 ]; then
301 echo "OCaml >= 3.12 is required. Aborting.";
307 check_ocsigenserverversion
() {
309 echo -n "Checking for ocsigenserver version... "
310 version
=$
(ocamlfind query ocsigenserver
-l |
grep version
: |
awk '{ print $2 }')
312 n1
=$
(echo $version |
sed 's/^\([0-9][0-9]*\)\..*$/\1/')
313 n2
=$
(echo $version |
sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\).*$/\1/')
314 # n3=`echo $version | sed 's/^[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/'`
315 if [ $n1 -eq 1 ] && [ $n2 -lt 91 ]; then
317 echo "Ocsigenserver >= 1.91 is required. Aborting.";
325 check_binary ocamlfind
"See: http://projects.camlcity.org/projects/findlib.html"
327 check_library ocsigenserver
"See: http://ocsigen.org/ocsigenserver/"
328 check_ocsigenserverversion
330 check_library deriving-ocsigen
"See: https://github.com/hnrgrgr/deriving"
332 check_binary js_of_ocaml
"See: http://ocsigen.org/js_of_ocaml"
333 check_library js_of_ocaml.deriving
"Missing support for deriving-ocsigen in js_of_ocaml"
335 check_library react
"See: http://erratique.ch/software/react"
337 check_library lwt
"See: http://ocsigen.org/lwt"
338 check_library lwt.unix
"Missing support for 'unix' in lwt."
339 check_library lwt.react
"Missing support for 'react' in lwt."
341 check_library calendar
"See: http://calendar.forge.ocamlcore.org/"
344 if [ "$with_ocamlduce" -gt 0 ]; then
345 if test_binary ocamlduce
; then
347 elif [ "$with_ocamlduce" -gt 1 ]; then
348 fail_binary ocamlduce
"http://ocamlduce.forge.ocamlcore.org/"
354 if [ "$with_ocamlduce" -gt 0 ]; then
355 check_library tyxml.duce
"Missing support for 'ocamlduce' in tyxml."
358 ######################################################################
362 echo "Effective options:"
366 #Convert 0/1 values to YES/NO
367 if [ $enable_debug -gt 0 ] ; then
372 if [ $enable_annot -gt 0 ] ; then
377 if [ $enable_natdynlink -gt 0 ] ; then
378 enable_natdynlink
="YES"
380 enable_natdynlink
="NO"
382 if [ $with_ocamlduce -gt 0 ] ; then
387 if [ $with_preempt -gt 0 ] ; then
393 ######################################################################
394 # Write Makefile.conf
396 echo "Writing Makefile.config"
397 cat <<_EOF_ > $my_pwd/Makefile.config
399 # The name of the library, ocamlfind package, etc.
402 #### External binaries ####
404 OCAMLFIND := ocamlfind
405 OCAMLMKLIB := ocamlmklib
406 JS_OF_OCAML := js_of_ocaml
411 OCAMLDUCEFIND := ocamlducefind
417 # Do you want the ocamlduce extension? YES/NO
418 # (You need ocamlduce to be installed)
419 OCAMLDUCE:=$with_ocamlduce
421 # Do you want preemptive threads ? YES/NO
422 PREEMPTIVE:=$with_preempt
424 # Do you want to use dynamic linking for native code? YES/NO
425 NATDYNLINK:=$enable_natdynlink
427 # Do you want debugging information (-g) ? YES/NO
430 # Do you want annot files (-dtypes) ? YES/NO
433 # Profiling (always put NO here - but if you want to debug eliom):
440 # Temporary root directory to install the package (usually always "" but for package makers)
443 # The directory for eliom compiler (binary):
444 BINDIR := $root$bindir
446 # Where to install Eliom libraries:
449 # Where to put Eliom documentation:
450 DOCDIR := $root$docdir
452 # The source directory (needed for local testing)
455 include \$(SRC)/Makefile.options
459 ######################################################################
464 echo "Please check Makefile.config."
466 echo "You can now compile Eliom by invoking:"
471 echo "You may want to test the extension before installation:"
473 echo " make run.local"
474 echo " make run.opt.local"
476 echo "Finally, if you want system-wide install, (become root if needed and) do"
479 echo " make install.doc"