]> mj.ucw.cz Git - pciutils.git/blob - lib/configure
ecd350352d444fac3d1ddcc5b67b41c2cc5b8feb
[pciutils.git] / lib / configure
1 #!/bin/sh
2
3 echo_n() {
4         if [ -n "$BASH" ]
5         then
6                 echo -n "$*"
7         else
8                 echo "$*\c"
9         fi
10 }
11
12 echo_n "Configuring libpci for your system..."
13 idsdir=${1:-/usr/share}
14 version=${2:-0.0}
15 sys=`uname -s`
16 rel=`uname -r`
17 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
18 then
19         rel=`/usr/bin/oslevel`
20         proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
21         cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
22 else
23         cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
24 fi
25 host=${3:-$cpu-$sys}
26 host=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr 'A-Z' 'a-z'`
27 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
28 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
29 rel=${4:-$rel}
30 echo " $host $rel"
31
32 c=config.h
33 echo >$c "#define PCI_ARCH_`echo $cpu | tr 'a-z' 'A-Z'`"
34 echo >>$c "#define PCI_OS_`echo $sys | tr 'a-z' 'A-Z'`"
35
36 echo_n "Looking for access methods..."
37
38 case $sys in
39         linux*)
40                 case $rel in
41                         2.[1-9]*|[3-9]*)        echo_n " sysfs proc"
42                                                 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
43                                                 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
44                                                 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
45                                                 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
46                                                 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
47                                                 ok=1
48                                                 ;;
49                 esac
50                 case $cpu in
51                                 i386)           echo_n " i386-ports"
52                                                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
53                                                 ok=1
54                                                 ;;
55                 esac
56                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
57                 ;;
58         sunos)
59                 case $cpu in
60                                 i386)           echo_n " i386-ports"
61                                                 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
62                                                 ok=1
63                                                 ;;
64                                 *)
65                                                 echo " The PCI library is does not support Solaris for this architecture: $cpu"
66                                                 exit 1
67                                                 ;;
68                 esac
69                 ;;
70                 
71         freebsd)
72                 echo_n " fbsd-device"
73                 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
74                 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
75                 ok=1
76                 ;;
77         aix)
78                 echo_n " aix-device"
79                 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
80                 ok=1
81                 ;;
82         netbsd)
83                 echo_n " nbsd-libpci"
84                 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
85                 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
86                 ok=1
87                 ;;
88         gnu)
89                 echo_n " i386-ports"
90                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
91                 ok=1
92                 ;;
93         *)
94                 echo " Unfortunately, your OS is not supported by the PCI Library"
95                 exit 1
96                 ;;
97 esac
98
99 echo >>$c '#define PCI_HAVE_PM_DUMP'
100 echo " dump"
101 if [ -z "$ok" ] ; then
102         echo "WARNING: No real configuration access method is available."
103 fi
104 echo >>$c "#define PCI_PATH_IDS \"$idsdir/pci.ids\""
105 echo >>$c "#define PCILIB_VERSION \"$version\""
106 sed '/^#define [^ ]*$/!d;s/^#define \(.*\)/\1=1/' <$c >config.mk