bootstrap 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/sh
  2. # This is more portable than `which' but comes with
  3. # the caveat of not(?) properly working on busybox's ash:
  4. have_command()
  5. {
  6. command -v "$1" >/dev/null 2>&1
  7. }
  8. unset bs_srcdir
  9. if test X"`dirname / 2>/dev/null`" = X"/"; then
  10. bs_scrdir=`dirname $0`
  11. else
  12. case $0 in
  13. */*) bs_scrdir=`echo $0 | ${SED-sed} -n -e 's|/.*$||p'` ;;
  14. *) bs_scrdir='.' ;;
  15. esac
  16. fi
  17. test -n "$bs_scrdir" && cd "$bs_scrdir" || echo "Warning: cannot detect sources directory" 1>&2
  18. if test ! -f './configure.ac'; then
  19. echo "Error: no 'configure.ac' found. Wrong sources directory?" 1>&2
  20. exit 2
  21. fi
  22. if test ! -f './src/include/microhttpd.h'; then
  23. echo "Error: src/include/libmicrohttpd.h not found. Wrong sources directory?" 1>&2
  24. exit 2
  25. fi
  26. if have_command uncrustify; then
  27. if test -f uncrustify.cfg; then
  28. echo "Uncrustify configuration already exists, skipping installation from the upstream file."
  29. else
  30. echo "Installing configuration"
  31. ln -s contrib/uncrustify.cfg uncrustify.cfg
  32. fi
  33. if test -d '.git'; then
  34. if test -f .git/hooks/pre-commit; then
  35. echo "Pre-commit git hook already exists, skipping installation from the upstream file."
  36. else
  37. echo "Installing uncrustify pre-commit git hook"
  38. ln -s ../../contrib/uncrustify_precommit .git/hooks/pre-commit
  39. fi
  40. else
  41. echo "No '.git' directory found, skipping installation of pre-commit git hook."
  42. fi
  43. else
  44. echo "Uncrustify not detected, hook not installed. Please install uncrustify if you plan on doing development."
  45. fi
  46. if have_command libtool || have_command libtoolize || have_command glibtoolize || have_command slibtool; then
  47. echo "Running autotools..."
  48. have_command libtoolize && \
  49. aclocal -I m4 --install && \
  50. libtoolize -c -i -v && \
  51. autoconf && \
  52. autoheader && \
  53. automake -a -c --gnu
  54. if test $? -ne 0 || ! test -x configure || ! test -f Makefile.in ; then
  55. echo "Trying with autoreconf..."
  56. if ! autoreconf -i ${1+"$@"} ; then
  57. echo "Failed to autoreconf, retrying with force install..."
  58. rm m4/po.m4 # Version of po.m4 should match installed po/* files
  59. if ! autoreconf -i -f ${1+"$@"} ; then
  60. echo "*** Failed to create 'configure' and other autotools generated files. ***" >&2
  61. exit 1
  62. fi
  63. fi
  64. fi
  65. echo "The ${bs_scrdir-.}/configure is ready to run."
  66. else
  67. echo "*** No libtoolize or libtool found, please install it ***" >&2;
  68. exit 1
  69. fi