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