automagic 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. log() {
  3. echo "[automagic] " $@
  4. }
  5. die() {
  6. log "Fatal: "$@
  7. exit 1
  8. }
  9. if [[ ! -d platform/unix ]]; then
  10. log "Can't find the 'plaform/unix' folder, make sure you run this from the root of the repository."
  11. exit 1
  12. fi
  13. AUTOHEADER=${AUTOHEADER:-$(which autoheader)}
  14. AUTOCONF=${AUTOCONF:-$(which autoconf)}
  15. LIBTOOLIZE=${LIBTOOLIZE:-$(which libtoolize)}
  16. ACLOCAL=${ACLOCAL:-$(which aclocal)}
  17. AUTOMAKE=${AUTOMAKE:-$(which automake)}
  18. [[ -x ${AUTOHEADER} ]] || die "Could not find autoheader. Install autoconf."
  19. [[ -x ${AUTOCONF} ]] || die "Could not find autoconf."
  20. [[ -x ${LIBTOOLIZE} ]] || die "Could not find libtoolize. Install libtool."
  21. [[ -x ${ACLOCAL} ]] || die "Could not find aclocal. Install automake."
  22. [[ -x ${AUTOMAKE} ]] || die "Could not find automake."
  23. automagic() {
  24. log "Copying files..." >&2
  25. cp platform/unix/configure.ac .
  26. cp platform/unix/Makefile.am .
  27. log "Running genmodules..." >&2
  28. if ! bash platform/unix/genmodules "$1"; then
  29. echo "You should be doing this from the root directory of the project."
  30. exit 1
  31. fi
  32. log "Running autoheader..." >&2
  33. ${AUTOHEADER} 2>&1 || return 1 # Gimmie config.h.in
  34. log "Running libtoolize..." >&2
  35. ${LIBTOOLIZE} --force 2>&1 || return 1
  36. log "Running aclocal..." >&2
  37. ${ACLOCAL} 2>&1 || return 1
  38. log "Running autoconf..." >&2
  39. ${AUTOCONF} 2>&1 || return 1
  40. log "Running automake..." >&2
  41. ${AUTOMAKE} -a 2>&1 || return 1
  42. }
  43. if [[ $1 == "-d" ]]; then
  44. shift 1
  45. automagic "$@" 2>&1
  46. else
  47. (automagic "$@" > /dev/null) 2>&1
  48. fi
  49. if [[ $? -eq 1 ]]; then
  50. log "Failed, sadface."
  51. log "You can make this script more verbose running it in debug mode (-d)"
  52. log "This is generally a configuration error (I'm looking at you aclocal)"
  53. exit 1
  54. else
  55. log "Success, carry on configuring."
  56. fi