summaryrefslogtreecommitdiff
path: root/build/install.sh
blob: 2197069c5b3893a2a6e721c0d49496505b653dfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
#!/bin/sh

#########################################################################
#                                                                       #
#                            Objective Caml                             #
#                                                                       #
#       Nicolas Pouillard, projet Gallium, INRIA Rocquencourt           #
#                                                                       #
#   Copyright 2007 Institut National de Recherche en Informatique et    #
#   en Automatique.  All rights reserved.  This file is distributed     #
#   under the terms of the Q Public License version 1.0.                #
#                                                                       #
#########################################################################

# $Id$

set -e

cd `dirname $0`/..

. config/config.sh

not_installed=$PWD/_build/not_installed

rm -f "$not_installed"
touch "$not_installed"

wontinstall() {
  echo "$1" >> "$not_installed"
  echo "  don't install $1"
}

installbin() {
  if [ -f "$1" ]; then
    echo "  install binary $2"
    cp -f "$1" "$2"
    [ -x "$2" ] || chmod +x "$2"
  else
    wontinstall "$1"
  fi
}

installbestbin() {
  if [ -f "$1" ]; then
    echo "  install binary $3 (with `basename $1`)"
    cp -f "$1" "$3"
  else
    if [ -f "$2" ]; then
      echo "  install binary $3 (with `basename $2`)"
      cp -f "$2" "$3"
    else
      echo "None of $1, $2 exists"
      exit 3
    fi
  fi
  [ -x "$3" ] || chmod +x "$3"
}

installlib() {
  if [ -f "$1" ]; then
    dest="$2/`basename $1`"
    echo "  install library $dest"
    cp -f "$1" "$2"
    if [ "$RANLIB" != "" ]; then
      "$RANLIB" "$dest"
    fi
  else
    wontinstall "$1"
  fi
}

installdir() {
  args=""
  while [ $# -gt 1 ]; do
    if [ -f "$1" ]; then
      args="$args $1"
    else
      wontinstall "$1"
    fi
    shift
  done
  last="$1"
  for file in $args; do
    echo "  install $last/`basename $file`"
    cp -f "$file" "$last"
  done
}

installlibdir() {
  args=""
  while [ $# -gt 1 ]; do
    args="$args $1"
    shift
  done
  last="$1"
  for file in $args; do
    installlib "$file" "$last"
  done
}

mkdir -p $BINDIR
mkdir -p $LIBDIR
mkdir -p $LIBDIR/caml
mkdir -p $LIBDIR/camlp4
mkdir -p $LIBDIR/vmthreads
mkdir -p $LIBDIR/threads
mkdir -p $LIBDIR/labltk
mkdir -p $LIBDIR/ocamlbuild
mkdir -p $LIBDIR/ocamldoc
mkdir -p $LIBDIR/ocamldoc/custom
mkdir -p $STUBLIBDIR
mkdir -p $MANDIR/man1
mkdir -p $MANDIR/man3
mkdir -p $MANDIR/man$MANEXT

echo "Installing core libraries..."
installlibdir byterun/libcamlrun.$A asmrun/libasmrun.$A asmrun/libasmrunp.$A \
              $LIBDIR
installdir byterun/libcamlrun_shared$EXT_DLL $LIBDIR

PUBLIC_INCLUDES="\
  alloc.h callback.h config.h custom.h fail.h intext.h \
  memory.h misc.h mlvalues.h printexc.h signals.h compatibility.h"

cd byterun
for i in $PUBLIC_INCLUDES; do
  echo "  install caml/$i"
  sed -f ../tools/cleanup-header $i > $LIBDIR/caml/$i
done
cd ..

WIN32=""
if [ "x$EXE" = "x.exe" ]; then
  installbin win32caml/ocamlwin.exe $PREFIX/OCamlWin.exe
  WIN32=win32
fi

installdir otherlibs/"$WIN32"unix/unixsupport.h \
           otherlibs/bigarray/bigarray.h \
           $LIBDIR/caml

installdir yacc/ocamlyacc$EXE byterun/ocamlrun$EXE $BINDIR

installdir config/Makefile $LIBDIR/Makefile.config
installdir byterun/ld.conf $LIBDIR

cd _build

echo "Installing the toplevel and compilers..."
installbin ocaml$EXE $BINDIR/ocaml$EXE
installbin ocamlc$EXE $BINDIR/ocamlc$EXE
installbin ocamlopt$EXE $BINDIR/ocamlopt$EXE
installbin ocamlc.opt$EXE $BINDIR/ocamlc.opt$EXE
installbin ocamlopt.opt$EXE $BINDIR/ocamlopt.opt$EXE

set=set # coloration workaround

echo "Installing the standard library..."
installdir \
  stdlib/stdlib.cma \
  stdlib/stdlib.cmxa stdlib/stdlib.p.cmxa \
  stdlib/camlheader \
  stdlib/camlheader_ur \
  stdlib/std_exit.cm[io] stdlib/std_exit.ml \
  stdlib/arg.cmi stdlib/arg.ml stdlib/arg.mli \
  stdlib/array.cmi stdlib/array.ml stdlib/array.mli \
  stdlib/arrayLabels.cmi stdlib/arrayLabels.ml stdlib/arrayLabels.mli \
  stdlib/buffer.cmi stdlib/buffer.ml stdlib/buffer.mli \
  stdlib/callback.cmi stdlib/callback.ml stdlib/callback.mli \
  stdlib/camlinternalLazy.cmi stdlib/camlinternalLazy.ml stdlib/camlinternalLazy.mli \
  stdlib/camlinternalMod.cmi stdlib/camlinternalMod.ml stdlib/camlinternalMod.mli \
  stdlib/camlinternalOO.cmi stdlib/camlinternalOO.ml stdlib/camlinternalOO.mli \
  stdlib/char.cmi stdlib/char.ml stdlib/char.mli \
  stdlib/complex.cmi stdlib/complex.ml stdlib/complex.mli \
  stdlib/digest.cmi stdlib/digest.ml stdlib/digest.mli \
  stdlib/filename.cmi stdlib/filename.ml stdlib/filename.mli \
  stdlib/format.cmi stdlib/format.ml stdlib/format.mli \
  stdlib/gc.cmi stdlib/gc.ml stdlib/gc.mli \
  stdlib/genlex.cmi stdlib/genlex.ml stdlib/genlex.mli \
  stdlib/hashtbl.cmi stdlib/hashtbl.ml stdlib/hashtbl.mli \
  stdlib/int32.cmi stdlib/int32.ml stdlib/int32.mli \
  stdlib/int64.cmi stdlib/int64.ml stdlib/int64.mli \
  stdlib/lazy.cmi stdlib/lazy.ml stdlib/lazy.mli \
  stdlib/lexing.cmi stdlib/lexing.ml stdlib/lexing.mli \
  stdlib/list.cmi stdlib/list.ml stdlib/list.mli \
  stdlib/listLabels.cmi stdlib/listLabels.ml stdlib/listLabels.mli \
  stdlib/map.cmi stdlib/map.ml stdlib/map.mli \
  stdlib/marshal.cmi stdlib/marshal.ml stdlib/marshal.mli \
  stdlib/moreLabels.cmi stdlib/moreLabels.ml stdlib/moreLabels.mli \
  stdlib/nativeint.cmi stdlib/nativeint.ml stdlib/nativeint.mli \
  stdlib/obj.cmi stdlib/obj.ml stdlib/obj.mli \
  stdlib/oo.cmi stdlib/oo.ml stdlib/oo.mli \
  stdlib/parsing.cmi stdlib/parsing.ml stdlib/parsing.mli \
  stdlib/pervasives.cmi stdlib/pervasives.ml stdlib/pervasives.mli \
  stdlib/printexc.cmi stdlib/printexc.ml stdlib/printexc.mli \
  stdlib/printf.cmi stdlib/printf.ml stdlib/printf.mli \
  stdlib/queue.cmi stdlib/queue.ml stdlib/queue.mli \
  stdlib/random.cmi stdlib/random.ml stdlib/random.mli \
  stdlib/scanf.cmi stdlib/scanf.ml stdlib/scanf.mli \
  stdlib/sort.cmi stdlib/sort.ml stdlib/sort.mli \
  stdlib/stack.cmi stdlib/stack.ml stdlib/stack.mli \
  stdlib/stdLabels.cmi stdlib/stdLabels.ml stdlib/stdLabels.mli \
  stdlib/stream.cmi stdlib/stream.ml stdlib/stream.mli \
  stdlib/string.cmi stdlib/string.ml stdlib/string.mli \
  stdlib/stringLabels.cmi stdlib/stringLabels.ml stdlib/stringLabels.mli \
  stdlib/sys.cmi stdlib/sys.ml stdlib/sys.mli \
  stdlib/weak.cmi stdlib/weak.ml stdlib/weak.mli \
  stdlib/$set.cmi stdlib/$set.ml stdlib/$set.mli \
 stdlib/arg.cmx stdlib/arg.p.cmx \
 stdlib/array.cmx stdlib/array.p.cmx \
 stdlib/arrayLabels.cmx stdlib/arrayLabels.p.cmx \
 stdlib/buffer.cmx stdlib/buffer.p.cmx \
 stdlib/callback.cmx stdlib/callback.p.cmx \
 stdlib/camlinternalLazy.cmx stdlib/camlinternalLazy.p.cmx \
 stdlib/camlinternalMod.cmx stdlib/camlinternalMod.p.cmx \
 stdlib/camlinternalOO.cmx stdlib/camlinternalOO.p.cmx \
 stdlib/char.cmx stdlib/char.p.cmx \
 stdlib/complex.cmx stdlib/complex.p.cmx \
 stdlib/digest.cmx stdlib/digest.p.cmx \
 stdlib/filename.cmx stdlib/filename.p.cmx \
 stdlib/format.cmx stdlib/format.p.cmx \
 stdlib/gc.cmx stdlib/gc.p.cmx \
 stdlib/genlex.cmx stdlib/genlex.p.cmx \
 stdlib/hashtbl.cmx stdlib/hashtbl.p.cmx \
 stdlib/int32.cmx stdlib/int32.p.cmx \
 stdlib/int64.cmx stdlib/int64.p.cmx \
 stdlib/lazy.cmx stdlib/lazy.p.cmx \
 stdlib/lexing.cmx stdlib/lexing.p.cmx \
 stdlib/list.cmx stdlib/list.p.cmx \
 stdlib/listLabels.cmx stdlib/listLabels.p.cmx \
 stdlib/map.cmx stdlib/map.p.cmx \
 stdlib/marshal.cmx stdlib/marshal.p.cmx \
 stdlib/moreLabels.cmx stdlib/moreLabels.p.cmx \
 stdlib/nativeint.cmx stdlib/nativeint.p.cmx \
 stdlib/obj.cmx stdlib/obj.p.cmx \
 stdlib/oo.cmx stdlib/oo.p.cmx \
 stdlib/parsing.cmx stdlib/parsing.p.cmx \
 stdlib/pervasives.cmx stdlib/pervasives.p.cmx \
 stdlib/printexc.cmx stdlib/printexc.p.cmx \
 stdlib/printf.cmx stdlib/printf.p.cmx \
 stdlib/queue.cmx stdlib/queue.p.cmx \
 stdlib/random.cmx stdlib/random.p.cmx \
 stdlib/scanf.cmx stdlib/scanf.p.cmx \
 stdlib/sort.cmx stdlib/sort.p.cmx \
 stdlib/stack.cmx stdlib/stack.p.cmx \
 stdlib/stdLabels.cmx stdlib/stdLabels.p.cmx \
 stdlib/std_exit.cmx stdlib/std_exit.p.cmx stdlib/std_exit.$O stdlib/std_exit.p.$O \
 stdlib/stream.cmx stdlib/stream.p.cmx \
 stdlib/string.cmx stdlib/string.p.cmx \
 stdlib/stringLabels.cmx stdlib/stringLabels.p.cmx \
 stdlib/sys.cmx stdlib/sys.p.cmx \
 stdlib/weak.cmx stdlib/weak.p.cmx \
 stdlib/$set.cmx stdlib/$set.p.cmx \
  $LIBDIR

installlibdir \
  stdlib/stdlib.$A stdlib/stdlib.p.$A \
  $LIBDIR

echo "Installing ocamllex, ocamldebug..."
installbin lex/ocamllex$EXE $BINDIR/ocamllex$EXE
installbin debugger/ocamldebug$EXE $BINDIR/ocamldebug$EXE
installbin lex/ocamllex.opt$EXE $BINDIR/ocamllex.opt$EXE
installbin tools/ocamldep.native$EXE $BINDIR/ocamldep.opt$EXE

echo "Installing some tools..."
installbin tools/ocamlcp.byte$EXE $BINDIR/ocamlcp$EXE
installbin tools/ocamldep.byte$EXE $BINDIR/ocamldep$EXE
installbin tools/ocamlmklib.byte$EXE $BINDIR/ocamlmklib$EXE
installbin tools/ocamlmktop.byte$EXE $BINDIR/ocamlmktop$EXE
installbin tools/ocamlprof.byte$EXE $BINDIR/ocamlprof$EXE
installbin toplevel/expunge.byte$EXE $LIBDIR/expunge$EXE
installbin tools/addlabels.byte $LIBDIR/addlabels
installbin tools/scrapelabels.byte $LIBDIR/scrapelabels
installbin otherlibs/dynlink/extract_crc.byte $LIBDIR/extract_crc
installbin otherlibs/labltk/lib/labltk$EXE $BINDIR/labltk$EXE
installbin otherlibs/labltk/browser/ocamlbrowser$EXE $BINDIR/ocamlbrowser$EXE
installbin otherlibs/labltk/compiler/pp$EXE $LIBDIR/labltk/pp$EXE
installbin otherlibs/labltk/lib/labltktop$EXE $LIBDIR/labltk/labltktop$EXE

echo "Installing libraries..."
installdir \
  otherlibs/bigarray/bigarray.cma \
  otherlibs/dbm/dbm.cma \
  otherlibs/dynlink/dynlink.cma \
  otherlibs/"$WIN32"graph/graphics.cma \
  otherlibs/num/nums.cma \
  otherlibs/str/str.cma \
  otherlibs/"$WIN32"unix/unix.cma \
  otherlibs/bigarray/bigarray.cmxa \
  otherlibs/dbm/dbm.cmxa \
  otherlibs/dynlink/dynlink.cmxa \
  otherlibs/"$WIN32"graph/graphics.cmxa \
  otherlibs/num/nums.cmxa \
  otherlibs/str/str.cmxa \
  otherlibs/"$WIN32"unix/unix.cmxa \
  toplevel/toplevellib.cma \
  otherlibs/systhreads/thread.mli \
  otherlibs/systhreads/mutex.mli \
  otherlibs/systhreads/condition.mli \
  otherlibs/systhreads/event.mli \
  otherlibs/systhreads/threadUnix.mli \
  $LIBDIR

installdir \
  otherlibs/labltk/support/fileevent.mli \
  otherlibs/labltk/support/fileevent.cmi \
  otherlibs/labltk/support/fileevent.cmx \
  otherlibs/labltk/support/protocol.mli \
  otherlibs/labltk/support/protocol.cmi \
  otherlibs/labltk/support/protocol.cmx \
  otherlibs/labltk/support/textvariable.mli \
  otherlibs/labltk/support/textvariable.cmi \
  otherlibs/labltk/support/textvariable.cmx \
  otherlibs/labltk/support/timer.mli \
  otherlibs/labltk/support/timer.cmi \
  otherlibs/labltk/support/timer.cmx \
  otherlibs/labltk/support/rawwidget.mli \
  otherlibs/labltk/support/rawwidget.cmi \
  otherlibs/labltk/support/rawwidget.cmx \
  otherlibs/labltk/support/widget.mli \
  otherlibs/labltk/support/widget.cmi \
  otherlibs/labltk/support/widget.cmx \
  otherlibs/labltk/support/tkthread.mli \
  otherlibs/labltk/support/tkthread.cmi \
  otherlibs/labltk/support/tkthread.cmo \
  otherlibs/labltk/support/tkthread.$O \
  otherlibs/labltk/support/tkthread.cmx \
  otherlibs/labltk/labltk/[^_]*.mli \
  otherlibs/labltk/labltk/*.cmi \
  otherlibs/labltk/labltk/*.cmx \
  otherlibs/labltk/camltk/[^_]*.mli \
  otherlibs/labltk/camltk/*.cmi \
  otherlibs/labltk/camltk/*.cmx \
  otherlibs/labltk/frx/frxlib.cma \
  otherlibs/labltk/frx/frxlib.cmxa \
  ../otherlibs/labltk/frx/*.mli \
  otherlibs/labltk/frx/*.cmi \
  otherlibs/labltk/jpf/jpflib.cma \
  otherlibs/labltk/jpf/jpflib.cmxa \
  otherlibs/labltk/jpf/*.mli \
  otherlibs/labltk/jpf/*.cmi \
  otherlibs/labltk/jpf/*.cmx \
  otherlibs/labltk/lib/labltk.cma \
  otherlibs/labltk/lib/labltk.cmxa \
  otherlibs/labltk/lib/labltk.cmx \
  otherlibs/labltk/tkanim/*.mli \
  otherlibs/labltk/tkanim/*.cmi \
  otherlibs/labltk/tkanim/tkanim.cma \
  otherlibs/labltk/tkanim/tkanim.cmxa \
  otherlibs/labltk/compiler/tkcompiler \
  $LIBDIR/labltk

installdir \
  otherlibs/systhreads/threads.cma \
  otherlibs/systhreads/threads.cmxa \
  otherlibs/systhreads/thread.cmi \
  otherlibs/systhreads/thread.cmx \
  otherlibs/systhreads/mutex.cmi \
  otherlibs/systhreads/mutex.cmx \
  otherlibs/systhreads/condition.cmi \
  otherlibs/systhreads/condition.cmx \
  otherlibs/systhreads/event.cmi \
  otherlibs/systhreads/event.cmx \
  otherlibs/systhreads/threadUnix.cmi \
  otherlibs/systhreads/threadUnix.cmx \
  $LIBDIR/threads

installdir \
  otherlibs/bigarray/dllbigarray$EXT_DLL \
  otherlibs/dbm/dllmldbm$EXT_DLL \
  otherlibs/"$WIN32"graph/dllgraphics$EXT_DLL \
  otherlibs/num/dllnums$EXT_DLL \
  otherlibs/str/dllstr$EXT_DLL \
  otherlibs/systhreads/dllthreads$EXT_DLL \
  otherlibs/"$WIN32"unix/dllunix$EXT_DLL \
  otherlibs/threads/dllvmthreads$EXT_DLL \
  otherlibs/labltk/support/dlllabltk$EXT_DLL \
  otherlibs/labltk/tkanim/dlltkanim$EXT_DLL \
  $STUBLIBDIR

installlibdir \
  otherlibs/threads/libvmthreads.$A \
  $LIBDIR/vmthreads

installdir \
  otherlibs/threads/thread.cmi \
  otherlibs/threads/thread.mli \
  otherlibs/threads/mutex.cmi \
  otherlibs/threads/mutex.mli \
  otherlibs/threads/condition.cmi \
  otherlibs/threads/condition.mli \
  otherlibs/threads/event.cmi \
  otherlibs/threads/event.mli \
  otherlibs/threads/threadUnix.cmi \
  otherlibs/threads/threadUnix.mli \
  otherlibs/threads/threads.cma \
  otherlibs/threads/stdlib.cma \
  otherlibs/threads/unix.cma \
  $LIBDIR/vmthreads

installlibdir \
  otherlibs/labltk/support/liblabltk.$A \
  otherlibs/labltk/lib/labltk.$A \
  otherlibs/labltk/jpf/jpflib.$A \
  otherlibs/labltk/tkanim/libtkanim.$A \
  otherlibs/labltk/tkanim/tkanim.$A \
  otherlibs/labltk/frx/frxlib.$A \
  $LIBDIR/labltk

installlibdir \
  otherlibs/bigarray/libbigarray.$A \
  otherlibs/dbm/libmldbm.$A \
  otherlibs/"$WIN32"graph/libgraphics.$A \
  otherlibs/num/libnums.$A \
  otherlibs/str/libstr.$A \
  otherlibs/systhreads/libthreads.$A \
  otherlibs/systhreads/libthreadsnat.$A \
  otherlibs/"$WIN32"unix/libunix.$A \
  $LIBDIR

echo "Installing object files and interfaces..."
installdir \
  tools/profiling.cm[oi] \
  toplevel/topstart.cmo \
  toplevel/toploop.cmi \
  toplevel/topdirs.cmi \
  toplevel/topmain.cmi \
  typing/outcometree.cmi \
  typing/outcometree.mli \
  otherlibs/graph/graphicsX11.cmi \
  otherlibs/graph/graphicsX11.mli \
  otherlibs/dynlink/dynlink.cmi \
  otherlibs/dynlink/dynlink.mli \
  otherlibs/num/arith_status.cmi \
  otherlibs/num/arith_status.mli \
  otherlibs/num/big_int.cmi \
  otherlibs/num/big_int.mli \
  otherlibs/num/nat.cmi \
  otherlibs/num/nat.mli \
  otherlibs/num/num.cmi \
  otherlibs/num/num.mli \
  otherlibs/num/ratio.cmi \
  otherlibs/num/ratio.mli \
  otherlibs/bigarray/bigarray.cmi \
  otherlibs/bigarray/bigarray.mli \
  otherlibs/dbm/dbm.cmi \
  otherlibs/dbm/dbm.mli \
  otherlibs/dynlink/dynlink.cmx \
  otherlibs/"$WIN32"graph/graphics.cmi \
  otherlibs/"$WIN32"graph/graphics.mli \
  otherlibs/str/str.cmi \
  otherlibs/str/str.mli \
  otherlibs/"$WIN32"unix/unix.cmi \
  otherlibs/"$WIN32"unix/unix.mli \
  otherlibs/"$WIN32"unix/unixLabels.cmi \
  otherlibs/"$WIN32"unix/unixLabels.mli \
  otherlibs/num/arith_flags.cmx \
  otherlibs/num/int_misc.cmx \
  otherlibs/num/arith_status.cmx \
  otherlibs/num/big_int.cmx \
  otherlibs/num/nat.cmx \
  otherlibs/num/num.cmx \
  otherlibs/num/ratio.cmx \
  otherlibs/bigarray/bigarray.cmx \
  otherlibs/dbm/dbm.cmx \
  otherlibs/"$WIN32"graph/graphics.cmx \
  otherlibs/graph/graphicsX11.cmx \
  otherlibs/str/str.cmx \
  otherlibs/"$WIN32"unix/unix.cmx \
  otherlibs/"$WIN32"unix/unixLabels.cmx \
  $LIBDIR

installlibdir \
  otherlibs/bigarray/bigarray.$A \
  otherlibs/dbm/dbm.$A \
  otherlibs/dynlink/dynlink.$A \
  otherlibs/"$WIN32"graph/graphics.$A \
  otherlibs/num/nums.$A \
  otherlibs/str/str.$A \
  otherlibs/"$WIN32"unix/unix.$A \
  stdlib/stdlib.$A \
  $LIBDIR

installlibdir \
  otherlibs/systhreads/threads.$A \
  $LIBDIR/threads

echo "Installing manuals..."
(cd ../man && make install)

echo "Installing ocamldoc..."
installbin ocamldoc/ocamldoc $BINDIR/ocamldoc$EXE
installbin ocamldoc/ocamldoc.opt $BINDIR/ocamldoc.opt$EXE

installdir \
  ../ocamldoc/ocamldoc.hva \
  ocamldoc/*.cmi \
  ocamldoc/odoc_info.mli ocamldoc/odoc_info.cm[ia] ocamldoc/odoc_info.cmxa \
  ocamldoc/odoc_info.$A \
  $LIBDIR/ocamldoc

installdir \
  ocamldoc/stdlib_man/* \
  $MANDIR/man3

echo "Installing camlp4..."
installbin camlp4/camlp4prof.byte$EXE $BINDIR/camlp4prof$EXE
installbin camlp4/mkcamlp4.byte$EXE $BINDIR/mkcamlp4$EXE
installbin camlp4/camlp4.byte$EXE $BINDIR/camlp4$EXE
installbin camlp4/camlp4boot.byte$EXE $BINDIR/camlp4boot$EXE
installbin camlp4/camlp4o.byte$EXE $BINDIR/camlp4o$EXE
installbin camlp4/camlp4of.byte$EXE $BINDIR/camlp4of$EXE
installbin camlp4/camlp4oof.byte$EXE $BINDIR/camlp4oof$EXE
installbin camlp4/camlp4orf.byte$EXE $BINDIR/camlp4orf$EXE
installbin camlp4/camlp4r.byte$EXE $BINDIR/camlp4r$EXE
installbin camlp4/camlp4rf.byte$EXE $BINDIR/camlp4rf$EXE
installbin camlp4/camlp4o.native$EXE $BINDIR/camlp4o.opt$EXE
installbin camlp4/camlp4of.native$EXE $BINDIR/camlp4of.opt$EXE
installbin camlp4/camlp4oof.native$EXE $BINDIR/camlp4oof.opt$EXE
installbin camlp4/camlp4orf.native$EXE $BINDIR/camlp4orf.opt$EXE
installbin camlp4/camlp4r.native$EXE $BINDIR/camlp4r.opt$EXE
installbin camlp4/camlp4rf.native$EXE $BINDIR/camlp4rf.opt$EXE

cd camlp4
CAMLP4DIR=$LIBDIR/camlp4
for dir in Camlp4Parsers Camlp4Printers Camlp4Filters Camlp4Top; do
  echo "Installing $dir..."
  mkdir -p $CAMLP4DIR/$dir
  installdir     \
    $dir/*.cm*   \
    $dir/*.$O    \
    $CAMLP4DIR/$dir
done
installdir \
  camlp4lib.cma camlp4lib.cmxa Camlp4.cmi \
  camlp4fulllib.cma camlp4fulllib.cmxa \
  camlp4o.cma camlp4of.cma camlp4oof.cma \
  camlp4orf.cma camlp4r.cma camlp4rf.cma \
  Camlp4Bin.cm[iox] Camlp4Bin.$O Camlp4Top.cm[io] \
  Camlp4_config.cmi camlp4prof.cm[iox] camlp4prof.$O Camlp4_import.cmi \
  $CAMLP4DIR
installlibdir camlp4lib.$A camlp4fulllib.$A $CAMLP4DIR
cd ..

echo "Installing ocamlbuild..."

cd ocamlbuild
installbin ocamlbuild.byte$EXE $BINDIR/ocamlbuild.byte$EXE
installbin ocamlbuild.native$EXE $BINDIR/ocamlbuild.native$EXE
installbestbin ocamlbuild.native$EXE ocamlbuild.byte$EXE $BINDIR/ocamlbuild$EXE

installlibdir \
  ocamlbuildlib.$A \
  $LIBDIR/ocamlbuild

installdir \
  ocamlbuildlib.cmxa \
  ocamlbuildlib.cma \
  ocamlbuild_plugin.cmi \
  ocamlbuild_pack.cmi \
  ocamlbuild_unix_plugin.cmi \
  ocamlbuild_unix_plugin.cmo \
  ocamlbuild_unix_plugin.cmx \
  ocamlbuild_unix_plugin.$O \
  ocamlbuild_executor.cmi \
  ocamlbuild_executor.cmo \
  ocamlbuild_executor.cmx \
  ocamlbuild_executor.$O \
  ocamlbuild.cmo \
  ocamlbuild.cmx \
  ocamlbuild.$O \
  $LIBDIR/ocamlbuild
cd ..

installdir \
  ../ocamlbuild/man/ocamlbuild.1 \
  $MANDIR/man1