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