Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 578 lines (540 sloc) 21.733 kB
22b433a @fperrin Don't assume that bash is in /bin
fperrin authored
1 #!/usr/bin/env bash
2
3 set -u
4 set -e
fccc685 Initial open-source release
MLstate authored
5
6 SCRIPTDIR=$(dirname $0)
7 cd $SCRIPTDIR
8 SCRIPTDIR=$PWD
9
10 SCRIPTNAME=$(basename $0)
11
12 # OS independent various variables
13 # Warning: only put in DEFAULT_PACKAGES what should be included in our binary package
70d19a7 [fix] installation_helper: camlidl and friends no longer installed by…
François-Régis Sinot authored
14 DEFAULT_PACKAGES=(ocaml findlib cryptokit camlzip ocamlgraph ulex ocaml-ssl)
96c8845 [feature] dependencies_helper: add ocaml-cairo package
Hugo Heuzard authored
15 ALL_PACKAGES=(ocaml findlib cryptokit camlzip ocamlgraph ulex openssl ocaml-ssl syslog jpeg libpng giflib camlimages mascot camlidl libnatpmp miniupnpc cairo-ocaml)
fccc685 Initial open-source release
MLstate authored
16
17 BUILD_DIR=$SCRIPTDIR/packages
18
19 # ##
20 # Bash setting and useful functions
21 # #####
22 shopt -s nullglob
23 msg_green () { echo "$@"; }
24 msg_red () { echo "$@"; }
25 msg_yellow () { echo "$@"; }
26 help () {
27 cat <<EOF
28
29 installation_helper.sh
30 helps download, patch, build and install the dependencies of OPA.
31
32 Usage:
33 $0 --prefix <dir> [options] [commands]
34
35 Options:
36 --prefix <dir> where ocaml and libs should expect to be installed (mandatory)
37 --installdir <dir> where to actually do the install (by default, the value of --prefix)
38 --packages 'pkg list' only install the specified packages
39 --sudo sudo before installation commands (see disclaimer)
40
41 Commands: (default choice underlined)
42 fetch download the archives for the packages to
43 $BUILD_DIR
44 unzip uncompress and patch the archives
45 install build and install the packages
46 lightclean make clean in all packages' directories
47 clean remove all contents of the work directory
48
49 Available packages: (default choice underlined)
50 $(for i in ${!ALL_PACKAGES[@]}; do
51 if grep -q "\(^\| \)${ALL_PACKAGES[i]}\( \|$\)" <<<${DEFAULT_PACKAGES[*]}
52 then printf "%-18s" "${ALL_PACKAGES[i]}"
53 else printf "%-10s" "${ALL_PACKAGES[i]}"
54 fi
55 [ $((i%6)) -eq 5 ] && echo -ne "\n\t" || echo -ne ' '
56 done)
57
58 Note:
59 All ocaml libs are compiled with and for the ocaml in the
60 given prefix. Therefore, ocaml should either be already there,
61 or you should include it first in your --packages. Also, some
62 packages depend on findlib to compile correctly.
63
64 Examples:
65 - Install all dependencies of opa to /opt/opa:
66 $ $0 --prefix /opt/opa --sudo
67 then, pass option -ocamlopt /opt/opa/bin/ocamlopt.opt to
68 opalang's ./configure script
69
70 - Install all dependencies in your home, when you don't have
71 administration rights:
72 $ $0 --prefix ~/opa
73 then, pass option -ocamlopt ~/opa/bin/ocamlopt.opt to
74 opalang's ./configure script
75
76 Disclaimer:
77 This script is provided because we think it may be useful, but
78 is provided WITHOUT SUPPORT, and you should know what you are
79 doing, especially if you want to install to a privileged
80 prefix like /usr/local. Using this script to install in /usr
81 would be a bad idea.
82
83 EOF
84 }
85
86 source ../platform_helper.sh
87
88 WINTOOLS=${WINTOOLS:-}
89 WINOCAMLC=$WINTOOLS/windows_ocamlc
90 WINOCAMLOPT=$WINTOOLS/windows_ocamlopt
91 WINOCAMLDEP=$WINTOOLS/windows_ocamldep
92 WINOCAMLMKLIB=$WINTOOLS/windows_ocamlmklib
93 WINOCAMLLEX=$WINTOOLS/windows_ocamllex
94
95 if [ -n "${ENFORCE_WINDOWS:-}" ];
96 then
97 msg_yellow "ENFORCE WINDOWS -> ocaml windows scripts"
98 export OCAMLC=$WINOCAMLC
99 export OCAMLOPT=$WINOCAMLOPT
100 export OCAMLDEP=$WINOCAMLDEP
101 export OCAMLMKLIB=$WINOCAMLMKLIB
102 export OCAMLLEX=$WINOCAMLLEX
103 export CAMLP4=camlp4
104 else
105 OCAMLC=ocamlc.opt
106 OCAMLOPT=ocamlopt.opt
107 OCAMLDEP=ocamldep.opt
108 OCAMLMKLIB=ocamlmklib
109 CAMLP4=camlp4
110 fi
111
112
113 PREFIX=
114 SUDO=
115 CLEAN=
116 FETCH=
117 UNZIP=
118 INSTALL=
119 LIGHTCLEAN=
120 while [ $# -gt 0 ]; do
121 case $1 in
122 --help) help; exit 0;;
123 --prefix)
124 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument"; exit 1; fi
125 shift
126 PREFIX="$1"
127 : ${INSTALLDIR:=$PREFIX}
128 ;;
129 --packages)
130 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument"; exit 1; fi
131 shift
132 PACKAGES=($1)
133 ;;
134 --installdir)
135 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument"; exit 1; fi
136 shift
137 INSTALLDIR="$1"
138 ;;
139 --sudo)
140 SUDO="sudo"
141 ;;
142 lightclean) LIGHTCLEAN=1;;
143 clean) CLEAN=1;;
144 fetch) FETCH=1;;
145 install) INSTALL=1;;
146 unzip) UNZIP=1;;
147 *)
148 echo "Error: unknown argument $1"; exit 1
149 esac
150 shift
151 done
152
153 PACKAGES=("${PACKAGES[@]:-${DEFAULT_PACKAGES[@]}}")
154
155 if [ -z "$CLEAN" ] && [ -z "$FETCH" ] && [ -z "$UNZIP" ] && [ -z "$INSTALL" ] && [ -z "$LIGHTCLEAN" ]; then
156 FETCH=1
157 UNZIP=1
158 INSTALL=1
159 fi
160 if [ -z "$PREFIX" ] && [ -n "$INSTALL" ]; then
161 help
162 echo "Error: you must specify the installation prefix" >&2
163 exit 1
164 fi
165
166 #FETCH=""
167 #CLEAN=""
168 #UNZIP=""
169
170 BUILD_DIR=$PWD/packages
171 mkdir -p $BUILD_DIR
172
173 sources () {
174 case $1 in
175 openssl) echo "http://www.openssl.org/source/openssl-1.0.0a.tar.gz";;
176 ocaml) echo "http://caml.inria.fr/pub/distrib/ocaml-3.12/ocaml-3.12.0.tar.gz" ;;
177 # Sources obtained thanks to "apt-get --print-uris source <package>"
178 findlib) echo "http://ftp.fr.debian.org/debian/pool/main/f/findlib/findlib_1.2.5+debian.orig.tar.gz";;
179 ocaml-ssl) echo "http://ftp.fr.debian.org/debian/pool/main/o/ocaml-ssl/ocaml-ssl_0.4.5.orig.tar.gz";;
180 cryptokit) echo "http://ftp.fr.debian.org/debian/pool/main/c/cryptokit/cryptokit_1.3.orig.tar.gz";;
181 ocamlgraph) echo "http://ftp.fr.debian.org/debian/pool/main/o/ocamlgraph/ocamlgraph_1.5.orig.tar.gz";;
182 camlzip) echo "http://ftp.fr.debian.org/debian/pool/main/c/camlzip/camlzip_1.04.orig.tar.gz";;
183 camlimages) echo "http://caml.inria.fr/distrib/bazar-ocaml/camlimages-3.0.2.tgz";;
184 ulex) echo "http://www.cduce.org/download/ulex-1.1.tar.gz";;
185 syslog) echo "http://homepage.mac.com/letaris/syslog-1.4.tar.gz";;
186 jpeg) echo "http://www.ijg.org/files/jpegsrc.v8b.tar.gz";;
187 libpng) echo "http://sourceforge.net/projects/libpng/files/libpng14/older-releases/1.4.3/libpng-1.4.3.tar.gz";;
188 giflib) echo "http://downloads.sourceforge.net/project/giflib/giflib%204.x/giflib-4.1.6/giflib-4.1.6.tar.gz";;
189 mascot) echo "http://mascot.x9c.fr/distrib/mascot-1.0-alpha.tar.gz";;
190 camlidl) echo "http://caml.inria.fr/pub/old_caml_site/distrib/bazar-ocaml/camlidl-1.05.tar.gz";;
191 libnatpmp) echo "http://miniupnp.free.fr/files/download.php?file=libnatpmp-20110103.tar.gz";;
192 miniupnpc) echo "http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.5.20110418.tar.gz";;
96c8845 [feature] dependencies_helper: add ocaml-cairo package
Hugo Heuzard authored
193 cairo-ocaml) echo "http://cgit.freedesktop.org/cairo-ocaml/snapshot/cairo-ocaml-master.tar.gz";;
fccc685 Initial open-source release
MLstate authored
194 *) msg_red "Error: don't know about package $1" >&2; exit 2
195 esac
196 }
197
198 package_dir () {
199 local p=$1
200 local dir=$(find . -maxdepth 1 -type d -name "$p-[0-9]*")
96c8845 [feature] dependencies_helper: add ocaml-cairo package
Hugo Heuzard authored
201 local dir="$dir "$(find . -maxdepth 1 -type d -name "$p-master")
fccc685 Initial open-source release
MLstate authored
202 echo $dir | (read a b; if [ -n "$b" ]; then
203 msg_red "Error: found several source directories for $p"
204 exit 12
205 fi)
206 echo $dir
207 }
208
209 install_generic () {
210 if [ "$(which $OCAMLC)" != "$INSTALLDIR/bin/$OCAMLC" ]; then
211 echo $OCAMLC x $PATH
212 msg_red "Error: fresh installed ocaml not found ($(which $OCAMLC) is not $INSTALLDIR/bin/$OCAMLC)"
213 exit 1
214 fi
215 if [ "$($OCAMLC -where)" != "$INSTALLDIR/lib/ocaml" ]; then
216 msg_red "Error: fresh installed ocaml not found (ocamlc -where returned $($OCAMLC -where) instead of $INSTALLDIR/lib/ocaml"
217 exit 1
218 fi
219 # Packages install themselves in $(ocamlc -where) automatically
220 if [ -x configure ]; then ./configure "$@"; fi
221 make all; r=$?
222 make allopt || make opt || make all.opt || [ $r -eq 0 ]
223 $SUDO make install-opt || $SUDO make install
224 }
225
226 package_install (){
227 if [ -n "${ENFORCE_WINDOWS:-}" ];
228 then
229 echo "INSTALLSYS WINDOWS"
230 WINPREFIX=`cygpath -u $PREFIX`
231 WINCAMLLIBDIR="$WINPREFIX/lib"
232 OLDPATH=$PATH
233 export PATH=/cygdrive/c/ocamlms/bin/:$PATH
234 case $1 in
235 ocaml)
236 # caml_sed_patch
237 # PREFIX is hard coded as C:/ocamlms
238 cp config/m-nt.h config/m.h
239 cp config/s-nt.h config/s.h
240 cp config/Makefile.msvc config/Makefile
241 make -f Makefile.nt clean
242 # rm -rf otherlibs/labltk/
243 make -f Makefile.nt world
244 # make -f Makefile.nt bootstrap
245 # make -f Makefile.nt clean
246 # make -f Makefile.nt world
247 make -f Makefile.nt opt opt.opt
248 make -f Makefile.nt install
249 #missing ocamlrun.lib => replaced by libcamlrun.lib
250 export PATH=$WINPREFIX/bin:${PATH}
251 export OCAMLLIB=$WINCAMLLIBDIR
252 export OCAMLC=$WINOCAMLC
253 export OCAMLOPT=$WINOCAMLOPT
254 export OCAMLDEP=$WINOCAMLDEP
255 export OCAMLMKLIB=$WINOCAMLMKLIB
256 export OCAMLLEX=$WINOCAMLLEX
257 export CAMLP4=camlp4
258 ;;
259 findlib)
260 #valid
261 ./configure -sitelib $PREFIX/lib
262 make all opt install clean
263 ;;
264 camlzip)
265 #valid
266 # library is call camlzip instead of zip
267 CAMLLIBDIR=$WINCAMLLIBDIR ZLIB_LIBDIR=/windows_libs/zlib ZLIB_INCLUDE=$PWD/../../../ms_windows/zlib make -f Makefile.nt clean all allopt install
268 CAMLLIBDIR=$WINCAMLLIBDIR ZLIB_LIBDIR=/windows_libs/zlib ZLIB_INCLUDE=$PWD/../../../ms_windows/zlib make -f Makefile.nt installopt || true
269 install -m 0644 -v zlib.cm* $WINCAMLLIBDIR/zip
270 ;;
271 ocamlgraph)
272 ./configure --prefix $WINPREFIX # should pass all var to have cross compilation
273 make -f Makefile.nt clean
274 # let the time do its job :) do not merge the two or prepare to a headache
275 make -f Makefile.nt byte opt install-byte install-opt
276 ;;
277 cryptokit)
278 make -f Makefile.win32 all allopt
279 make -f Makefile.win32 install
280 ;;
281 ocaml-ssl)
282 #valid but ugly
283 # just for generating the META file and Makefile
284 # ,does not work with PATH because of cl.exe problems with libs
285 PATH=$OLDPATH ./configure
286 export OCAMLMKLIB="$OCAMLMKLIB -LC:/cygwin/windows_libs/openssl/lib"
287 # seems horrible ? simpler than patching everything
288 make -e byte || true
289 make -e opt || true
290 make -e install || true
291 cp src/*.lib $PREFIX/lib/ssl # because ocamlfind ignores .lib files
292 ;;
293 camlidl)
294 sed -ie "s%^OCAMLLIB=.*%OCAMLLIB=$WINPREFIX/lib/ocaml%; s%^BINDIR=.*%BINDIR=$WINPREFIX/bin%" \
295 config/Makefile.win32 > config/Makefile
296 make all
297 make install
298 ;;
299 libnatpmp)
300 make -f Makefile.windows all
301 TMPP=$PREFIX/lib/libnatpmp
302 mkdir -p $TMPP
303 cp libnatpmp.a $TMPP
304 TMPP=$PREFIX/include/libnatpmp
305 mkdir -p $TMPP
306 cp *.h $TMPP
307 ;;
308 miniupnpc)
309 INSTALLPREFIX=$PREFIX make -f Makefile.windows all
310 TMPP=$PREFIX/lib/miniupnpc
311 mkdir -p $TMPP
312 cp libminiupnpc.a $TMPP
313 TMPP=$PREFIX/include/miniupnpc
314 mkdir -p $TMPP
315 cp *.h $TMPP
316 ;;
317 ulex)
318 rm -f myocamlbuild.ml
319 install_generic
320 ;;
96c8845 [feature] dependencies_helper: add ocaml-cairo package
Hugo Heuzard authored
321 cairo-ocaml)
322 aclocal -I support
323 autoconf
e83d1d9 [enhance] dependencies: patch for cairo-ocaml
Mathieu Barbin authored
324 ./configure --prefix $PREFIX --without-gtk --without-libsvg_cairo --without-libpangocairo
96c8845 [feature] dependencies_helper: add ocaml-cairo package
Hugo Heuzard authored
325 make
326 make install
327 ;;
fccc685 Initial open-source release
MLstate authored
328 *)
329 msg_yellow "Install $1 by hand"
330 msg_yellow "TODO : check $1 installation"
331 exit 1
332 ;;
333 esac
334 else
335 case $1 in
336 ocaml)
337 [ $IS_WINDOWS ] && CYGOPT="-tk-no-x11 -no-tk"
338 ./configure -prefix $PREFIX ${CYGOPT:-}
339 make world # clean world
340 make bootstrap
7de4ee0 @fperrin New platform: `FreeBSD'
fperrin authored
341 if [ $IS_LINUX ] || [ $IS_MAC ] || [ $IS_FREEBSD ]; then
fccc685 Initial open-source release
MLstate authored
342 make opt && make opt.opt
343 fi
344 PREFIX=$INSTALLDIR $SUDO make install -e
345 ;;
346 camlzip)
347 make all allopt
348 $SUDO make install installopt
349 $SUDO install -m 0644 -v zlib.cm* $($OCAMLC -where)/zip
350 ;;
351 ocaml-ssl)
352 $SUDO $INSTALLDIR/bin/ocamlfind remove -destdir $INSTALLDIR/lib/ocaml ssl || true
353 install_generic
354 ;;
355 findlib)
356 install_generic -sitelib $INSTALLDIR/lib/ocaml
357 ;;
358 camlimages)
359 touch src/oXpm.cmi || true # camlimages wants that even if we tell him not...
360 ./configure --with-ocamlfind=no --enable-native-library --enable-bytecode-library --with-jpeg --with-png --with-gif --without-lablgtk --without-lablgtk2 --without-freetype --without-xpm --without-tiff --without-x --without-gs --prefix $INSTALLDIR \
361 CFLAGS=-I$INSTALLDIR/include LDFLAGS=-L$INSTALLDIR/lib
362 make
363 $SUDO make install
364 ;;
365 ulex)
366 $SUDO $INSTALLDIR/bin/ocamlfind remove -destdir $INSTALLDIR/lib/ocaml ulex || true
367 rm -f myocamlbuild.ml
f9c07eb [bug fix] build: installation_helper now correctly installs ulex with…
Valentin Gatien-Baron authored
368 make all.opt
369 # the following is copy pasted from ulex's Makefile
370 # because install depends on all (it just does't work
371 # when your rights for compiling and installing are not compatible)
372 cd _build && $SUDO make -f ../Makefile realinstall
fccc685 Initial open-source release
MLstate authored
373 ;;
374 jpeg)
375 ./configure --prefix $PREFIX
376 make
377 $SUDO make install
378 ;;
379 libpng)
380 ./configure --prefix $PREFIX
381 make
382 $SUDO make install
383 ;;
384 giflib)
385 ./configure --prefix $PREFIX
386 make
387 $SUDO make install
388 ;;
389 mascot)
390 sh configure -ocaml-prefix $INSTALLDIR
391 $SUDO make all install -e
392 ;;
393 camlidl)
394 sed -e "s%^OCAMLLIB=.*%OCAMLLIB=$INSTALLDIR/lib/ocaml%; s%^BINDIR=.*%BINDIR=$INSTALLDIR/bin%" \
395 config/Makefile.unix > config/Makefile
396 make -e all
397 $SUDO make -e install
398 ;;
399 libnatpmp)
400 make -e
401 # custom installation
402 LIBDIR=$INSTALLDIR/lib/ocaml
403 $SUDO mkdir -p $LIBDIR
404 $SUDO cp libnatpmp.a $LIBDIR
405 INCLUDE=$INSTALLDIR/include/libnatpmp
406 $SUDO mkdir -p $INCLUDE
407 $SUDO cp *.h $INCLUDE
408 ;;
409 miniupnpc)
410 INSTALLPREFIX=$INSTALLDIR make -e
411 LIBDIR=$INSTALLDIR/lib/ocaml
412 $SUDO mkdir -p $LIBDIR
413 $SUDO cp libminiupnpc.a $LIBDIR
414 INCLUDE=$INSTALLDIR/include/miniupnpc
415 $SUDO mkdir -p $INCLUDE
416 $SUDO cp *.h $INCLUDE
417 ;;
96c8845 [feature] dependencies_helper: add ocaml-cairo package
Hugo Heuzard authored
418 cairo-ocaml)
419 aclocal -I support
420 autoconf
e83d1d9 [enhance] dependencies: patch for cairo-ocaml
Mathieu Barbin authored
421 ./configure --prefix $PREFIX --without-gtk --without-libsvg_cairo --without-libpangocairo
96c8845 [feature] dependencies_helper: add ocaml-cairo package
Hugo Heuzard authored
422 make
423 $SUDO make install
424 ;;
fccc685 Initial open-source release
MLstate authored
425 *)
426 install_generic
427 esac
428 fi
429 }
430
431 if [ -n "$CLEAN" ]; then
432 msg_yellow "$SCRIPTNAME: Cleaning source"
433 for p in "${PACKAGES[@]}"; do
434 msg_green "[ PACKAGE: $p (clean-up) ]"
435 dir=$(package_dir $p)
436 rm -rf $BUILD_DIR/$dir
437 done
438 msg_green "Remove building directory $BUILD_DIR"
439 rm -fr $BUILD_DIR/*
440 fi
441
442 if [ -n "$LIGHTCLEAN" ]; then
443 msg_yellow "Cleaning packages configurations"
444 cd $BUILD_DIR/
445 for p in "${PACKAGES[@]}"; do
446 dir=$(package_dir $p)
447 if [ -z $dir ]; then
448 msg_green "[ PACKAGE: $p (skip clean) ]"
449 else
450 msg_green "[ PACKAGE: $p (make clean) ]"
451 echo "dir: $dir"
452 cd $dir
453 make clean
454 cd -
455 fi
456 done
457 msg_green "make general configuration clean done."
458 cd $SCRIPTDIR
459 fi
460
461 if [ -n "$FETCH" ]; then
462 msg_green "$SCRIPTNAME: Downloading packages"
463 cd $BUILD_DIR
464 for p in "${PACKAGES[@]}"; do
465 msg_green "[ PACKAGE: $p (download) ]"
466 src=$(sources $p)
467 wget -N "$src"
468 ## some lib are downloaded via a php script, we need to clean the string from 'source' a little
469 tgz0=$(basename "$src")
470 tgz=${tgz0#download.php\?file=}
471 [ "$tgz0" != "$tgz" ] && [ -f "$tgz0" ] && mv "$tgz0" "$tgz"
472 ## remove existing extracted directories
473 packfile=$(tar -tzf $tgz 2>/dev/null | head -n 1)
474 packdir=$(pwd)/${packfile%%/*}
475 rm -rf $BUILD_DIR/${packdir#$BUILD_DIR}
476 done
477 cd $SCRIPTDIR
478 fi
479
480 if [ -n "$UNZIP" ]; then
481 msg_green "$SCRIPTNAME: Uncompressing & patching"
482 cd $BUILD_DIR
483 for p in "${PACKAGES[@]}"; do
484 msg_green "[ PACKAGE: $p (uncompressing) ]"
485 echo "Uncompressing..."
486 ## retrieve the file name
487 tgz=$(basename "$(sources $p)")
488 tgz=${tgz#download.php\?file=}
489 ## uncompress
490 tar -xzf $tgz
491 ## patch
492 packdir=$(pwd)/$(package_dir $p)
493 cd $packdir
494 if [ $IS_WINDOWS ]; then
495 for df in $SCRIPTDIR/patches/${p}_*.patch.windows; do
496 echo "Applying patch $df from $packdir"
497 patch -Np1 < $df || (msg_red "Error: patch $df did not apply"; exit 3)
498 done
499 fi
500 for df in $SCRIPTDIR/patches/${p}_*.patch; do
501 echo "Applying patch $df from $packdir"
502 patch -Np1 < $df || (msg_red "Error: patch $df did not apply"; exit 3)
503 done
504 echo "Uncompressed $SCRIPTNAME to $packdir"
505 cd $BUILD_DIR
506 done
507 cd $SCRIPTDIR
508 fi
509
510 setup_local_ocaml () {
511 #
512 # Here we attempt to relocate ocaml, which is not an easy task. Beware the hacks.
513 # (no $SUDO here, relocation is not supposed to be needed if we are already
514 # installing to a privileged place)
515 if [ -d $INSTALLDIR/lib/ocaml ] && [ "$PREFIX" != "$INSTALLDIR" ]; then
516 # Update ld.conf for the temporary location
517 # (this is reverted last thing in this script)
518 HAS_PATCHED_OCAML_LD_CONF=1
519 sed -i "s%^$PREFIX%$INSTALLDIR%" $INSTALLDIR/lib/ocaml/ld.conf
520 # The following are not needed in our binary package, so we
521 # don't care about reverting the changes (we clean them up
522 # before making the package)
523 #
524 # The bytecode exes refer to an interpreter that is not installed (<prefix>/bin/ocamlrun).
525 sed -i '1s%#!'$PREFIX'/bin/ocamlrun%#!'$INSTALLDIR'/bin/ocamlrun%' $INSTALLDIR/bin/*
526 # ocamlmklib doesn't play nice, we wrap them to add options
527 if [ ! -e $INSTALLDIR/bin/ocamlmklib-bin ]; then
528 mv $INSTALLDIR/bin/ocamlmklib $INSTALLDIR/bin/ocamlmklib-bin
529 echo -e '#!/bin/sh\nexec '$INSTALLDIR/bin/ocamlmklib-bin' -ocamlc '$INSTALLDIR/bin/ocamlc' -ocamlopt '$INSTALLDIR/bin/ocamlopt' "$@"' >$INSTALLDIR/bin/ocamlmklib
530 chmod a+x $INSTALLDIR/bin/ocamlmklib
531 fi
532 # camlp4 needs a shared library (dllunix, what for ??) that
533 # isn't yet in normal library search paths
534 for f in $INSTALLDIR/bin/camlp4*; do
535 if [ $f = ${f%.opt} ] && [ ! -e $f-bin ]; then
536 mv $f $f-bin
537 echo -e '#!/bin/sh\nLD_LIBRARY_PATH='$INSTALLDIR/lib/ocaml/stublibs':$LD_LIBRARY_PATH exec '$f-bin' "$@"' >$f
538 chmod a+x $f
539 fi
540 done
541 fi
542 msg_yellow "Extending path to find the proper ocaml (at $INSTALLDIR/bin)"
543 export PATH=$INSTALLDIR/bin:$PATH
544 # export LD_LIBRARY_PATH=$INSTALLDIR/lib/ocaml:$INSTALLDIR/lib/ocaml/stublibs/$LD_LIBRARY_PATH
545 msg_yellow "Setting OCAMLLIB to the proper location ($INSTALLDIR/lib/ocaml)"
546 export OCAMLLIB=$INSTALLDIR/lib/ocaml
547 export OCAMLOPT=$INSTALLDIR/bin/ocamlopt.opt
548 export OCAMLFIND_INSTFLAGS="-destdir $INSTALLDIR/lib/ocaml"
549 }
550
551 if [ -n "$INSTALL" ]; then
552 msg_green "$SCRIPTNAME: Building & install"
553 for i in ${!PACKAGES[@]}; do
554 if [ -z "${setup_done:-}" ] && ! grep -q "\(^\| \)ocaml\( \|$\)" <<<${PACKAGES[*]:$i}; then
555 setup_local_ocaml
556 setup_done=1
557 fi
558 p="${PACKAGES[$i]}"
559 cd $BUILD_DIR
560 msg_yellow "entering build directory $BUILD_DIR"
561 msg_green "[ PACKAGE: $p (building and installing) ]"
562 dir=$(package_dir $p)
563 echo "Directory: $dir"
564 cd $dir
565 echo "Package: $p"
566 package_install $p
567 cd $SCRIPTDIR
568 msg_yellow "leaving build directory"
569 done
570 fi
571
572 if [ -n "${HAS_PATCHED_OCAML_LD_CONF:-}" ]; then
573 msg_yellow "Reverting temporary modification of ocaml's ld.conf used for building the libs"
574 sed -i "s%^$INSTALLDIR%$PREFIX%" $INSTALLDIR/lib/ocaml/ld.conf
575 fi
576
577 msg_green "$SCRIPTNAME: done"
Something went wrong with that request. Please try again.