]>
Commit | Line | Data |
---|---|---|
ecae4d1b | 1 | #!/bin/sh |
c6275ab2 TC |
2 | ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- |
3 | ##### bootstrap FreeSWITCH and FreeSWITCH libraries | |
4 | ||
3afa604a | 5 | . $(dirname $0)/scripts/ci/build-requirements.sh |
6 | ||
ecae4d1b MJ |
7 | echo "bootstrap: checking installation..." |
8 | ||
abb7d2e5 | 9 | BGJOB=false |
82520c68 | 10 | VERBOSE=false |
c219a094 TC |
11 | BASEDIR=`pwd`; |
12 | LIBDIR=${BASEDIR}/libs; | |
8e59603d | 13 | SUBDIRS="apr iksemel srtp fs"; |
c219a094 | 14 | |
82520c68 | 15 | while getopts 'jhd:v' o; do |
c219a094 | 16 | case "$o" in |
6c74fe98 | 17 | j) BGJOB=true;; |
8f3bb106 | 18 | d) SUBDIRS="$OPTARG";; |
82520c68 | 19 | v) VERBOSE=true;; |
6c74fe98 | 20 | h) echo "Usage: $0 <options>" |
c6275ab2 TC |
21 | echo " Options:" |
22 | echo " -d 'library1 library2'" | |
5d3c1da3 | 23 | echo " => Bootstrap only specified subdirectories" |
c6275ab2 TC |
24 | echo " -j => Run Jobs in Background" |
25 | exit;; | |
6c74fe98 BW |
26 | esac |
27 | done | |
abb7d2e5 | 28 | |
82520c68 TC |
29 | ex() { |
30 | test $VERBOSE && echo "bootstrap: $@" >&2 | |
31 | $@ | |
32 | } | |
33 | ||
c6275ab2 TC |
34 | setup_modules() { |
35 | if [ ! -f modules.conf ]; then | |
30ccc85d | 36 | cp build/modules.conf.in modules.conf |
c6275ab2 TC |
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 | ||
c6275ab2 TC |
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}" | |
0ec0f08d KR |
60 | echo " make : ${make} (${make_version})" |
61 | echo " awk : ${awk} (${awk_version})" | |
c6275ab2 TC |
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;}\" \ | |
f2d777f1 | 115 | < $libtoolize`" |
c6275ab2 TC |
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 | |
ecae4d1b MJ |
126 | echo "$ltfile not found" |
127 | exit 1 | |
c6275ab2 | 128 | fi |
ecae4d1b | 129 | |
c6275ab2 | 130 | echo "bootstrap: Using libtool.m4 at ${ltfile}." |
ecae4d1b | 131 | |
c6275ab2 | 132 | cat $ltfile | sed -e 's/LIBTOOL=\(.*\)top_build/LIBTOOL=\1apr_build/' > build/libtool.m4 |
ecae4d1b | 133 | |
c6275ab2 TC |
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 | |
ecae4d1b | 139 | |
c6275ab2 TC |
140 | # Clean up any leftovers |
141 | rm -f aclocal.m4 libtool.m4 | |
ecae4d1b | 142 | |
c6275ab2 TC |
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 | |
ecae4d1b | 147 | |
c6275ab2 | 148 | aclocal_dir="`${ACLOCAL:-aclocal} --print-ac-dir`" |
ecae4d1b | 149 | |
c6275ab2 TC |
150 | if [ -n "${aclocal_dir}" -a -n "${ltfile}" -a "`dirname ${ltfile}`" != "${aclocal_dir}" ] ; then |
151 | ACLOCAL_OPTS="-I `dirname ${ltfile}`" | |
152 | fi | |
ecae4d1b | 153 | |
c6275ab2 TC |
154 | ### run aclocal |
155 | echo "Re-creating aclocal.m4 ..." | |
156 | ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} | |
f2d777f1 | 157 | |
c6275ab2 | 158 | ### do some work to toss config.cache? |
bf60eff5 AM |
159 | rm -rf config.cache |
160 | ||
c6275ab2 TC |
161 | echo "Creating configure ..." |
162 | ${AUTOCONF:-autoconf} | |
f2d777f1 | 163 | |
c6275ab2 TC |
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 | ||
c6275ab2 | 173 | } |
f2d777f1 | 174 | |
abb7d2e5 | 175 | # Libs automake automation function |
c6275ab2 | 176 | libbootstrap() { |
abb7d2e5 | 177 | i=$1 |
c6275ab2 TC |
178 | if [ -d ${LIBDIR}/${i} ]; then |
179 | echo "Entering directory ${LIBDIR}/${i}" | |
82520c68 TC |
180 | ex cd ${LIBDIR}/${i} |
181 | ex rm -f aclocal.m4 | |
c6275ab2 TC |
182 | CFFILE= |
183 | if [ -f ${LIBDIR}/${i}/configure.in ]; then | |
ecae4d1b | 184 | CFFILE="${LIBDIR}/${i}/configure.in" |
c6275ab2 TC |
185 | else |
186 | if [ -f ${LIBDIR}/${i}/configure.ac ]; then | |
187 | CFFILE="${LIBDIR}/${i}/configure.ac" | |
ecae4d1b | 188 | fi |
c6275ab2 | 189 | fi |
ecae4d1b | 190 | |
c6275ab2 | 191 | if [ ! -z ${CFFILE} ]; then |
ecae4d1b MJ |
192 | LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}` |
193 | LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}` | |
de167c44 MJ |
194 | AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}` |
195 | AMTEST2=`grep "AC_PROG_INSTALL" ${CFFILE}` | |
ecae4d1b | 196 | AHTEST=`grep "AC_CONFIG_HEADERS" ${CFFILE}` |
c46e0287 | 197 | AXTEST=`grep "ACX_LIBTOOL_C_ONLY" ${CFFILE}` |
ecae4d1b MJ |
198 | |
199 | echo "Creating aclocal.m4" | |
82520c68 | 200 | ex ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} ${ACLOCAL_FLAGS} |
ecae4d1b | 201 | |
c6275ab2 TC |
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 | |
82520c68 | 206 | ex $libtoolize --force --copy --install |
c6275ab2 | 207 | else |
82520c68 | 208 | ex $libtoolize --force --copy |
c6275ab2 | 209 | fi |
ecae4d1b MJ |
210 | fi |
211 | ||
212 | echo "Creating configure" | |
82520c68 | 213 | ex ${AUTOCONF:-autoconf} |
ecae4d1b | 214 | |
c6275ab2 TC |
215 | # only run if AC_CONFIG_HEADERS is found in configure.in/configure.ac |
216 | if [ ! -z "${AHTEST}" ]; then | |
217 | echo "Running autoheader..." | |
82520c68 | 218 | ex ${AUTOHEADER:-autoheader}; |
ecae4d1b MJ |
219 | fi |
220 | ||
c6275ab2 TC |
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" | |
82520c68 | 224 | ex ${AUTOMAKE:-automake} --no-force --add-missing --copy; |
ecae4d1b | 225 | fi |
82520c68 | 226 | ex rm -rf autom4te*.cache |
c6275ab2 | 227 | fi |
ff960d78 | 228 | else |
c6275ab2 | 229 | echo "Skipping directory ${LIBDIR}/${i}" |
ff960d78 | 230 | fi |
abb7d2e5 MJ |
231 | } |
232 | ||
c6275ab2 TC |
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 | } | |
abb7d2e5 | 243 | |
e9abdac0 MJ |
244 | bootstrap_libs_pre() { |
245 | case "$1" in | |
246 | *) return 0;; | |
247 | esac | |
248 | } | |
249 | ||
250 | bootstrap_libs_post() { | |
251 | case "$1" in | |
cd650f60 | 252 | *) return 0;; |
e9abdac0 MJ |
253 | esac |
254 | } | |
255 | ||
c6275ab2 TC |
256 | bootstrap_libs() { |
257 | for i in ${SUBDIRS}; do | |
8f3bb106 | 258 | case "$i" in |
8e59603d | 259 | apr|fs) |
9d341184 | 260 | ${BGJOB} && wait |
3282a35d TC |
261 | bootstrap_$i |
262 | continue | |
dfc68a72 | 263 | ;; |
8f3bb106 | 264 | esac |
e9abdac0 | 265 | bootstrap_libs_pre ${i} |
5c575b27 | 266 | if ! ${BGJOB}; then |
e9abdac0 | 267 | libbootstrap ${i} ; bootstrap_libs_post ${i} |
5c575b27 | 268 | else |
89c590cd | 269 | (libbootstrap ${i} ; bootstrap_libs_post ${i}) & |
5c575b27 | 270 | fi |
c6275ab2 | 271 | done |
9d341184 | 272 | ${BGJOB} && wait |
c6275ab2 | 273 | } |
abb7d2e5 | 274 | |
c6275ab2 TC |
275 | run() { |
276 | setup_modules | |
277 | setup_gnu | |
0ec0f08d KR |
278 | check_make |
279 | check_awk | |
c6275ab2 TC |
280 | check_ac_ver |
281 | check_am_ver | |
282 | check_acl_ver | |
283 | check_lt_ver | |
284 | check_libtoolize | |
285 | print_autotools_vers | |
c6275ab2 | 286 | bootstrap_libs |
9e25cc2c | 287 | return 0 |
c6275ab2 | 288 | } |
ecae4d1b | 289 | |
c6275ab2 | 290 | run |
ecae4d1b | 291 |