forked from ocaml-obuild/obuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·112 lines (96 loc) · 3.2 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
libs="unix.cma"
OCAMLC="ocamlc -g"
OCAMLVER=$($OCAMLC -version)
echo "$OCAMLVER"
rm -f ext/compat.ml
if [[ $OCAMLVER < "4.02.0" ]] ; then
echo "Using compat401.ml"
cp -f compat401.ml ext/compat.ml
else
echo "Using compat402.ml"
cp -f compat402.ml ext/compat.ml
fi
extmodules="compat fugue filepath filesystem"
libmodules="types gconf filetype dag libname pp expr utils modname taskdep helper dagutils process findlibConf scheduler prog dependencies generators hier meta metacache target dist 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 ./*.cmo ./*.o
FILES=()
for mod in $extmodules
do
echo "COMPILING $mod"
[ -f "${mod}.mli" ] && $OCAMLC -for-pack Ext -c "${mod}.mli"
$OCAMLC -for-pack Ext -c "${mod}.ml"
FILES+=("ext/${mod}.cmo")
done;
cd ..
echo "BUILDING library Ext.cmo"
$OCAMLC -pack -o Ext.cmo -I ext/ "${FILES[@]}"
########################################################################
########################################################################
########################################################################
# build the library
cd obuild
rm -f ./*.cmi ./*.cmo ./*.o
FILES=()
for mod in $libmodules
do
echo "COMPILING $mod"
[ -f "${mod}.mli" ] && $OCAMLC -for-pack Obuild -I ../ -c "${mod}.mli"
$OCAMLC -for-pack Obuild -I ../ -c "${mod}.ml"
FILES+=("obuild/${mod}.cmo")
done;
cd ..
echo "BUILDING library Obuild.cmo"
$OCAMLC -pack -o Obuild.cmo -I ext/ "${FILES[@]}"
# 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
FILES=()
for mod in $mainmodules
do
echo "COMPILING $mod"
[ -f "${mod}.mli" ] && $OCAMLC -I ../ -c "${mod}.mli"
$OCAMLC -I ../ -c "${mod}.ml"
FILES+=("${mod}.cmo")
done
echo "LINKING obuild.bootstrap"
$OCAMLC -o ../obuild.bootstrap -I ../ ${libs} Ext.cmo Obuild.cmo "${FILES[@]}"
cd ..
rm -f obuild/*.cmi obuild/*.cmo obuild/*.o
rm -f src/*.cmi src/*.cmo src/*.o
rm -f ./*.cmi ./*.o ./*a ./*.cmo
rm -f src/path_generated.ml
########################################################################
########################################################################
########################################################################
# rebuild everything with the bootstraped version
export OCAMLRUNPARAM=b
./obuild.bootstrap clean
if [ -x "$(command -v ocamlopt)" ]; then
./obuild.bootstrap configure
time ./obuild.bootstrap build
else
./obuild.bootstrap configure \
--disable-executable-native \
--disable-library-native \
--disable-library-plugin \
--enable-executable-bytecode \
--enable-library-bytecode
time ./obuild.bootstrap build
mv dist/build/obuild/obuild.byte dist/build/obuild/obuild
mv dist/build/obuild-simple/obuild-simple.byte dist/build/obuild-simple/obuild-simple
fi
if [ -x dist/build/obuild/obuild ]; then
rm obuild.bootstrap
fi