Refactor bootstrap.sh with more function points

This commit is contained in:
Travis Cross 2012-04-04 22:21:56 +00:00
parent 277c1141c4
commit c6275ab224
1 changed files with 339 additions and 309 deletions

View File

@ -1,4 +1,7 @@
#!/bin/sh
##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
##### bootstrap FreeSWITCH and FreeSWITCH libraries
echo "bootstrap: checking installation..."
BGJOB=false
@ -20,17 +23,23 @@ while getopts 'jhd:' o; do
esac
done
setup_modules() {
if [ ! -f modules.conf ]; then
cp build/modules.conf.in modules.conf
fi
}
# keep automake from making us magically GPL, and to stop complaining about missing files.
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
}
check_ac_ver() {
# autoconf 2.59 or newer
ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
if test -z "$ac_version"; then
@ -39,12 +48,10 @@ echo " You need autoconf version 2.59 or newer installed"
echo " to build FreeSWITCH from source."
exit 1
fi
if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then
echo "Autoconf 2.62 is broken on OpenBSD, please try another version"
exit 1
fi
IFS=_; set $ac_version; IFS=' '
ac_version=$1
IFS=.; set $ac_version; IFS=' '
@ -56,10 +63,10 @@ exit 1
else
echo "bootstrap: autoconf version $ac_version (ok)"
fi
}
check_am_ver() {
# automake 1.7 or newer
am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
if test -z "$am_version"; then
echo "bootstrap: automake not found."
@ -78,9 +85,10 @@ exit 1
else
echo "bootstrap: automake version $am_version (ok)"
fi
}
check_acl_ver() {
# aclocal 1.7 or newer
acl_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
if test -z "$acl_version"; then
echo "bootstrap: aclocal not found."
@ -99,7 +107,9 @@ exit 1
else
echo "bootstrap: aclocal version $acl_version (ok)"
fi
}
check_lt_ver() {
# Sample libtool --version outputs:
# ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11)
# ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a
@ -138,7 +148,9 @@ else
echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source."
exit 1
fi
}
check_libtoolize() {
# check libtoolize availability
if [ -n "${LIBTOOL}" ]; then
libtoolize=${LIBTOOLIZE:-`dirname "${libtool}"`/libtoolize}
@ -163,8 +175,9 @@ if [ "x${lt_version}" != "x${ltl_version}" ]; then
echo "$libtool and $libtoolize have different versions"
exit 1
fi
}
print_autotools_vers() {
#
# Info output
#
@ -175,7 +188,9 @@ echo " aclocal : ${ACLOCAL:-`which aclocal`}"
echo " libtool : ${libtool} (${lt_version})"
echo " libtoolize: ${libtoolize}"
echo
}
bootstrap_apr() {
echo "Entering directory ${LIBDIR}/apr"
cd ${LIBDIR}/apr
@ -278,9 +293,20 @@ ${AUTOCONF:-autoconf}
echo "Creating include/arch/unix/apr_private.h.in ..."
${AUTOHEADER:-autoheader}
# Remove autoconf 2.5x's cache directory
rm -rf autom4te*.cache
echo "Entering directory ${LIBDIR}/apr-util"
cd ${LIBDIR}/apr-util
if [ "${BGJOB}" = "false" ]; then
./buildconf
else
./buildconf &
fi
}
# Libs automake automation function
libbootstrap()
{
libbootstrap() {
i=$1
if [ -d ${LIBDIR}/${i} ]; then
echo "Entering directory ${LIBDIR}/${i}"
@ -296,7 +322,6 @@ libbootstrap()
fi
if [ ! -z ${CFFILE} ]; then
LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}`
LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}`
AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}`
@ -338,33 +363,8 @@ libbootstrap()
fi
}
# Remove autoconf 2.5x's cache directory
rm -rf autom4te*.cache
echo "Entering directory ${LIBDIR}/apr-util"
cd ${LIBDIR}/apr-util
if [ "${BGJOB}" = "false" ] ; then
./buildconf
else
./buildconf &
fi
for i in ${SUBDIRS}
do
if [ "${BGJOB}" = "false" ] ; then
libbootstrap ${i}
else
libbootstrap ${i} &
fi
done
if [ "${BGJOB}" = "true" ] ; then
wait
fi
bootstrap_fs() {
cd ${BASEDIR}
rm -f aclocal.m4
${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
$libtoolize --copy --automake
@ -372,4 +372,34 @@ ${AUTOCONF:-autoconf}
${AUTOHEADER:-autoheader}
${AUTOMAKE:-automake} --no-force --add-missing --copy
rm -rf autom4te*.cache
}
bootstrap_libs() {
for i in ${SUBDIRS}; do
if [ "${BGJOB}" = "false" ]; then
libbootstrap ${i}
else
libbootstrap ${i} &
fi
done
}
run() {
setup_modules
setup_gnu
check_ac_ver
check_am_ver
check_acl_ver
check_lt_ver
check_libtoolize
print_autotools_vers
bootstrap_apr
bootstrap_libs
bootstrap_fs
if [ "${BGJOB}" = "true" ]; then
wait
fi
}
run