-
Notifications
You must be signed in to change notification settings - Fork 1
/
compile.sh
executable file
·269 lines (245 loc) · 6.61 KB
/
compile.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
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
#!/bin/bash
###########################################################################
#
# SWIG-generated python wrapper for the Linear Arrangement Library
# Copyright (C) 2021 - 2024 LAL-project developers
# Lluís Alemany Puig
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Contact:
#
# Lluís Alemany Puig ([email protected])
# LQMC (Quantitative, Mathematical, and Computational Linguisitcs)
# CQL (Complexity and Quantitative Linguistics Lab)
# Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
# Webpage: https://cqllab.upc.edu/people/lalemany/
#
###########################################################################
function help() {
echo "Compilation of the Python wrapper for LAL"
echo "========================================="
echo ""
echo "Examples of usage:"
echo ""
echo "* Make a debug build in a development version of LAL"
echo ""
echo " ./compile.sh --build=debug"
echo " ./compile.sh --build=debug --environment=development"
echo ""
echo "* Make a release build in a distribution version of LAL"
echo ""
echo " ./compile.sh --build=release --environment=distribution"
echo ""
echo "* Install a release compilation of LAL"
echo ""
echo " ./compile.sh --build=release --install"
echo ""
echo "For further information, read below the usage of all parameters."
echo ""
echo "----------"
echo "LAL SOURCE"
echo "----------"
echo ""
echo " When necessary, the location of the Linear Arrangement Library's"
echo " header files and library files can be specified with the following"
echo " two commands:"
echo ""
echo " --lal-headers=dir"
echo ""
echo " Use it to specify the location of LAL's header files."
echo ""
echo " --lal-libs=dir"
echo ""
echo " Use it to specify the location of LAL's library files (.so, .dll, ...)."
echo ""
echo "----------"
echo "LAL SOURCE"
echo "----------"
echo ""
echo " Specify the destination directory of LAL with the following command:"
echo ""
echo " --destination-directory=dir"
echo ""
echo " This is mandatory when using the option '--install'."
echo ""
echo "----------"
echo "GMP SOURCE"
echo "----------"
echo ""
echo " When necessary, the location of the GNU Multiple Precision library"
echo " header files and library files can be specified with the following"
echo " two commands:"
echo ""
echo " --gmp-headers=dir"
echo ""
echo " Use it to specify the location of GMP's header files."
echo ""
echo " --gmp-libs=dir"
echo ""
echo " Use it to specify the location of GMP's library files (.so, .dll, ...)."
echo ""
echo "-------------"
echo "PYTHON SOURCE"
echo "-------------"
echo ""
echo " When necessary, the location of python's header files and library"
echo " files can be specified with the following two commands:"
echo ""
echo " --python-headers=dir"
echo ""
echo " Use it to specify the location of GMP's header files."
echo ""
echo " --python-libs=dir"
echo ""
echo " Use it to specify the location of GMP's library files (.so, .dll, ...)."
echo ""
echo " It is mandatory to specify the version of python that is to be used"
echo ""
echo " --python-major=x (default: 3)"
echo " --python-minor=x"
echo ""
echo "----------------"
echo "BUILD PARAMETERS"
echo "----------------"
echo ""
echo " --build=debug (default)"
echo " --build=release"
echo ""
echo " Make either a debug or release compilation of the wrapper."
echo ""
echo "------------------"
echo "INSTALL PARAMETERS"
echo "------------------"
echo ""
echo " --install"
echo ""
echo " Copy the compiled binaries to the installation directory."
echo ""
exit
}
LAL_HEADERS=""
LAL_LIBRARY=""
INSTALLATION_DIR=""
GMP_HEADERS=""
GMP_LIBRARY=""
PYTHON_HEADERS=""
PYTHON_LIBRARY=""
BUILD="debug"
ENVIRONMENT="development"
INSTALL=0
ANACONDA="no"
CLEAN=0
for i in "$@"; do
case $i in
--help)
help
;;
--lal-headers=*)
LAL_HEADERS="${i#*=}"
shift
;;
--lal-libs=*)
LAL_LIBRARY="${i#*=}"
shift
;;
--destination-directory=*)
INSTALLATION_DIR="${i#*=}"
shift
;;
--gmp-headers=*)
GMP_HEADERS="${i#*=}"
shift
;;
--gmp-libs=*)
GMP_LIBRARY="${i#*=}"
shift
;;
--python-headers=*)
PYTHON_HEADERS="${i#*=}"
shift
;;
--python-libs=*)
PYTHON_LIBRARY="${i#*=}"
shift
;;
--build=*)
BUILD="${i#*=}"
shift
;;
--environment=*)
ENVIRONMENT="${i#*=}"
shift
;;
--clean)
CLEAN=1
shift
;;
--install)
INSTALL=1
shift
;;
--anaconda)
ANACONDA="yes"
shift
;;
*)
echo -e "\e[1;4;31mError:\e[0m Option $i unknown"
exit 1
;;
esac
done
if [ $CLEAN == 1 ] && [ $INSTALL == 1 ]; then
echo "Error: conflict in options '--clean' and '--install'"
echo " clean: $CLEAN"
echo " install: $INSTALL"
exit 1
fi
if [ $INSTALL == 1 ]; then
if [ $INSTALLATION_DIR == "" ]; then
echo "Error: missing mandatory value for option 'install'."
echo " Missing: --destination-directory"
echo " Current value: $INSTALLATION_DIR"
exit 1
fi
fi
if [ "$BUILD" != "debug" ] && [ "$BUILD" != "release" ]; then
echo "Error: invalid value for 'BUILD' variable: '$BUILD'"
echo " Valid values: debug/release"
exit 1
fi
if [ "$ENVIRONMENT" != "development" ] && [ "$ENVIRONMENT" != "distribution" ]; then
echo "Error: invalid value for 'ENVIRONMENT' variable: '$ENVIRONMENT'"
echo " Valid values: development/distribution"
exit 1
fi
MAKE_COMMAND="\
make \
USER_LAL_INC_DIR=$LAL_HEADERS \
USER_LAL_LIB_DIR=$LAL_LIBRARY \
USER_INSTALLATION_DIR=$INSTALLATION_DIR \
USER_GMP_INC_DIR=$GMP_HEADERS \
USER_GMP_LIB_DIR=$GMP_LIBRARY \
USER_PYTHON_HEADERS=$PYTHON_HEADERS \
USER_PYTHON_LIBRARY=$PYTHON_LIBRARY \
USER_ENVIRONMENT=$ENVIRONMENT \
USER_BUILD=$BUILD"
echo "Make command: '$MAKE_COMMAND'"
if [ $INSTALL == 1 ]; then
$MAKE_COMMAND install
elif [ $CLEAN == 1 ]; then
$MAKE_COMMAND clean
else
$MAKE_COMMAND
fi