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)
8 datarootdir=${datarootdir:-${prefix}/share}
10 # Little helper function for reading args from the commandline.
11 # it automatically handles -a b and -a=b variants, and returns 1 if
12 # we need to shift $3.
17 local rematch='^[^=]*=(.*)$'
18 if [[ $2 =~ $rematch ]]; then
19 read "$1" <<< "${BASH_REMATCH[1]}"
22 # There is no way to shift our callers args, so
23 # return 1 to indicate they should do it instead.
30 --prefix) read_arg prefix "$@" || shift;;
31 --bindir) read_arg bindir "$@" || shift;;
32 --sbindir) read_arg sbindir "$@" || shift;;
33 --libexecdir) read_arg libexecdir "$@" || shift;;
34 --datarootdir) read_arg datarootdir "$@" || shift;;
35 --datadir) read_arg datadir "$@" || shift;;
36 --sysconfdir) read_arg sysconfdir "$@" || shift;;
37 --libdir) read_arg libdir "$@" || shift;;
38 --mandir) read_arg mandir "$@" || shift;;
39 *) echo "Ignoring unknown option '$1'";;
44 # Handle srcdir != builddir
46 if ! test -f Makefile; then
47 ln -s ${srcdir}/Makefile Makefile
50 cat > Makefile.inc.tmp <<EOF
54 bindir ?= ${bindir:-${prefix}/bin}
55 sbindir ?= ${sbindir:-${prefix}/sbin}
56 libexecdir ?= ${libexecdir:-${prefix}/libexec}
57 datarootdir ?= ${datarootdir}
58 datadir ?= ${datadir:-${datarootdir}}
59 sysconfdir ?= ${sysconfdir:-${prefix}/etc}
60 libdir ?= ${libdir:-${prefix}/lib}
61 mandir ?= ${mandir:-${prefix}/share/man}
64 mv Makefile.inc.tmp Makefile.inc