]> git.ipfire.org Git - thirdparty/freeswitch.git/blob - bootstrap.sh
[mod_event_socket] Check if listener is running before pushing more logs or events...
[thirdparty/freeswitch.git] / bootstrap.sh
1 #!/bin/sh
2 ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
3 ##### bootstrap FreeSWITCH and FreeSWITCH libraries
4
5 . $(dirname $0)/scripts/ci/build-requirements.sh
6
7 echo "bootstrap: checking installation..."
8
9 BGJOB=false
10 VERBOSE=false
11 BASEDIR=`pwd`;
12 LIBDIR=${BASEDIR}/libs;
13 SUBDIRS="apr iksemel srtp fs";
14
15 while getopts 'jhd:v' o; do
16 case "$o" in
17 j) BGJOB=true;;
18 d) SUBDIRS="$OPTARG";;
19 v) VERBOSE=true;;
20 h) echo "Usage: $0 <options>"
21 echo " Options:"
22 echo " -d 'library1 library2'"
23 echo " => Bootstrap only specified subdirectories"
24 echo " -j => Run Jobs in Background"
25 exit;;
26 esac
27 done
28
29 ex() {
30 test $VERBOSE && echo "bootstrap: $@" >&2
31 $@
32 }
33
34 setup_modules() {
35 if [ ! -f modules.conf ]; then
36 cp build/modules.conf.in modules.conf
37 fi
38 }
39
40 setup_gnu() {
41 # keep automake from making us magically GPL, and to stop
42 # complaining about missing files.
43 cp -f docs/COPYING .
44 cp -f docs/AUTHORS .
45 cp -f docs/ChangeLog .
46 touch NEWS
47 touch README
48 }
49
50 print_autotools_vers() {
51 #
52 # Info output
53 #
54 echo "Bootstrapping using:"
55 echo " autoconf : ${AUTOCONF:-`which autoconf`}"
56 echo " automake : ${AUTOMAKE:-`which automake`}"
57 echo " aclocal : ${ACLOCAL:-`which aclocal`}"
58 echo " libtool : ${libtool} (${lt_version})"
59 echo " libtoolize: ${libtoolize}"
60 echo " make : ${make} (${make_version})"
61 echo " awk : ${awk} (${awk_version})"
62 echo
63 }
64
65 bootstrap_apr() {
66 echo "Entering directory ${LIBDIR}/apr"
67 cd ${LIBDIR}/apr
68
69 # Licensed to the Apache Software Foundation (ASF) under one or more
70 # contributor license agreements. See the NOTICE file distributed with
71 # this work for additional information regarding copyright ownership.
72 # The ASF licenses this file to You under the Apache License, Version 2.0
73 # (the "License"); you may not use this file except in compliance with
74 # the License. You may obtain a copy of the License at
75 #
76 # http://www.apache.org/licenses/LICENSE-2.0
77 #
78 # Unless required by applicable law or agreed to in writing, software
79 # distributed under the License is distributed on an "AS IS" BASIS,
80 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
81 # See the License for the specific language governing permissions and
82 # limitations under the License.
83 #
84 #
85
86 # bootstrap: Build the support scripts needed to compile from a
87 # checked-out version of the source code.
88
89 # Create the libtool helper files
90 #
91 # Note: we copy (rather than link) them to simplify distribution.
92 # Note: APR supplies its own config.guess and config.sub -- we do not
93 # rely on libtool's versions
94 #
95 echo "Copying libtool helper files ..."
96
97 # Remove any libtool files so one can switch between libtool 1.3
98 # and libtool 1.4 by simply rerunning the bootstrap script.
99 (cd build ; rm -f ltconfig ltmain.sh libtool.m4)
100
101 if ${libtoolize} -n --install >/dev/null 2>&1 ; then
102 $libtoolize --force --copy --install
103 else
104 $libtoolize --force --copy
105 fi
106
107 if [ -f libtool.m4 ]; then
108 ltfile=`pwd`/libtool.m4
109 else
110 if [ $lt_major -eq 2 ]; then
111 ltfindcmd="`sed -n \"/aclocaldir=/{s/.*=/echo /p;q;}\" < $libtoolize`"
112 ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`/libtool.m4}
113 else
114 ltfindcmd="`sed -n \"/=[^\\\`]/p;/libtool_m4=/{s/.*=/echo /p;q;}\" \
115 < $libtoolize`"
116 ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`}
117 fi
118 # Expecting the code above to be very portable, but just in case...
119 if [ -z "$ltfile" -o ! -f "$ltfile" ]; then
120 ltpath=`dirname $libtoolize`
121 ltfile=`cd $ltpath/../share/aclocal ; pwd`/libtool.m4
122 fi
123 fi
124
125 if [ ! -f $ltfile ]; then
126 echo "$ltfile not found"
127 exit 1
128 fi
129
130 echo "bootstrap: Using libtool.m4 at ${ltfile}."
131
132 cat $ltfile | sed -e 's/LIBTOOL=\(.*\)top_build/LIBTOOL=\1apr_build/' > build/libtool.m4
133
134 # libtool.m4 from 1.6 requires ltsugar.m4
135 if [ -f ltsugar.m4 ]; then
136 rm -f build/ltsugar.m4
137 mv ltsugar.m4 build/ltsugar.m4
138 fi
139
140 # Clean up any leftovers
141 rm -f aclocal.m4 libtool.m4
142
143 # fix for FreeBSD (at least):
144 # libtool.m4 is in share/aclocal, while e.g. aclocal19 only looks in share/aclocal19
145 # get aclocal's default directory and include the libtool.m4 directory via -I if
146 # it's in a different location
147
148 aclocal_dir="`${ACLOCAL:-aclocal} --print-ac-dir`"
149
150 if [ -n "${aclocal_dir}" -a -n "${ltfile}" -a "`dirname ${ltfile}`" != "${aclocal_dir}" ] ; then
151 ACLOCAL_OPTS="-I `dirname ${ltfile}`"
152 fi
153
154 ### run aclocal
155 echo "Re-creating aclocal.m4 ..."
156 ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
157
158 ### do some work to toss config.cache?
159 rm -rf config.cache
160
161 echo "Creating configure ..."
162 ${AUTOCONF:-autoconf}
163
164 #
165 # Generate the autoconf header
166 #
167 echo "Creating include/arch/unix/apr_private.h.in ..."
168 ${AUTOHEADER:-autoheader}
169
170 # Remove autoconf 2.5x's cache directory
171 rm -rf autom4te*.cache
172
173 }
174
175 # Libs automake automation function
176 libbootstrap() {
177 i=$1
178 if [ -d ${LIBDIR}/${i} ]; then
179 echo "Entering directory ${LIBDIR}/${i}"
180 ex cd ${LIBDIR}/${i}
181 ex rm -f aclocal.m4
182 CFFILE=
183 if [ -f ${LIBDIR}/${i}/configure.in ]; then
184 CFFILE="${LIBDIR}/${i}/configure.in"
185 else
186 if [ -f ${LIBDIR}/${i}/configure.ac ]; then
187 CFFILE="${LIBDIR}/${i}/configure.ac"
188 fi
189 fi
190
191 if [ ! -z ${CFFILE} ]; then
192 LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}`
193 LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}`
194 AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}`
195 AMTEST2=`grep "AC_PROG_INSTALL" ${CFFILE}`
196 AHTEST=`grep "AC_CONFIG_HEADERS" ${CFFILE}`
197 AXTEST=`grep "ACX_LIBTOOL_C_ONLY" ${CFFILE}`
198
199 echo "Creating aclocal.m4"
200 ex ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} ${ACLOCAL_FLAGS}
201
202 # only run if AC_PROG_LIBTOOL is in configure.in/configure.ac
203 if [ ! -z "${LTTEST}" -o "${LTTEST2}" -o "${AXTEST}" ]; then
204 echo "Running libtoolize..."
205 if ${libtoolize} -n --install >/dev/null 2>&1; then
206 ex $libtoolize --force --copy --install
207 else
208 ex $libtoolize --force --copy
209 fi
210 fi
211
212 echo "Creating configure"
213 ex ${AUTOCONF:-autoconf}
214
215 # only run if AC_CONFIG_HEADERS is found in configure.in/configure.ac
216 if [ ! -z "${AHTEST}" ]; then
217 echo "Running autoheader..."
218 ex ${AUTOHEADER:-autoheader};
219 fi
220
221 # run if AM_INIT_AUTOMAKE / AC_PROG_INSTALL is in configure.in/configure.ac
222 if [ ! -z "${AMTEST}" -o "${AMTEST2}" ]; then
223 echo "Creating Makefile.in"
224 ex ${AUTOMAKE:-automake} --no-force --add-missing --copy;
225 fi
226 ex rm -rf autom4te*.cache
227 fi
228 else
229 echo "Skipping directory ${LIBDIR}/${i}"
230 fi
231 }
232
233 bootstrap_fs() {
234 cd ${BASEDIR}
235 rm -f aclocal.m4
236 ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
237 $libtoolize --copy --automake
238 ${AUTOCONF:-autoconf}
239 ${AUTOHEADER:-autoheader}
240 ${AUTOMAKE:-automake} --no-force --add-missing --copy
241 rm -rf autom4te*.cache
242 }
243
244 bootstrap_libs_pre() {
245 case "$1" in
246 *) return 0;;
247 esac
248 }
249
250 bootstrap_libs_post() {
251 case "$1" in
252 *) return 0;;
253 esac
254 }
255
256 bootstrap_libs() {
257 for i in ${SUBDIRS}; do
258 case "$i" in
259 apr|fs)
260 ${BGJOB} && wait
261 bootstrap_$i
262 continue
263 ;;
264 esac
265 bootstrap_libs_pre ${i}
266 if ! ${BGJOB}; then
267 libbootstrap ${i} ; bootstrap_libs_post ${i}
268 else
269 (libbootstrap ${i} ; bootstrap_libs_post ${i}) &
270 fi
271 done
272 ${BGJOB} && wait
273 }
274
275 run() {
276 setup_modules
277 setup_gnu
278 check_make
279 check_awk
280 check_ac_ver
281 check_am_ver
282 check_acl_ver
283 check_lt_ver
284 check_libtoolize
285 print_autotools_vers
286 bootstrap_libs
287 return 0
288 }
289
290 run
291