PageRenderTime 26ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/bootstrap.sh

https://github.com/ppanhoto/Freeswitch-mod_mp4
Shell | 372 lines | 259 code | 55 blank | 58 comment | 46 complexity | f3284d8b06c2c0ff65ab6731539a011c MD5 | raw file
  1. #!/bin/sh
  2. echo "bootstrap: checking installation..."
  3. BGJOB=false
  4. while getopts jh arg
  5. do
  6. case $arg in
  7. j) BGJOB=true;;
  8. h) echo "Usage: $0 <options>"
  9. echo " Options:"
  10. echo " -j => Run Jobs in Background"
  11. exit;;
  12. esac
  13. done
  14. BASEDIR=`pwd`;
  15. LIBDIR=${BASEDIR}/libs;
  16. SUBDIRS="ilbc curl iksemel js js/nsprpub libdingaling libedit libsndfile pcre sofia-sip \
  17. speex sqlite srtp openzap freetdm spandsp libg722_1 portaudio unimrcp tiff-3.8.2 broadvoice silk";
  18. if [ ! -f modules.conf ]; then
  19. cp build/modules.conf.in modules.conf
  20. fi
  21. # keep automake from making us magically GPL, and to stop complaining about missing files.
  22. cp -f docs/COPYING .
  23. cp -f docs/AUTHORS .
  24. cp -f docs/ChangeLog .
  25. touch NEWS
  26. touch README
  27. # autoconf 2.59 or newer
  28. ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
  29. if test -z "$ac_version"; then
  30. echo "bootstrap: autoconf not found."
  31. echo " You need autoconf version 2.59 or newer installed"
  32. echo " to build FreeSWITCH from source."
  33. exit 1
  34. fi
  35. if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then
  36. echo "Autoconf 2.62 is broken on OpenBSD, please try another version"
  37. exit 1
  38. fi
  39. IFS=_; set $ac_version; IFS=' '
  40. ac_version=$1
  41. IFS=.; set $ac_version; IFS=' '
  42. if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then
  43. echo "bootstrap: autoconf version $ac_version found."
  44. echo " You need autoconf version 2.59 or newer installed"
  45. echo " to build FreeSWITCH from source."
  46. exit 1
  47. else
  48. echo "bootstrap: autoconf version $ac_version (ok)"
  49. fi
  50. # automake 1.7 or newer
  51. am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
  52. if test -z "$am_version"; then
  53. echo "bootstrap: automake not found."
  54. echo " You need automake version 1.7 or newer installed"
  55. echo " to build FreeSWITCH from source."
  56. exit 1
  57. fi
  58. IFS=_; set $am_version; IFS=' '
  59. am_version=$1
  60. IFS=.; set $am_version; IFS=' '
  61. if test "$1" = "1" -a "$2" -lt "7"; then
  62. echo "bootstrap: automake version $am_version found."
  63. echo " You need automake version 1.7 or newer installed"
  64. echo " to build FreeSWITCH from source."
  65. exit 1
  66. else
  67. echo "bootstrap: automake version $am_version (ok)"
  68. fi
  69. # aclocal 1.7 or newer
  70. acl_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'`
  71. if test -z "$acl_version"; then
  72. echo "bootstrap: aclocal not found."
  73. echo " You need aclocal version 1.7 or newer installed"
  74. echo " to build FreeSWITCH from source."
  75. exit 1
  76. fi
  77. IFS=_; set $acl_version; IFS=' '
  78. acl_version=$1
  79. IFS=.; set $acl_version; IFS=' '
  80. if test "$1" = "1" -a "$2" -lt "7"; then
  81. echo "bootstrap: aclocal version $acl_version found."
  82. echo " You need aclocal version 1.7 or newer installed"
  83. echo " to build FreeSWITCH from source."
  84. exit 1
  85. else
  86. echo "bootstrap: aclocal version $acl_version (ok)"
  87. fi
  88. # Sample libtool --version outputs:
  89. # ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11)
  90. # ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a
  91. # output is multiline from 1.5 onwards
  92. # Require libtool 1.4 or newer
  93. libtool=${LIBTOOL:-`${LIBDIR}/apr/build/PrintPath glibtool libtool libtool22 libtool15 libtool14`}
  94. lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'`
  95. if test -z "$lt_pversion"; then
  96. echo "bootstrap: libtool not found."
  97. echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source."
  98. exit 1
  99. fi
  100. lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
  101. IFS=.; set $lt_version; IFS=' '
  102. lt_status="good"
  103. if test -z "$1"; then a=0 ; else a=$1;fi
  104. if test -z "$2"; then b=0 ; else b=$2;fi
  105. if test -z "$3"; then c=0 ; else c=$3;fi
  106. lt_major=$a
  107. if test "$a" -eq "2"; then
  108. lt_status="good"
  109. elif test "$a" -lt "2"; then
  110. if test "$b" -lt "5" -o "$b" = "5" -a "$c" -lt "14" ; then
  111. lt_status="bad"
  112. fi
  113. else
  114. lt_status="bad"
  115. fi
  116. if test $lt_status = "good"; then
  117. echo "bootstrap: libtool version $lt_pversion (ok)"
  118. else
  119. echo "bootstrap: libtool version $lt_pversion found."
  120. echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source."
  121. exit 1
  122. fi
  123. # check libtoolize availability
  124. if [ -n "${LIBTOOL}" ]; then
  125. libtoolize=${LIBTOOLIZE:-`dirname "${libtool}"`/libtoolize}
  126. else
  127. libtoolize=${LIBTOOLIZE:-`${LIBDIR}/apr/build/PrintPath glibtoolize libtoolize libtoolize22 libtoolize15 libtoolize14`}
  128. fi
  129. if [ "x$libtoolize" = "x" ]; then
  130. echo "libtoolize not found in path"
  131. exit 1
  132. fi
  133. if [ ! -x "$libtoolize" ]; then
  134. echo "$libtoolize does not exist or ist not executable"
  135. exit 1
  136. fi
  137. # compare libtool and libtoolize version
  138. ltl_pversion=`$libtoolize --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'`
  139. ltl_version=`echo $ltl_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
  140. IFS=.; set $ltl_version; IFS=' '
  141. if [ "x${lt_version}" != "x${ltl_version}" ]; then
  142. echo "$libtool and $libtoolize have different versions"
  143. exit 1
  144. fi
  145. #
  146. # Info output
  147. #
  148. echo "Bootstrapping using:"
  149. echo " autoconf : ${AUTOCONF:-`which autoconf`}"
  150. echo " automake : ${AUTOMAKE:-`which automake`}"
  151. echo " aclocal : ${ACLOCAL:-`which aclocal`}"
  152. echo " libtool : ${libtool} (${lt_version})"
  153. echo " libtoolize: ${libtoolize}"
  154. echo
  155. echo "Entering directory ${LIBDIR}/apr"
  156. cd ${LIBDIR}/apr
  157. # Licensed to the Apache Software Foundation (ASF) under one or more
  158. # contributor license agreements. See the NOTICE file distributed with
  159. # this work for additional information regarding copyright ownership.
  160. # The ASF licenses this file to You under the Apache License, Version 2.0
  161. # (the "License"); you may not use this file except in compliance with
  162. # the License. You may obtain a copy of the License at
  163. #
  164. # http://www.apache.org/licenses/LICENSE-2.0
  165. #
  166. # Unless required by applicable law or agreed to in writing, software
  167. # distributed under the License is distributed on an "AS IS" BASIS,
  168. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  169. # See the License for the specific language governing permissions and
  170. # limitations under the License.
  171. #
  172. #
  173. # bootstrap: Build the support scripts needed to compile from a
  174. # checked-out version of the source code.
  175. # Create the libtool helper files
  176. #
  177. # Note: we copy (rather than link) them to simplify distribution.
  178. # Note: APR supplies its own config.guess and config.sub -- we do not
  179. # rely on libtool's versions
  180. #
  181. echo "Copying libtool helper files ..."
  182. # Remove any libtool files so one can switch between libtool 1.3
  183. # and libtool 1.4 by simply rerunning the bootstrap script.
  184. (cd build ; rm -f ltconfig ltmain.sh libtool.m4)
  185. if ${libtoolize} -n --install >/dev/null 2>&1 ; then
  186. $libtoolize --force --copy --install
  187. else
  188. $libtoolize --force --copy
  189. fi
  190. if [ -f libtool.m4 ]; then
  191. ltfile=`pwd`/libtool.m4
  192. else
  193. if [ $lt_major -eq 2 ]; then
  194. ltfindcmd="`sed -n \"/aclocaldir=/{s/.*=/echo /p;q;}\" < $libtoolize`"
  195. ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`/libtool.m4}
  196. else
  197. ltfindcmd="`sed -n \"/=[^\\\`]/p;/libtool_m4=/{s/.*=/echo /p;q;}\" \
  198. < $libtoolize`"
  199. ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`}
  200. fi
  201. # Expecting the code above to be very portable, but just in case...
  202. if [ -z "$ltfile" -o ! -f "$ltfile" ]; then
  203. ltpath=`dirname $libtoolize`
  204. ltfile=`cd $ltpath/../share/aclocal ; pwd`/libtool.m4
  205. fi
  206. fi
  207. if [ ! -f $ltfile ]; then
  208. echo "$ltfile not found"
  209. exit 1
  210. fi
  211. echo "bootstrap: Using libtool.m4 at ${ltfile}."
  212. cat $ltfile | sed -e 's/LIBTOOL=\(.*\)top_build/LIBTOOL=\1apr_build/' > build/libtool.m4
  213. # libtool.m4 from 1.6 requires ltsugar.m4
  214. if [ -f ltsugar.m4 ]; then
  215. rm -f build/ltsugar.m4
  216. mv ltsugar.m4 build/ltsugar.m4
  217. fi
  218. # Clean up any leftovers
  219. rm -f aclocal.m4 libtool.m4
  220. # fix for FreeBSD (at least):
  221. # libtool.m4 is in share/aclocal, while e.g. aclocal19 only looks in share/aclocal19
  222. # get aclocal's default directory and include the libtool.m4 directory via -I if
  223. # it's in a different location
  224. aclocal_dir="`${ACLOCAL:-aclocal} --print-ac-dir`"
  225. if [ -n "${aclocal_dir}" -a -n "${ltfile}" -a "`dirname ${ltfile}`" != "${aclocal_dir}" ] ; then
  226. ACLOCAL_OPTS="-I `dirname ${ltfile}`"
  227. fi
  228. ### run aclocal
  229. echo "Re-creating aclocal.m4 ..."
  230. ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
  231. ### do some work to toss config.cache?
  232. echo "Creating configure ..."
  233. ${AUTOCONF:-autoconf}
  234. #
  235. # Generate the autoconf header
  236. #
  237. echo "Creating include/arch/unix/apr_private.h.in ..."
  238. ${AUTOHEADER:-autoheader}
  239. # Libs automake automation function
  240. libbootstrap()
  241. {
  242. i=$1
  243. if [ -d ${LIBDIR}/${i} ] ; then
  244. echo "Entering directory ${LIBDIR}/${i}"
  245. cd ${LIBDIR}/${i}
  246. rm -f aclocal.m4
  247. CFFILE=
  248. if [ -f ${LIBDIR}/${i}/configure.in ] ; then
  249. CFFILE="${LIBDIR}/${i}/configure.in"
  250. else
  251. if [ -f ${LIBDIR}/${i}/configure.ac ] ; then
  252. CFFILE="${LIBDIR}/${i}/configure.ac"
  253. fi
  254. fi
  255. if [ ! -z ${CFFILE} ] ; then
  256. LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}`
  257. LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}`
  258. AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}`
  259. AMTEST2=`grep "AC_PROG_INSTALL" ${CFFILE}`
  260. AHTEST=`grep "AC_CONFIG_HEADERS" ${CFFILE}`
  261. echo "Creating aclocal.m4"
  262. ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} ${ACLOCAL_FLAGS}
  263. #only run if AC_PROG_LIBTOOL is in configure.in/configure.ac
  264. if [ ! -z "${LTTEST}" -o "${LTTEST2}" ] ; then
  265. echo "Running libtoolize..."
  266. if ${libtoolize} -n --install >/dev/null 2>&1 ; then
  267. $libtoolize --force --copy --install
  268. else
  269. $libtoolize --force --copy
  270. fi
  271. fi
  272. echo "Creating configure"
  273. ${AUTOCONF:-autoconf}
  274. #only run if AC_CONFIG_HEADERS is found in configure.in/configure.ac
  275. if [ ! -z "${AHTEST}" ] ; then
  276. echo "Running autoheader..."
  277. ${AUTOHEADER:-autoheader} ;
  278. fi
  279. #run if AM_INIT_AUTOMAKE / AC_PROG_INSTALL is in configure.in/configure.ac
  280. if [ ! -z "${AMTEST}" -o "${AMTEST2}" ] ; then
  281. echo "Creating Makefile.in"
  282. ${AUTOMAKE:-automake} --no-force --add-missing --copy ;
  283. fi
  284. rm -rf autom4te*.cache
  285. fi
  286. else
  287. echo "Skipping directory ${LIBDIR}/${i}"
  288. fi
  289. }
  290. # Remove autoconf 2.5x's cache directory
  291. rm -rf autom4te*.cache
  292. echo "Entering directory ${LIBDIR}/apr-util"
  293. cd ${LIBDIR}/apr-util
  294. if [ "${BGJOB}" = "false" ] ; then
  295. ./buildconf
  296. else
  297. ./buildconf &
  298. fi
  299. for i in ${SUBDIRS}
  300. do
  301. if [ "${BGJOB}" = "false" ] ; then
  302. libbootstrap ${i}
  303. else
  304. libbootstrap ${i} &
  305. fi
  306. done
  307. if [ "${BGJOB}" = "true" ] ; then
  308. wait
  309. fi
  310. cd ${BASEDIR}
  311. rm -f aclocal.m4
  312. ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS}
  313. $libtoolize --copy --automake
  314. ${AUTOCONF:-autoconf}
  315. ${AUTOHEADER:-autoheader}
  316. ${AUTOMAKE:-automake} --no-force --add-missing --copy
  317. rm -rf autom4te*.cache