]> mj.ucw.cz Git - pciutils.git/blob - lib/configure
6fd652a3310d942ecd52bea9c1ded526e7fdf58c
[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 sharedir=${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 echo " $sys/$cpu $rel"
26
27 c=config.h
28 echo >$c "#define ARCH_`echo $cpu | tr 'a-z' 'A-Z'`"
29 echo >>$c "#define OS_`echo $sys | tr 'a-z' 'A-Z'`"
30
31 echo_n "Looking for access methods..."
32
33 case $sys in
34         Linux)
35                 case $rel in
36                         2.[1-9]*|[3-9]*)        echo_n "sysfs proc"
37                                                 echo >>$c '#define HAVE_PM_LINUX_SYSFS'
38                                                 echo >>$c '#define HAVE_PM_LINUX_PROC'
39                                                 echo >>$c '#define HAVE_LINUX_BYTEORDER_H'
40                                                 echo >>$c '#define PATH_PROC_BUS_PCI "/proc/bus/pci"'
41                                                 echo >>$c '#define PATH_SYS_BUS_PCI "/sys/bus/pci"'
42                                                 ok=1
43                                                 ;;
44                 esac
45                 case $cpu in
46                                 i386)           echo_n " i386-ports"
47                                                 echo >>$c '#define HAVE_PM_INTEL_CONF'
48                                                 ok=1
49                                                 ;;
50                                 alpha|ia64|sparc|sparc64|ppc|ppc64)
51                                                 echo >>$c '#define HAVE_64BIT_ADDRESS'
52                                                 ;;
53                 esac
54                 ;;
55         SunOS)
56                 case $cpu in
57                                 i386)           echo_n " i386-ports"
58                                                 echo >>$c "#define HAVE_PM_INTEL_CONF"
59                                                 ok=1
60                                                 ;;
61                                 *)
62                                                 echo " The PCI library is does not support Solaris for this architecture: $cpu"
63                                                 exit 1
64                                                 ;;
65                 esac
66                 ;;
67                 
68         FreeBSD)
69                 echo_n " fbsd-device"
70                 echo >>$c '#define HAVE_PM_FBSD_DEVICE'
71                 echo >>$c '#define PATH_FBSD_DEVICE "/dev/pci"'
72                 ok=1
73                 ;;
74         AIX)
75                 echo_n " aix-device"
76                 echo >>$c '#define HAVE_PM_AIX_DEVICE'
77                 ok=1
78                 ;;
79         NetBSD)
80                 echo_n " nbsd-libpci"
81                 echo >>$c '#define HAVE_PM_NBSD_LIBPCI'
82                 echo >>$c '#define PATH_NBSD_DEVICE "/dev/pci0"'
83                 ok=1
84                 ;;
85         GNU)
86                 echo_n " i386-ports"
87                 echo >>$c '#define HAVE_PM_INTEL_CONF'
88                 ok=1
89                 ;;
90         *)
91                 echo " Unfortunately, your OS is not supported by the PCI Library"
92                 exit 1
93                 ;;
94 esac
95
96 echo >>$c '#define HAVE_PM_DUMP'
97 echo " dump"
98 if [ -z "$ok" ] ; then
99         echo "WARNING: No real configuration access method is available."
100 fi
101 echo >>$c "#define PATH_PCI_IDS \"$sharedir/pci.ids\""
102 echo >>$c "#define PCILIB_VERSION \"$version\""
103 sed '/^#define [^ ]*$/!d;s/^#define \(.*\)/\1=1/' <$c >config.mk