]> mj.ucw.cz Git - pciutils.git/blob - lib/configure
Added more parts of the Windows port.
[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 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                                 alpha|ia64|sparc|sparc64|ppc|ppc64)
56                                                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
57                                                 ;;
58                 esac
59                 ;;
60         sunos)
61                 case $cpu in
62                                 i386)           echo_n " i386-ports"
63                                                 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
64                                                 ok=1
65                                                 ;;
66                                 *)
67                                                 echo " The PCI library is does not support Solaris for this architecture: $cpu"
68                                                 exit 1
69                                                 ;;
70                 esac
71                 ;;
72                 
73         freebsd)
74                 echo_n " fbsd-device"
75                 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
76                 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
77                 ok=1
78                 ;;
79         aix)
80                 echo_n " aix-device"
81                 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
82                 ok=1
83                 ;;
84         netbsd)
85                 echo_n " nbsd-libpci"
86                 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
87                 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
88                 ok=1
89                 ;;
90         gnu)
91                 echo_n " i386-ports"
92                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
93                 ok=1
94                 ;;
95         *)
96                 echo " Unfortunately, your OS is not supported by the PCI Library"
97                 exit 1
98                 ;;
99 esac
100
101 echo >>$c '#define PCI_HAVE_PM_DUMP'
102 echo " dump"
103 if [ -z "$ok" ] ; then
104         echo "WARNING: No real configuration access method is available."
105 fi
106 echo >>$c "#define PCI_PATH_IDS \"$sharedir/pci.ids\""
107 echo >>$c "#define PCILIB_VERSION \"$version\""
108 sed '/^#define [^ ]*$/!d;s/^#define \(.*\)/\1=1/' <$c >config.mk