]> mj.ucw.cz Git - pciutils.git/blob - lib/configure
Added support for GNU/kFreeBSD.
[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 if [ "$sys" = "GNU/kFreeBSD" ]
26 then
27         sys=freebsd
28 fi
29 host=${3:-$cpu-$sys}
30 host=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr 'A-Z' 'a-z'`
31 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
32 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
33 rel=${4:-$rel}
34 echo " $host $rel"
35
36 c=config.h
37 echo >$c "#define PCI_ARCH_`echo $cpu | tr 'a-z' 'A-Z'`"
38 echo >>$c "#define PCI_OS_`echo $sys | tr 'a-z' 'A-Z'`"
39
40 echo_n "Looking for access methods..."
41
42 case $sys in
43         linux*)
44                 case $rel in
45                         2.[1-9]*|[3-9]*)        echo_n " sysfs proc"
46                                                 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
47                                                 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
48                                                 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
49                                                 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
50                                                 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
51                                                 ok=1
52                                                 ;;
53                 esac
54                 case $cpu in
55                                 i386)           echo_n " i386-ports"
56                                                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
57                                                 ok=1
58                                                 ;;
59                 esac
60                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
61                 ;;
62         sunos)
63                 case $cpu in
64                                 i386)           echo_n " i386-ports"
65                                                 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
66                                                 ok=1
67                                                 ;;
68                                 *)
69                                                 echo " The PCI library is does not support Solaris for this architecture: $cpu"
70                                                 exit 1
71                                                 ;;
72                 esac
73                 ;;
74                 
75         freebsd)
76                 echo_n " fbsd-device"
77                 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
78                 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
79                 ok=1
80                 ;;
81         openbsd)
82                 echo_n " obsd-device"
83                 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
84                 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
85                 ok=1
86                 ;;
87         aix)
88                 echo_n " aix-device"
89                 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
90                 ok=1
91                 ;;
92         netbsd)
93                 echo_n " nbsd-libpci"
94                 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
95                 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
96                 ok=1
97                 ;;
98         gnu)
99                 echo_n " i386-ports"
100                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
101                 ok=1
102                 ;;
103         *)
104                 echo " Unfortunately, your OS is not supported by the PCI Library"
105                 exit 1
106                 ;;
107 esac
108
109 echo >>$c '#define PCI_HAVE_PM_DUMP'
110 echo " dump"
111 if [ -z "$ok" ] ; then
112         echo "WARNING: No real configuration access method is available."
113 fi
114 echo >>$c "#define PCI_PATH_IDS \"$idsdir/pci.ids\""
115 echo >>$c "#define PCILIB_VERSION \"$version\""
116 sed '/^#define [^ ]*$/!d;s/^#define \(.*\)/\1=1/' <$c >config.mk