forked from signalwire/freeswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·291 lines (248 loc) · 7.57 KB
/
bootstrap.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
#!/bin/sh
##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
##### bootstrap FreeSWITCH and FreeSWITCH libraries
. $(dirname $0)/scripts/ci/build-requirements.sh
echo "bootstrap: checking installation..."
BGJOB=false
VERBOSE=false
BASEDIR=`pwd`;
LIBDIR=${BASEDIR}/libs;
SUBDIRS="apr iksemel srtp fs";
while getopts 'jhd:v' o; do
case "$o" in
j) BGJOB=true;;
d) SUBDIRS="$OPTARG";;
v) VERBOSE=true;;
h) echo "Usage: $0 <options>"
echo " Options:"
echo " -d 'library1 library2'"
echo " => Bootstrap only specified subdirectories"
echo " -j => Run Jobs in Background"
exit;;
esac
done
ex() {
test $VERBOSE && echo "bootstrap: $@" >&2
$@
}
setup_modules() {
if [ ! -f modules.conf ]; then
cp build/modules.conf.in modules.conf
fi
}
setup_gnu() {
# keep automake from making us magically GPL, and to stop
# complaining about missing files.
cp -f docs/COPYING .
cp -f docs/AUTHORS .
cp -f docs/ChangeLog .
touch NEWS
touch README
}
print_autotools_vers() {
#
# Info output
#
echo "Bootstrapping using:"
echo " autoconf : ${AUTOCONF:-`which autoconf`}"
echo " automake : ${AUTOMAKE:-`which automake`}"
echo " aclocal : ${ACLOCAL:-`which aclocal`}"
echo " libtool : ${libtool} (${lt_version})"
echo " libtoolize: ${libtoolize}"
echo " make : ${make} (${make_version})"
echo " awk : ${awk} (${awk_version})"
echo
}
bootstrap_apr() {
echo "Entering directory ${LIBDIR}/apr"
cd ${LIBDIR}/apr
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# bootstrap: Build the support scripts needed to compile from a
# checked-out version of the source code.
# Create the libtool helper files
#
# Note: we copy (rather than link) them to simplify distribution.
# Note: APR supplies its own config.guess and config.sub -- we do not
# rely on libtool's versions
#
echo "Copying libtool helper files ..."
# Remove any libtool files so one can switch between libtool 1.3
# and libtool 1.4 by simply rerunning the bootstrap script.
(cd build ; rm -f ltconfig ltmain.sh libtool.m4)
if ${libtoolize} -n --install >/dev/null 2>&1 ; then
$libtoolize --force --copy --install
else
$libtoolize --force --copy
fi
if [ -f libtool.m4 ]; then
ltfile=`pwd`/libtool.m4
else
if [ $lt_major -eq 2 ]; then
ltfindcmd="`sed -n \"/aclocaldir=/{s/.*=/echo /p;q;}\" < $libtoolize`"
ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`/libtool.m4}
else
ltfindcmd="`sed -n \"/=[^\\\`]/p;/libtool_m4=/{s/.*=/echo /p;q;}\" \
< $libtoolize`"
ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`}
fi
# Expecting the code above to be very portable, but just in case...
if [ -z "$ltfile" -o ! -f "$ltfile" ]; then
ltpath=`dirname $libtoolize`
ltfile=`cd $ltpath/../share/aclocal ; pwd`/libtool.m4
fi
fi
if [ ! -f $ltfile ]; then
echo "$ltfile not found"
exit 1
fi
echo "bootstrap: Using libtool.m4 at ${ltfile}."
cat $ltfile | sed -e 's/LIBTOOL=\(.*\)top_build/LIBTOOL=\1apr_build/' > build/libtool.m4
# libtool.m4 from 1.6 requires ltsugar.m4
if [ -f ltsugar.m4 ]; then
rm -f build/ltsugar.m4
mv ltsugar.m4 build/ltsugar.m4
fi
# Clean up any leftovers
rm -f aclocal.m4 libtool.m4
# fix for FreeBSD (at least):
# libtool.m4 is in share/aclocal, while e.g. aclocal19 only looks in share/aclocal19
# get aclocal's default directory and include the libtool.m4 directory via -I if
# it's in a different location
aclocal_dir="`${ACLOCAL:-aclocal} --print-ac-dir`"
if [ -n "${aclocal_dir}" -a -n "${ltfile}" -a "`dirname ${ltfile}`" != "${aclocal_dir}" ] ; then
ACLOCAL_OPTS="-I `dirname ${ltfile}`"
fi
### run aclocal
echo "Re-creating aclocal.m4 ..."
${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
### do some work to toss config.cache?
rm -rf config.cache
echo "Creating configure ..."
${AUTOCONF:-autoconf}
#
# Generate the autoconf header
#
echo "Creating include/arch/unix/apr_private.h.in ..."
${AUTOHEADER:-autoheader}
# Remove autoconf 2.5x's cache directory
rm -rf autom4te*.cache
}
# Libs automake automation function
libbootstrap() {
i=$1
if [ -d ${LIBDIR}/${i} ]; then
echo "Entering directory ${LIBDIR}/${i}"
ex cd ${LIBDIR}/${i}
ex rm -f aclocal.m4
CFFILE=
if [ -f ${LIBDIR}/${i}/configure.in ]; then
CFFILE="${LIBDIR}/${i}/configure.in"
else
if [ -f ${LIBDIR}/${i}/configure.ac ]; then
CFFILE="${LIBDIR}/${i}/configure.ac"
fi
fi
if [ ! -z ${CFFILE} ]; then
LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}`
LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}`
AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}`
AMTEST2=`grep "AC_PROG_INSTALL" ${CFFILE}`
AHTEST=`grep "AC_CONFIG_HEADERS" ${CFFILE}`
AXTEST=`grep "ACX_LIBTOOL_C_ONLY" ${CFFILE}`
echo "Creating aclocal.m4"
ex ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} ${ACLOCAL_FLAGS}
# only run if AC_PROG_LIBTOOL is in configure.in/configure.ac
if [ ! -z "${LTTEST}" -o "${LTTEST2}" -o "${AXTEST}" ]; then
echo "Running libtoolize..."
if ${libtoolize} -n --install >/dev/null 2>&1; then
ex $libtoolize --force --copy --install
else
ex $libtoolize --force --copy
fi
fi
echo "Creating configure"
ex ${AUTOCONF:-autoconf}
# only run if AC_CONFIG_HEADERS is found in configure.in/configure.ac
if [ ! -z "${AHTEST}" ]; then
echo "Running autoheader..."
ex ${AUTOHEADER:-autoheader};
fi
# run if AM_INIT_AUTOMAKE / AC_PROG_INSTALL is in configure.in/configure.ac
if [ ! -z "${AMTEST}" -o "${AMTEST2}" ]; then
echo "Creating Makefile.in"
ex ${AUTOMAKE:-automake} --no-force --add-missing --copy;
fi
ex rm -rf autom4te*.cache
fi
else
echo "Skipping directory ${LIBDIR}/${i}"
fi
}
bootstrap_fs() {
cd ${BASEDIR}
rm -f aclocal.m4
${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
$libtoolize --copy --automake
${AUTOCONF:-autoconf}
${AUTOHEADER:-autoheader}
${AUTOMAKE:-automake} --no-force --add-missing --copy
rm -rf autom4te*.cache
}
bootstrap_libs_pre() {
case "$1" in
*) return 0;;
esac
}
bootstrap_libs_post() {
case "$1" in
*) return 0;;
esac
}
bootstrap_libs() {
for i in ${SUBDIRS}; do
case "$i" in
apr|fs)
${BGJOB} && wait
bootstrap_$i
continue
;;
esac
bootstrap_libs_pre ${i}
if ! ${BGJOB}; then
libbootstrap ${i} ; bootstrap_libs_post ${i}
else
(libbootstrap ${i} ; bootstrap_libs_post ${i}) &
fi
done
${BGJOB} && wait
}
run() {
setup_modules
setup_gnu
check_make
check_awk
check_ac_ver
check_am_ver
check_acl_ver
check_lt_ver
check_libtoolize
print_autotools_vers
bootstrap_libs
return 0
}
run