/autogen.sh

http://github.com/hbons/SparkleShare · Shell · 85 lines · 64 code · 17 blank · 4 comment · 14 complexity · b28579829ee5fc149cea7639cb452025 MD5 · raw file

  1. #!/usr/bin/env bash
  2. PROJECT=sparkleshare
  3. function error () {
  4. echo "Error: $1" 1>&2
  5. exit 1
  6. }
  7. function check_autotool_version () {
  8. which $1 &>/dev/null || {
  9. error "$1 is not installed, and is required to configure $PACKAGE"
  10. }
  11. version=$($1 --version | head -n 1 | cut -f4 -d' ')
  12. major=$(echo $version | cut -f1 -d.)
  13. minor=$(echo $version | cut -f2 -d.)
  14. rev=$(echo $version | cut -f3 -d. | sed 's/[^0-9].*$//')
  15. major_check=$(echo $2 | cut -f1 -d.)
  16. minor_check=$(echo $2 | cut -f2 -d.)
  17. rev_check=$(echo $2 | cut -f3 -d.)
  18. if [ $major -lt $major_check ]; then
  19. do_bail=yes
  20. elif [[ $minor -lt $minor_check && $major = $major_check ]]; then
  21. do_bail=yes
  22. elif [[ $rev -lt $rev_check && $minor = $minor_check && $major = $major_check ]]; then
  23. do_bail=yes
  24. fi
  25. if [ x"$do_bail" = x"yes" ]; then
  26. error "$1 version $2 or better is required to configure $PROJECT"
  27. fi
  28. }
  29. function run () {
  30. echo "Running $@ ..."
  31. $@ 2>.autogen.log || {
  32. cat .autogen.log 1>&2
  33. rm .autogen.log
  34. error "Could not run $1, which is required to configure $PROJECT"
  35. }
  36. rm .autogen.log
  37. }
  38. srcdir=$(dirname $0)
  39. test -z "$srcdir" && srcdir=.
  40. (test -f $srcdir/configure.ac) || {
  41. error "Directory \"$srcdir\" does not look like the top-level $PROJECT directory"
  42. }
  43. # MacPorts on OS X only seems to have glibtoolize
  44. WHICHLIBTOOLIZE=$(which libtoolize || which glibtoolize)
  45. if [ x"$WHICHLIBTOOLIZE" == x"" ]; then
  46. error "libtool is required to configure $PROJECT"
  47. fi
  48. LIBTOOLIZE=$(basename $WHICHLIBTOOLIZE)
  49. check_autotool_version aclocal 1.9
  50. check_autotool_version automake 1.9
  51. check_autotool_version autoconf 2.53
  52. check_autotool_version $LIBTOOLIZE 1.4.3
  53. #check_autotool_version intltoolize 0.35.0
  54. check_autotool_version pkg-config 0.14.0
  55. #run intltoolize --force --copy
  56. run $LIBTOOLIZE --force --copy --automake
  57. run aclocal -I build/m4/sparkleshare -I build/m4/shamrock -I build/m4/shave $ACLOCAL_FLAGS
  58. run autoconf
  59. run automake --gnu --add-missing --force --copy \
  60. -Wno-portability -Wno-portability
  61. if [ ! -z "$NOCONFIGURE" ]; then
  62. echo "Done. ./configure skipped."
  63. exit $?
  64. fi
  65. if [ $# = 0 ]; then
  66. echo "WARNING: I am going to run configure without any arguments."
  67. fi
  68. run ./configure --enable-maintainer-mode $@