- Updated pci, usb, vendor ids and hwdb files
[oweals/hwdata.git] / configure
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
7 prefix=/usr
8
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.
12 read_arg() {
13     # $1 = arg name
14     # $2 = arg value
15     # $3 = arg parameter
16     local rematch='^[^=]*=(.*)$'
17     if [[ $2 =~ $rematch ]]; then
18         read "$1" <<< "${BASH_REMATCH[1]}"
19     else
20         read "$1" <<< "$3"
21         # There is no way to shift our callers args, so
22         # return 1 to indicate they should do it instead.
23         return 1
24     fi
25 }
26
27 while (($# > 0)); do
28     case "${1%%=*}" in
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'";;
39     esac
40     shift
41 done
42
43 # Handle srcdir != builddir
44 srcdir=$(dirname $0)
45 if ! test -f Makefile; then
46     ln -s ${srcdir}/Makefile Makefile
47 fi
48
49 cat > Makefile.inc.tmp <<EOF
50 srcdir = ${srcdir}
51
52 prefix ?= ${prefix}
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}
61
62 EOF
63 mv Makefile.inc.tmp Makefile.inc