Skip to content

Instantly share code, notes, and snippets.

@leedm777
Created March 21, 2013 17:33
Show Gist options
  • Save leedm777/5214941 to your computer and use it in GitHub Desktop.
Save leedm777/5214941 to your computer and use it in GitHub Desktop.
My wrapper for Asterisk's configure script
#!/bin/bash
TOPDIR=.
if test $1 && test -d $1; then
TOPDIR=$1
shift
fi
TOPDIR=$(cd ${TOPDIR} && pwd)
if ! test -d ${TOPDIR}; then
echo "Directory doesn't exist" >&2
exit 1
fi
if ! test -f ${TOPDIR}/main/asterisk.c; then
echo "Run from Asterisk directory" >&2
exit 1
fi
if ! which ccache > /dev/null 2>&1; then
echo "ccache not installed" >&2
exit 1
fi
set -ex
DIR=$(basename ${TOPDIR})
if test -d ${TOPDIR}/.git && ! test -d ${TOPDIR}/.svn; then
# \o/ git!
DIR=$(git symbolic-ref HEAD)
DIR=${DIR##refs/heads/}
DIR=${DIR##svn_}
DIR=${DIR%%-*}
fi
if test -d ${TOPDIR}/.svn && test "$(svn pget svnmerge-integrated ${TOPDIR})"; then
# Team branch - use merge path
# and track across branches of branches
URL=$(svn info ${TOPDIR} | sed -n 's/^Repository Root: // p')
DIR=$(svn pget svnmerge-integrated ${TOPDIR} | sed 's/:.*$//')
while test "$(svn pget svnmerge-integrated ${URL}${DIR})"; do
DIR=$(svn pget svnmerge-integrated ${URL}${DIR} | sed 's/:.*$//')
done
DIR=$(basename ${DIR})
fi
if [[ ${DIR} == C.3* ]]; then
# no noisy dev mode. sadness.
DEV_MODE=yes
else
DEV_MODE=noisy
fi
PREFIX=/opt/Asterisk/${DIR}
: ${CC:="ccache gcc"}
: ${CXX:="ccache g++"}
export CC
export CXX
case $(uname) in
Darwin)
SSLDIR=/usr/local/opt/openssl
SQLITE3DIR=/usr/local/opt/sqlite
# Use homebrew's SSL and sqlite3 library
# OS X NetSNMP is too old for Asterisk
CONFIGFLAGS="--with-ssl=${SSLDIR} --with-sqlite3=${SQLITE3DIR} --without-netsnmp"
# -cert branches don't have my patch to fix openssl include paths. ugh.
if [[ ${DIR} == 1.8.* ]] || [[ ${DIR} == C.3* ]]; then
CFLAGS="-I/usr/local/opt/openssl/include"
fi
# uuid is key-only
CFLAGS="-I/usr/local/opt/ossp-uuid/include ${CFLAGS}"
LDFLAGS="-L/usr/local/opt/ossp-uuid/lib"
PATH=${SSLDIR}/bin:$PATH
;;
Linux)
# EL stores 64-bit libs in /usr/lib64. Cheeky.
if test -d /usr/lib64; then
LDFLAGS="-Wl,-rpath,/usr/lib64 $LDFLAGS"
#CONFIGFLAGS="--libdir=/usr/lib64"
fi
;;
*)
exit 1
;;
esac
if test $(hostname) = dlee-testsuite; then
# test-suite needs asterisk to be installed in /usr.
PREFIX=/usr
if test -d testsuite; then
svn up testsuite
else
svn co https://origsvn.digium.com/svn/testsuite/asterisk/trunk testsuite
fi
fi
if test -d .git; then
# Manually checkout svn repos
if test -d menuselect/.svn; then
svn up menuselect
else
svn co https://origsvn.digium.com/svn/menuselect/trunk menuselect
fi
fi
export LDFLAGS
export CFLAGS
${TOPDIR}/configure --prefix=${PREFIX} --enable-dev-mode=${DEV_MODE} ${CONFIGFLAGS} "$@"
# menuconfig
make menuselect/cmenuselect menuselect-tree menuselect.makeopts
menuselect/cmenuselect --enable "DONT_OPTIMIZE"
echo "=== Will install in ${PREFIX} ==="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment