2
0

configure 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. # -*- mode: sh -*-
  3. # Minimal configure script which writes out a Makefile.inc
  4. # Copyright 2010, 2011 Colin Walters <walters@verbum.org>
  5. # Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
  6. prefix=/usr
  7. datarootdir=${datarootdir:-${prefix}/share}
  8. # Little helper function for reading args from the commandline.
  9. # it automatically handles -a b and -a=b variants, and returns 1 if
  10. # we need to shift $3.
  11. read_arg() {
  12. # $1 = arg name
  13. # $2 = arg value
  14. # $3 = arg parameter
  15. local rematch='^[^=]*=(.*)$'
  16. if [[ $2 =~ $rematch ]]; then
  17. read "$1" <<< "${BASH_REMATCH[1]}"
  18. else
  19. read "$1" <<< "$3"
  20. # There is no way to shift our callers args, so
  21. # return 1 to indicate they should do it instead.
  22. return 1
  23. fi
  24. }
  25. while (($# > 0)); do
  26. case "${1%%=*}" in
  27. --prefix) read_arg prefix "$@" || shift;;
  28. --bindir) read_arg bindir "$@" || shift;;
  29. --sbindir) read_arg sbindir "$@" || shift;;
  30. --libexecdir) read_arg libexecdir "$@" || shift;;
  31. --datarootdir) read_arg datarootdir "$@" || shift;;
  32. --datadir) read_arg datadir "$@" || shift;;
  33. --sysconfdir) read_arg sysconfdir "$@" || shift;;
  34. --libdir) read_arg libdir "$@" || shift;;
  35. --mandir) read_arg mandir "$@" || shift;;
  36. *) echo "Ignoring unknown option '$1'";;
  37. esac
  38. shift
  39. done
  40. # Handle srcdir != builddir
  41. srcdir=$(dirname $0)
  42. if ! test -f Makefile; then
  43. ln -s ${srcdir}/Makefile Makefile
  44. fi
  45. cat > Makefile.inc.tmp <<EOF
  46. srcdir = ${srcdir}
  47. prefix ?= ${prefix}
  48. bindir ?= ${bindir:-${prefix}/bin}
  49. sbindir ?= ${sbindir:-${prefix}/sbin}
  50. libexecdir ?= ${libexecdir:-${prefix}/libexec}
  51. datarootdir ?= ${datarootdir}
  52. datadir ?= ${datadir:-${datarootdir}}
  53. sysconfdir ?= ${sysconfdir:-${prefix}/etc}
  54. libdir ?= ${libdir:-${prefix}/lib}
  55. mandir ?= ${mandir:-${prefix}/share/man}
  56. EOF
  57. mv Makefile.inc.tmp Makefile.inc