buildlib.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/sh
  2. root=$1
  3. shift
  4. if [ -f $root/.nodepends ] ; then
  5. echo "***depends disabled*** use $MAKE yesdepends to re-enable"
  6. exit 0
  7. fi
  8. if [ -z "$MAKE" ] ; then
  9. make=`which gmake 2>/dev/null`
  10. if [ -z "$MAKE" ] ; then
  11. make=make
  12. fi
  13. fi
  14. GZCAT=`which gzcat 2>/dev/null`
  15. if [ -z "$GZCAT" ] ; then
  16. GZCAT=zcat
  17. fi
  18. install=
  19. base=http://files.freeswitch.org/downloads/libs
  20. if [ ! -z "$1" ] && [ "$1" = install ] ; then
  21. install=1
  22. shift
  23. fi
  24. tar=$1
  25. shift
  26. cd $root/libs/.
  27. CFLAGS=
  28. LDFLAGS=
  29. MAKEFLAGS=
  30. if [ -d $tar ] ; then
  31. uncompressed=$tar
  32. tar=
  33. else
  34. uncompressed=`echo $tar | sed "s/\.tar\.gz//g"`
  35. uncompressed=`echo $uncompressed | sed "s/\.tgz//g"`
  36. if [ ! -f $tar ] ; then
  37. rm -fr $uncompressed
  38. wget $base/$tar || ftp $base/$tar
  39. if [ ! -f $tar ] ; then
  40. echo cannot find $tar
  41. exit
  42. fi
  43. fi
  44. if [ ! -d $uncompressed ] ; then
  45. $GZCAT $tar | tar xf -
  46. fi
  47. fi
  48. if [ -f $uncompressed/.complete ] ; then
  49. if [ $uncompressed/.complete -ot $uncompressed ]; then
  50. if [ ! -f $root/.nothanks ] ; then
  51. echo remove stale .complete
  52. rm $uncompressed/.complete
  53. sh -c "cd $uncompressed && $MAKE clean distclean"
  54. fi
  55. fi
  56. fi
  57. if [ -f $uncompressed/.complete ] ; then
  58. echo $uncompressed already installed
  59. exit 0
  60. fi
  61. cd $uncompressed
  62. if [ -f ../$uncompressed.build.sh ] ; then
  63. MAKE=$MAKE ../$uncompressed.build.sh $@
  64. else
  65. $MAKE clean 2>&1
  66. CFLAGS="$MOD_CFLAGS" sh ./configure $@
  67. if [ $? = 0 ] ; then
  68. $MAKE
  69. else
  70. echo ERROR
  71. exit 1
  72. fi
  73. if [ ! -z $install ] ; then
  74. $MAKE install
  75. fi
  76. fi
  77. if [ $? = 0 ] ; then
  78. touch .complete
  79. sleep 1
  80. touch .complete
  81. else
  82. echo ERROR
  83. exit 1
  84. fi
  85. exit 0