forked from ocaml-obuild/obuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·96 lines (81 loc) · 2.74 KB
/
bootstrap
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
#!/usr/bin/env bash
libs="unix.cmxa"
OCAMLOPT="ocamlopt -g"
# use faster ocamlopt, if available
OCAMLOPT_OPT=`which ocamlopt.opt`
if [[ $OCAMLOPT_OPT != "" ]] ; then
OCAMLOPT="ocamlopt.opt -g"
fi
extmodules="fugue filepath filesystem"
libmodules="gconf types dag pp filetype expr utils modname taskdep dist helper dagutils process findlibConf scheduler prog dependencies generators hier meta target project analyze configure prepare buildprogs build exception"
mainmodules="sdist doc init help install path_generated main"
set -e
########################################################################
########################################################################
########################################################################
# build ext
cd ext
rm -f *.cmi *.cmx *.o
APPEND=""
for mod in $extmodules
do
echo "COMPILING $mod"
[ -f ${mod}.mli ] && $OCAMLOPT -for-pack Ext -c ${mod}.mli
$OCAMLOPT -for-pack Ext -c ${mod}.ml
APPEND+="ext/${mod}.cmx "
done;
cd ..
echo "BUILDING library obuild_ext.cmxa"
$OCAMLOPT -pack -o ext.cmx -I ext/ $APPEND
$OCAMLOPT -a -o obuild_ext.cmxa ext.cmx
########################################################################
########################################################################
########################################################################
# build the library
cd obuild
rm -f *.cmi *.cmx *.o
APPEND=""
for mod in $libmodules
do
echo "COMPILING $mod"
[ -f ${mod}.mli ] && $OCAMLOPT -for-pack Obuild -I ../ -c ${mod}.mli
$OCAMLOPT -for-pack Obuild -I ../ -c ${mod}.ml
APPEND+="obuild/${mod}.cmx "
done;
cd ..
echo "BUILDING library obuild.cmxa"
$OCAMLOPT -pack -o obuild.cmx -I ext/ $APPEND
$OCAMLOPT -a -o obuild.cmxa obuild.cmx
# then bootstrap the main executable
# main needs the version number
cat <<EOF > src/path_generated.ml
(* autogenerated file by bootstrap. do not modify *)
let project_version = "0.0.0"
EOF
cd src
APPEND=""
for mod in $mainmodules
do
echo "COMPILING $mod"
[ -f ${mod}.mli ] && $OCAMLOPT -I ../ -c ${mod}.mli
$OCAMLOPT -I ../ -c ${mod}.ml
APPEND+="${mod}.cmx "
done
echo "LINKING obuild.bootstrap"
$OCAMLOPT -o ../obuild.bootstrap -I ../ ${libs} obuild_ext.cmxa obuild.cmxa $APPEND
cd ..
rm -f obuild/*.cmi obuild/*.cmx obuild/*.o
rm -f src/*.cmi src/*.cmx src/*.o
rm -f *.cmi *.o *a *.cmx *.cmxa
rm -f src/path_generated.ml
########################################################################
########################################################################
########################################################################
# rebuild everything with the bootstraped version
export OCAMLRUNPARAM=b
./obuild.bootstrap clean
./obuild.bootstrap configure
time ./obuild.bootstrap build
if [ -x dist/build/obuild/obuild ]; then
rm obuild.bootstrap
fi