xref: /pciutils/lib/configure (revision ee7d8384)
1#!/bin/sh
2
3echo_n() {
4	if [ -n "$BASH" ]
5	then
6		echo -n "$*"
7	else
8		echo "$*\c"
9	fi
10}
11
12echo_n "Configuring libpci for your system..."
13sharedir=${1:-/usr/share}
14version=${2:-0.0}
15sys=`uname -s`
16rel=`uname -r`
17if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
18then
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/_.*//'`
22else
23	cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
24fi
25host=${3:-$cpu-$sys}
26host=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr 'A-Z' 'a-z'`
27cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
28sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
29rel=${4:-$rel}
30echo " $host $rel"
31
32c=config.h
33echo >$c "#define PCI_ARCH_`echo $cpu | tr 'a-z' 'A-Z'`"
34echo >>$c "#define PCI_OS_`echo $sys | tr 'a-z' 'A-Z'`"
35
36echo_n "Looking for access methods..."
37
38case $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		;;
99esac
100
101echo >>$c '#define PCI_HAVE_PM_DUMP'
102echo " dump"
103if [ -z "$ok" ] ; then
104	echo "WARNING: No real configuration access method is available."
105fi
106echo >>$c "#define PCI_PATH_IDS \"$sharedir/pci.ids\""
107echo >>$c "#define PCILIB_VERSION \"$version\""
108sed '/^#define [^ ]*$/!d;s/^#define \(.*\)/\1=1/' <$c >config.mk
109