Refactor bootstrap.sh with more function points
This commit is contained in:
parent
277c1141c4
commit
c6275ab224
102
bootstrap.sh
102
bootstrap.sh
|
@ -1,4 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
|
||||||
|
##### bootstrap FreeSWITCH and FreeSWITCH libraries
|
||||||
|
|
||||||
echo "bootstrap: checking installation..."
|
echo "bootstrap: checking installation..."
|
||||||
|
|
||||||
BGJOB=false
|
BGJOB=false
|
||||||
|
@ -20,17 +23,23 @@ while getopts 'jhd:' o; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
setup_modules() {
|
||||||
if [ ! -f modules.conf ]; then
|
if [ ! -f modules.conf ]; then
|
||||||
cp build/modules.conf.in modules.conf
|
cp build/modules.conf.in modules.conf
|
||||||
fi
|
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/COPYING .
|
||||||
cp -f docs/AUTHORS .
|
cp -f docs/AUTHORS .
|
||||||
cp -f docs/ChangeLog .
|
cp -f docs/ChangeLog .
|
||||||
touch NEWS
|
touch NEWS
|
||||||
touch README
|
touch README
|
||||||
|
}
|
||||||
|
|
||||||
|
check_ac_ver() {
|
||||||
# autoconf 2.59 or newer
|
# autoconf 2.59 or newer
|
||||||
ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
|
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
|
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."
|
echo " to build FreeSWITCH from source."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then
|
if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then
|
||||||
echo "Autoconf 2.62 is broken on OpenBSD, please try another version"
|
echo "Autoconf 2.62 is broken on OpenBSD, please try another version"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS=_; set $ac_version; IFS=' '
|
IFS=_; set $ac_version; IFS=' '
|
||||||
ac_version=$1
|
ac_version=$1
|
||||||
IFS=.; set $ac_version; IFS=' '
|
IFS=.; set $ac_version; IFS=' '
|
||||||
|
@ -56,10 +63,10 @@ exit 1
|
||||||
else
|
else
|
||||||
echo "bootstrap: autoconf version $ac_version (ok)"
|
echo "bootstrap: autoconf version $ac_version (ok)"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_am_ver() {
|
||||||
# automake 1.7 or newer
|
# automake 1.7 or newer
|
||||||
|
|
||||||
am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
|
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
|
if test -z "$am_version"; then
|
||||||
echo "bootstrap: automake not found."
|
echo "bootstrap: automake not found."
|
||||||
|
@ -78,9 +85,10 @@ exit 1
|
||||||
else
|
else
|
||||||
echo "bootstrap: automake version $am_version (ok)"
|
echo "bootstrap: automake version $am_version (ok)"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_acl_ver() {
|
||||||
# aclocal 1.7 or newer
|
# aclocal 1.7 or newer
|
||||||
|
|
||||||
acl_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
|
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
|
if test -z "$acl_version"; then
|
||||||
echo "bootstrap: aclocal not found."
|
echo "bootstrap: aclocal not found."
|
||||||
|
@ -99,7 +107,9 @@ exit 1
|
||||||
else
|
else
|
||||||
echo "bootstrap: aclocal version $acl_version (ok)"
|
echo "bootstrap: aclocal version $acl_version (ok)"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_lt_ver() {
|
||||||
# Sample libtool --version outputs:
|
# 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.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
|
# 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."
|
echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_libtoolize() {
|
||||||
# check libtoolize availability
|
# check libtoolize availability
|
||||||
if [ -n "${LIBTOOL}" ]; then
|
if [ -n "${LIBTOOL}" ]; then
|
||||||
libtoolize=${LIBTOOLIZE:-`dirname "${libtool}"`/libtoolize}
|
libtoolize=${LIBTOOLIZE:-`dirname "${libtool}"`/libtoolize}
|
||||||
|
@ -163,8 +175,9 @@ if [ "x${lt_version}" != "x${ltl_version}" ]; then
|
||||||
echo "$libtool and $libtoolize have different versions"
|
echo "$libtool and $libtoolize have different versions"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
print_autotools_vers() {
|
||||||
#
|
#
|
||||||
# Info output
|
# Info output
|
||||||
#
|
#
|
||||||
|
@ -175,7 +188,9 @@ echo " aclocal : ${ACLOCAL:-`which aclocal`}"
|
||||||
echo " libtool : ${libtool} (${lt_version})"
|
echo " libtool : ${libtool} (${lt_version})"
|
||||||
echo " libtoolize: ${libtoolize}"
|
echo " libtoolize: ${libtoolize}"
|
||||||
echo
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrap_apr() {
|
||||||
echo "Entering directory ${LIBDIR}/apr"
|
echo "Entering directory ${LIBDIR}/apr"
|
||||||
cd ${LIBDIR}/apr
|
cd ${LIBDIR}/apr
|
||||||
|
|
||||||
|
@ -278,9 +293,20 @@ ${AUTOCONF:-autoconf}
|
||||||
echo "Creating include/arch/unix/apr_private.h.in ..."
|
echo "Creating include/arch/unix/apr_private.h.in ..."
|
||||||
${AUTOHEADER:-autoheader}
|
${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
|
# Libs automake automation function
|
||||||
libbootstrap()
|
libbootstrap() {
|
||||||
{
|
|
||||||
i=$1
|
i=$1
|
||||||
if [ -d ${LIBDIR}/${i} ]; then
|
if [ -d ${LIBDIR}/${i} ]; then
|
||||||
echo "Entering directory ${LIBDIR}/${i}"
|
echo "Entering directory ${LIBDIR}/${i}"
|
||||||
|
@ -296,7 +322,6 @@ libbootstrap()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z ${CFFILE} ]; then
|
if [ ! -z ${CFFILE} ]; then
|
||||||
|
|
||||||
LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}`
|
LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}`
|
||||||
LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}`
|
LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}`
|
||||||
AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}`
|
AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}`
|
||||||
|
@ -338,33 +363,8 @@ libbootstrap()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bootstrap_fs() {
|
||||||
# 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
|
|
||||||
cd ${BASEDIR}
|
cd ${BASEDIR}
|
||||||
|
|
||||||
rm -f aclocal.m4
|
rm -f aclocal.m4
|
||||||
${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
|
${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
|
||||||
$libtoolize --copy --automake
|
$libtoolize --copy --automake
|
||||||
|
@ -372,4 +372,34 @@ ${AUTOCONF:-autoconf}
|
||||||
${AUTOHEADER:-autoheader}
|
${AUTOHEADER:-autoheader}
|
||||||
${AUTOMAKE:-automake} --no-force --add-missing --copy
|
${AUTOMAKE:-automake} --no-force --add-missing --copy
|
||||||
rm -rf autom4te*.cache
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue