-
Notifications
You must be signed in to change notification settings - Fork 0
/
autogen.sh
executable file
·382 lines (360 loc) · 11 KB
/
autogen.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
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
#!/bin/sh
#
dir=`echo "$0" | sed 's,[^/]*$,,'`
test "x${dir}" = "x" && dir='.'
#
if test "x`cd "${dir}" 2>/dev/null && pwd`" != "x`pwd`"
then
echo "This script must be executed directly from the source directory."
exit 1
fi
##
# Parsing of command-line options
DOC_OPTION="-DINSTALL_DOC:BOOL=ON"
BUILD_DIR_OPTION="NO"
SOURCE_DIR="."
for opt_elem in $@
do
if [ "${opt_elem}" = "-h" -o "${opt_elem}" = "-H" -o "${opt_elem}" = "--h" -o "${opt_elem}" = "--help" ]
then
echo ""
echo " This script generates a 'configure' script for simulator-related projects."
echo " That 'configure' script is compatible with some GNU Autotools options."
echo " Run './configure', after its generation, to see its usage."
echo " "
echo "Usage:"
echo " \$0 [--nodoc]"
echo ""
exit 0
fi
if [ "${opt_elem}" = "-n" -o "${opt_elem}" = "-N" -o "${opt_elem}" = "--nodoc" ]
then
DOC_OPTION="-DINSTALL_DOC:BOOL=OFF"
fi
if [ "${opt_elem}" = "-b" -o "${opt_elem}" = "-B" -o "${opt_elem}" = "--builddir" ]
then
BUILD_DIR_OPTION="YES"
SOURCE_DIR=".."
fi
done
#
PROJECT_NAME=stdair
PROJECT_NAME_STRING=`grep "set_project_names" CMakeLists.txt | sed -e "s/set_project_names.*(\([a-z]\+\).*).*/\1/"`
if [ "x${PROJECT_NAME_STRING}" != "x" ]
then
PROJECT_NAME=${PROJECT_NAME_STRING}
fi
#
VERSION_MAJOR=1
VERSION_MINOR=01
VERSION_PATCH=7
VERSION_TMP_STRING=`grep "set_project_versions" CMakeLists.txt | sed -e "s/set_project_versions.*\([0-9]\+.\+[0-9]\+.\+[0-9]\+\).\+/\1/"`
VERSION_STRING=`echo "${VERSION_TMP_STRING}" | grep "^[0-9]\+.[0-9]\+.[0-9]\+$"`
if [ "x${VERSION_STRING}" != "x" ]
then
VERSION_MAJOR=`echo ${VERSION_STRING} | cut -d\ -f1`
VERSION_MINOR=`echo ${VERSION_STRING} | cut -d\ -f2`
VERSION_PATCH=`echo ${VERSION_STRING} | cut -d\ -f3`
fi
#
LOCAL_USERNAME=`id | cut -d\( -f2 | cut -d\) -f1`
PREFIX=/home/${LOCAL_USERNAME}/dev/deliveries/${PROJECT_NAME}-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
if [ "${LOCAL_USERNAME}" = "build" ]
then
PREFIX=/opt/${PROJECT_NAME}-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
fi
#
cat > configure << _EOF
#!/bin/sh
##
# Contrary to what its name could lead to think, this Shell script is not a
# GNU Autotools-based configure script. Instead, it triggers the CMake build
# system. That Shell script is intended to be used by standard CI (Continuous
# Integration) build-servers, such as Hudson/Jenkins for instance.
# The standard CI build-server often calls simple build preparation scripts,
# namely autogen.sh and/or configure in our case. Hence, the CI build-server
# will not fail when running this configure script. Better, the CMake framework
# will be invoked, thus improving the performance of the build.
#
# Even better, this configure script has itself been generated by an ad-hoc
# autogen.sh script. That latter can be seen from the Git repository only:
# it is not shipped with the project tar-ball.
#
# Parsing of options
# Note:
# -----
# The Hudson/Jenkins-based CI build-server often builds any simulator-related
# projects with the same set up of options:
# ./configure --with-stdair=/opt/stdair
# --with-sevmgr=/opt/sevmgr --with-trademgen=/opt/trademgen
# --with-travelccm=/opt/travelccm --with-airtsp=/opt/airtsp
# --with-airrac=/opt/airrac --with-rmol=/opt/rmol
# --with-airinv=/opt/airinv --with-avlcal=/opt/avlcal
# --with-simfqt=/opt/simfqt --with-simlfs=/opt/simlfs
# --with-simcrs=/opt/simcrs
#
_EOF
#
if [ "${PROJECT_NAME}" = "stdair" ]
then
cat >> configure << _EOF
# If the --with-stdair option is actually given, it will be stripped out.
# Indeed, that option should not be set, as the StdAir project itself is
# to be built. Like that, the CI build-server has not to be bothered by
# any specific set up.
#
_EOF
fi
#
cat >> configure << _EOF
PREFIX_OPTION=""
STDAIR_OPTION=""
SEVMGR_OPTION=""
TRADEMGEN_OPTION=""
TRAVELCCM_OPTION=""
AIRTSP_OPTION=""
AIRRAC_OPTION=""
RMOL_OPTION=""
AIRINV_OPTION=""
AVLCAL_OPTION=""
SIMFQT_OPTION=""
SIMLFS_OPTION=""
SIMCRS_OPTION=""
DOC_OPTION="${DOC_OPTION}"
RM_OPTION="rm -rf build"
BUILD_DIR_OPTION="${BUILD_DIR_OPTION}"
SOURCE_DIR="${SOURCE_DIR}"
for opt_elem in \$@
do
if [ "\${opt_elem}" = "-h" -o "\${opt_elem}" = "-H" -o "\${opt_elem}" = "--h" -o "\${opt_elem}" = "--help" ]
then
echo ""
echo "Usage:"
echo " \$0 [--prefix=<install_dir>] [--with-stdair=<stdair_install_dir>] [--with-sevmgr=<sevmgr_install_dir>] [--with-trademgen=<trademgen_install_dir>] [--with-travelccm=<travelccm_install_dir>] [--with-airtsp=<airtsp_install_dir>] [--with-airrac=<airrac_install_dir>] [--with-rmol=<rmol_install_dir>] [--with-airinv=<airinv_install_dir>] [--with-avlcal=<avlcal_install_dir>] [--with-simfqt=<simfqt_install_dir>] [--with-simlfs=<simlfs_install_dir>] [--with-simcrs=<simcrs_install_dir>] [--with-doc | --without-doc] [-n|-N|--norm] [-b|--buildir]"
echo " --with-doc/--without-doc : Force the (resp. non) generation of the documentation"
echo " -n/-N/--norm : Do not remove/clean older potential 'build' sub-directory"
echo " -b/-B/--buildir : Do the build in a dedicated 'build' sub-directory, rather than in-place"
echo ""
exit 0
fi
IS_OPTION_PREFIX=\`echo "\${opt_elem}" | grep "^--prefix="\`
if [ "\${IS_OPTION_PREFIX}" != "" ]
then
PREFIX_DIR=\`echo "\${opt_elem}" | sed -e "s/^--prefix=\(.*\)\$/\1/"\`
PREFIX_OPTION="-DCMAKE_INSTALL_PREFIX=\${PREFIX_DIR}"
fi
_EOF
#
if [ "${PROJECT_NAME}" != "stdair" ]
then
cat >> configure << _EOF
IS_OPTION_STDAIR=\`echo "\${opt_elem}" | grep "^--with-stdair="\`
if [ "\${IS_OPTION_STDAIR}" != "" ]
then
STDAIR_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-stdair=\(.*\)\$/\1/"\`
STDAIR_OPTION="-DWITH_STDAIR_PREFIX=\${STDAIR_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "sevmgr" ]
then
cat >> configure << _EOF
IS_OPTION_SEVMGR=\`echo "\${opt_elem}" | grep "^--with-sevmgr="\`
if [ "\${IS_OPTION_SEVMGR}" != "" ]
then
SEVMGR_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-sevmgr=\(.*\)\$/\1/"\`
SEVMGR_OPTION="-DWITH_SEVMGR_PREFIX=\${SEVMGR_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "trademgen" ]
then
cat >> configure << _EOF
IS_OPTION_TRADEMGEN=\`echo "\${opt_elem}" | grep "^--with-trademgen="\`
if [ "\${IS_OPTION_TRADEMGEN}" != "" ]
then
TRADEMGEN_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-trademgen=\(.*\)\$/\1/"\`
TRADEMGEN_OPTION="-DWITH_TRADEMGEN_PREFIX=\${TRADEMGEN_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "travelccm" ]
then
cat >> configure << _EOF
IS_OPTION_TRAVELCCM=\`echo "\${opt_elem}" | grep "^--with-travelccm="\`
if [ "\${IS_OPTION_TRAVELCCM}" != "" ]
then
TRAVELCCM_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-travelccm=\(.*\)\$/\1/"\`
TRAVELCCM_OPTION="-DWITH_TRAVELCCM_PREFIX=\${TRAVELCCM_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "airtsp" ]
then
cat >> configure << _EOF
IS_OPTION_AIRTSP=\`echo "\${opt_elem}" | grep "^--with-airtsp="\`
if [ "\${IS_OPTION_AIRTSP}" != "" ]
then
AIRTSP_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-airtsp=\(.*\)\$/\1/"\`
AIRTSP_OPTION="-DWITH_AIRTSP_PREFIX=\${AIRTSP_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "airrac" ]
then
cat >> configure << _EOF
IS_OPTION_AIRRAC=\`echo "\${opt_elem}" | grep "^--with-airrac="\`
if [ "\${IS_OPTION_AIRRAC}" != "" ]
then
AIRRAC_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-airrac=\(.*\)\$/\1/"\`
AIRRAC_OPTION="-DWITH_AIRRAC_PREFIX=\${AIRRAC_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "rmol" ]
then
cat >> configure << _EOF
IS_OPTION_RMOL=\`echo "\${opt_elem}" | grep "^--with-rmol="\`
if [ "\${IS_OPTION_RMOL}" != "" ]
then
RMOL_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-rmol=\(.*\)\$/\1/"\`
RMOL_OPTION="-DWITH_RMOL_PREFIX=\${RMOL_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "airinv" ]
then
cat >> configure << _EOF
IS_OPTION_AIRINV=\`echo "\${opt_elem}" | grep "^--with-airinv="\`
if [ "\${IS_OPTION_AIRINV}" != "" ]
then
AIRINV_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-airinv=\(.*\)\$/\1/"\`
AIRINV_OPTION="-DWITH_AIRINV_PREFIX=\${AIRINV_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "avlcal" ]
then
cat >> configure << _EOF
IS_OPTION_AVLCAL=\`echo "\${opt_elem}" | grep "^--with-avlcal="\`
if [ "\${IS_OPTION_AVLCAL}" != "" ]
then
AVLCAL_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-avlcal=\(.*\)\$/\1/"\`
AVLCAL_OPTION="-DWITH_AVLCAL_PREFIX=\${AVLCAL_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "simfqt" ]
then
cat >> configure << _EOF
IS_OPTION_SIMFQT=\`echo "\${opt_elem}" | grep "^--with-simfqt="\`
if [ "\${IS_OPTION_SIMFQT}" != "" ]
then
SIMFQT_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-simfqt=\(.*\)\$/\1/"\`
SIMFQT_OPTION="-DWITH_SIMFQT_PREFIX=\${SIMFQT_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "simlfs" ]
then
cat >> configure << _EOF
IS_OPTION_SIMLFS=\`echo "\${opt_elem}" | grep "^--with-simlfs="\`
if [ "\${IS_OPTION_SIMLFS}" != "" ]
then
SIMLFS_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-simlfs=\(.*\)\$/\1/"\`
SIMLFS_OPTION="-DWITH_SIMLFS_PREFIX=\${SIMLFS_DIR}"
fi
_EOF
fi
#
if [ "${PROJECT_NAME}" != "simcrs" ]
then
cat >> configure << _EOF
IS_OPTION_SIMCRS=\`echo "\${opt_elem}" | grep "^--with-simcrs="\`
if [ "\${IS_OPTION_SIMCRS}" != "" ]
then
SIMCRS_DIR=\`echo "\${opt_elem}" | sed -e "s/^--with-simcrs=\(.*\)\$/\1/"\`
SIMCRS_OPTION="-DWITH_SIMCRS_PREFIX=\${SIMCRS_DIR}"
fi
_EOF
fi
#
cat >> configure << _EOF
IS_OPTION_W_DOC=\`echo "\${opt_elem}" | grep "^--with-doc"\`
if [ "\${IS_OPTION_W_DOC}" != "" ]
then
DOC_OPTION="-DINSTALL_DOC:BOOL=ON"
fi
IS_OPTION_WO_DOC=\`echo "\${opt_elem}" | grep "^--without-doc"\`
if [ "\${IS_OPTION_WO_DOC}" != "" ]
then
DOC_OPTION="-DINSTALL_DOC:BOOL=OFF"
fi
if [ "\${opt_elem}" = "-n" -o "\${opt_elem}" = "-N" -o "\${opt_elem}" = "--norm" ]
then
RM_OPTION=""
fi
if [ "\${opt_elem}" = "-b" -o "\${opt_elem}" = "-B" -o "\${opt_elem}" = "--builddir" ]
then
BUILD_DIR_OPTION="YES"
SOURCE_DIR=".."
fi
done
#
LIB_OPTION=""
if [ -d /usr/lib64 ]
then
LIB_OPTION="-DLIB_SUFFIX=64"
fi
#
BUILD_OPTION="-DCMAKE_BUILD_TYPE:STRING=Debug"
#
CMAKE_CMD="cmake \${PREFIX_OPTION} \${STDAIR_OPTION} \${SEVMGR_OPTION} \${TRADEMGEN_OPTION} \${TRAVELCCM_OPTION} \${AIRTSP_OPTION} \${AIRRAC_OPTION} \${RMOL_OPTION} \${AIRINV_OPTION} \${AVLCAL_OPTION} \${SIMFQT_OPTION} \${SIMLFS_OPTION} \${SIMCRS_OPTION} \${LIB_OPTION} \${BUILD_OPTION} \${DOC_OPTION} \${SOURCE_DIR}"
# Trace on
set -x
##
# Clean potential former builds
\${RM_OPTION}
mkdir -p build
##
# Configuration
if [ "\${BUILD_DIR_OPTION}" = "YES" ]
then
cd build
fi
\${CMAKE_CMD}
if [ "\${BUILD_DIR_OPTION}" = "YES" ]
then
cd -
fi
# Trace back off
set +x
##
# Tell how to build, test and install
echo ""
echo "--------------------"
echo "To build, test and install:"
if [ "\${BUILD_DIR_OPTION}" = "YES" ]
then
echo "alias build_check_install='cd build && make && make check && make install && cd -'"
else
echo "alias build_check_install='make && make check && make install'"
fi
echo "build_check_install"
echo "--------------------"
echo ""
_EOF
#
chmod 755 configure
#
echo "You can now just run ./configure"