-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathconfigure.sh
executable file
·146 lines (132 loc) · 3.75 KB
/
configure.sh
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
#!/bin/sh
#
# This file is part of OCaml-Java build.
# Copyright (C) 2007-2015 Xavier Clerc.
#
# OCaml-Java build is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# OCaml-Java build is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# prints the passed message, and terminates the script
fail() {
echo "*** error: $1"
exit 1
}
# prints the passed message
warn() {
echo "*** warning: $1"
}
# prints the help message, and terminates the script
print_usage() {
echo "usage: $0 [options]"
echo 'available options:'
echo ' -prefix <path> set installation path'
echo ' -mode <compatibility|speed> set runtime/compiler mode'
echo ' -ocaml-configure <...> set options to pass to OCaml configure'
exit 0
}
# checks Ant and Java versions, terminating the script if any is invalid
check_ant_and_java_versions() {
local ant_stdout
local ant_exit_code
ant_stdout=`ant -q -S -f build/build-check-versions.xml 2>&1`
ant_exit_code=$?
case $ant_exit_code in
0) # Ant execution was successful
;;
1) # Ant execution failed
fail "`echo $ant_stdout | sed -e 's/.*!\(.*\)!.*/\1/'`"
;;
127) # Ant was not executed
fail "unable to run Ant"
;;
esac
}
# checks dependencies
check_ant_and_java_versions
# default values
prefix=''
mode='compatibility'
ocaml_configure=''
# parses command-line
while [ $# -gt 0 ]
do
case "$1" in
-prefix)
prefix="$2";
shift
;;
-mode)
mode="$2";
shift
;;
-ocaml-configure)
ocaml_configure="$2";
shift
;;
-help|--help)
print_usage
;;
*)
fail "invalid switch ($1)"
;;
esac
shift
done
# performs sanity checks over command-line elements
if [ "$prefix" = "" ]; then
fail 'an installation prefix should be given through -prefix'
fi
case "$prefix" in
/*) # the prefix value is absolute (leading '/')
;;
*)
fail 'the prefix should be absolute'
;;
esac
case "$mode" in
compatibility)
;;
speed)
fail 'the "speed" mode is not currently supported'
;;
*)
fail 'the mode should be either "compatibility" or "speed"'
;;
esac
# outputs configuration summary
echo 'configuration:'
echo " PREFIX ---------------> $prefix"
echo " MODE -----------------> $mode"
echo " OCAML_CONFIGURE ------> $ocaml_configure"
# creates the configuration file
echo "# timestamp: `date`" > Makefile.config
echo 'VERSION="'`cat VERSION`'"' >> Makefile.config
echo 'PREFIX="'$prefix'"' >> Makefile.config
case "$mode" in
compatibility)
echo "OCAML_INTS_ARE_63_BIT_LONG=TRUE" >> Makefile.config
;;
speed)
echo "# OCAML_INTS_ARE_63_BIT_LONG=FALSE" >> Makefile.config
;;
esac
echo 'OCAML_CONFIGURE="'$ocaml_configure'"' >> Makefile.config
# checks that JAVA_HOME is set
if [ -z "$JAVA_HOME" ] && [ ! -x "/usr/libexec/java_home" ]; then
echo ''
warn '"JAVA_HOME" environment variable should be set'
fi
# informs that configuration is done
echo ''
echo '*** configuration successfully written to "Makefile.config"'
exit 0