-
Notifications
You must be signed in to change notification settings - Fork 0
/
autogen.sh
executable file
·273 lines (251 loc) · 7.55 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
#!/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=00
VERSION_PATCH=9
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-airrac=/opt/airrac
# --with-rmol=/opt/rmol --with-sevmgr=/opt/sevmgr
#
_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=""
AIRRAC_OPTION=""
RMOL_OPTION=""
SEVMGR_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-airrac=<airrac_install_dir>] [--with-rmol=<rmol_install_dir>] [--with-sevmgr=<sevmgr_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}" != "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}" != "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
#
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} \${AIRRAC_OPTION} \${RMOL_OPTION} \${SEVMGR_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"