]> git.ipfire.org Git - thirdparty/pciutils.git/blame - lib/configure
Updated test cases from Yu Zhao.
[thirdparty/pciutils.git] / lib / configure
CommitLineData
727ce158 1#!/bin/sh
3b75e19a
MM
2# Configuration script for the PCI library
3# (c) 1998--2008 Martin Mares <mj@ucw.cz>
727ce158 4
14d6c0a3
MM
5echo_n() {
6 if [ -n "$BASH" ]
7 then
8 echo -n "$*"
9 else
10 echo "$*\c"
11 fi
12}
13
3b75e19a
MM
14if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
15 echo >&2 "Please run the configure script from the top-level Makefile"
16 exit 1
14d6c0a3 17fi
3b75e19a
MM
18
19echo_n "Configuring libpci for your system..."
20if [ -z "$HOST" ] ; then
21 sys=`uname -s`
22 rel=`uname -r`
23 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
24 then
25 rel=`/usr/bin/oslevel`
26 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
27 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
28 else
29 cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
30 fi
31 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
32 then
33 sys=freebsd
34 fi
550d67d1
MM
35 if [ "$sys" = "CYGWIN_NT-5.1" ]
36 then
37 sys=cygwin
38 fi
3b75e19a 39 HOST=${3:-$cpu-$sys}
d1058e9d 40fi
f683f54a 41[ -n "$RELEASE" ] && rel="${RELEASE}"
b0eb18cc 42# CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
f683f54a 43host=`echo $HOST | sed -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\3/' -e 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
0d656226
MM
44cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
45sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
f683f54a 46echo " $host $rel $cpu $sys"
168b4f46 47
727ce158 48c=config.h
840d09ae 49m=config.mk
59a0211a 50echo >$c '#define PCI_CONFIG_H'
daf2ef4e 51echo >>$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
b0eb18cc 52echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
d7ea742c 53echo >$m 'WITH_LIBS='
168b4f46 54
14d6c0a3 55echo_n "Looking for access methods..."
17b215b0 56LIBRESOLV=-lresolv
168b4f46
MM
57
58case $sys in
0d656226 59 linux*)
2100f710
MM
60 echo_n " sysfs proc"
61 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
62 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
63 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
64 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
65 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
168b4f46 66 case $cpu in
f683f54a 67 i?86|x86_64) echo_n " i386-ports"
489233b4 68 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
168b4f46 69 ;;
168b4f46 70 esac
15296723 71 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
168b4f46 72 ;;
0d656226 73 sunos)
8fc75dbc 74 case $cpu in
f683f54a 75 i?86) echo_n " i386-ports"
489233b4 76 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
8fc75dbc
MM
77 ;;
78 *)
545d5126 79 echo " The PCI library does not support Solaris for this architecture: $cpu"
8fc75dbc
MM
80 exit 1
81 ;;
82 esac
e49ed044 83 echo >>$c '#define PCI_HAVE_STDINT_H'
8fc75dbc 84 ;;
0d656226 85 freebsd)
14d6c0a3 86 echo_n " fbsd-device"
489233b4
MM
87 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
88 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
17b215b0 89 LIBRESOLV=
168b4f46 90 ;;
b6359063
MM
91 openbsd)
92 echo_n " obsd-device"
93 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
94 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
17b215b0 95 LIBRESOLV=
b6359063 96 ;;
0d656226 97 aix)
14d6c0a3 98 echo_n " aix-device"
489233b4 99 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
840d09ae
MM
100 echo >>$m 'CFLAGS=-g'
101 echo >>$m 'INSTALL=installbsd'
102 echo >>$m 'DIRINSTALL=mkdir -p'
14d6c0a3 103 ;;
0d656226 104 netbsd)
848b4347 105 echo_n " nbsd-libpci"
489233b4
MM
106 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
107 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
d7ea742c
MM
108 echo >>$m 'LIBNAME=libpciutils'
109 echo >>$m 'WITH_LIBS+=-lpci'
17b215b0 110 LIBRESOLV=
848b4347 111 ;;
0d656226 112 gnu)
8fc75dbc 113 echo_n " i386-ports"
489233b4 114 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
80459c65 115 ;;
550d67d1
MM
116 cygwin)
117 echo_n " i386-ports"
118 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
d4553175 119 echo >>$m 'WITH_LIBS+=-lioperm'
550d67d1 120 ;;
168b4f46 121 *)
80459c65 122 echo " Unfortunately, your OS is not supported by the PCI Library"
168b4f46
MM
123 exit 1
124 ;;
727ce158 125esac
168b4f46 126
489233b4 127echo >>$c '#define PCI_HAVE_PM_DUMP'
727ce158 128echo " dump"
cc062b4a
MM
129
130echo_n "Checking for zlib support... "
3b75e19a
MM
131if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
132 echo "$ZLIB (set manually)"
cc062b4a 133else
ff94bc05 134 if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
3b75e19a 135 ZLIB=yes
cc062b4a 136 else
3b75e19a 137 ZLIB=no
cc062b4a 138 fi
3b75e19a 139 echo "$ZLIB (auto-detected)"
cc062b4a 140fi
3b75e19a 141if [ "$ZLIB" = yes ] ; then
cc062b4a 142 echo >>$c '#define PCI_COMPRESSED_IDS'
840d09ae 143 echo >>$c '#define PCI_IDS "pci.ids.gz"'
5670e427 144 echo >>$m 'LIBZ=-lz'
d7ea742c 145 echo >>$m 'WITH_LIBS+=$(LIBZ)'
cc062b4a 146else
840d09ae 147 echo >>$c '#define PCI_IDS "pci.ids"'
cc062b4a 148fi
3b75e19a
MM
149echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
150
151echo_n "Checking for DNS support... "
152if [ "$DNS" = yes -o "$DNS" = no ] ; then
153 echo "$DNS (set manually)"
154else
155 if [ -f /usr/include/resolv.h ] ; then
156 DNS=yes
157 else
158 DNS=no
159 fi
160 echo "$DNS (auto-detected)"
161fi
162if [ "$DNS" = yes ] ; then
163 echo >>$c "#define PCI_USE_DNS"
cd2f6a34 164 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
17b215b0 165 echo >>$m "WITH_LIBS+=$LIBRESOLV"
3b75e19a 166fi
cc062b4a 167
d7ea742c
MM
168echo "Checking whether to build a shared library... $SHARED (set manually)"
169if [ "$SHARED" = no ] ; then
170 echo >>$m 'PCILIB=$(LIBNAME).a'
171 echo >>$m 'LDLIBS=$(WITH_LIBS)'
172 echo >>$m 'LIB_LDLIBS='
173else
5ad89ed9 174 echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
d7ea742c
MM
175 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
176 echo >>$m 'LDLIBS='
177 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
59a0211a 178 echo >>$c '#define PCI_SHARED_LIB'
d7ea742c
MM
179 if [ "$SHARED" = yes ] ; then
180 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
181 fi
182fi
183echo >>$m 'PCILIBPC=$(LIBNAME).pc'
184
3b75e19a 185echo >>$c "#define PCILIB_VERSION \"$VERSION\""
840d09ae 186sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m