automagic 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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=$(which autoheader)
  14. AUTOCONF=$(which autoconf)
  15. LIBTOOLIZE=$(which libtoolize)
  16. ACLOCAL=$(which aclocal)
  17. 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. cp platform/unix/configure.ac .
  25. cp platform/unix/Makefile.am .
  26. if ! sh platform/unix/gen-makefile; then
  27. echo "You should be doing this from the root directory of the project."
  28. exit 1
  29. fi
  30. log "Running autoheader..." >&2
  31. ${AUTOHEADER} 2>&1 || return 1 # Gimmie config.h.in
  32. log "Running libtoolize..." >&2
  33. ${LIBTOOLIZE} --force 2>&1 || return 1
  34. log "Running aclocal..." >&2
  35. ${ACLOCAL} 2>&1 || return 1
  36. log "Running autoconf..." >&2
  37. ${AUTOCONF} 2>&1 || return 1
  38. log "Running automake..." >&2
  39. ${AUTOMAKE} -a 2>&1 || return 1
  40. }
  41. if [[ $1 == "-d" ]]; then
  42. automagic 2>&1
  43. else
  44. (automagic > /dev/null) 2>&1
  45. fi
  46. if [[ $? -eq 1 ]]; then
  47. log "Failed, please contact the developers."
  48. exit 1
  49. else
  50. log "Success, carry on configuring."
  51. fi