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