2 # Configuration script for the PCI library
3 # (c) 1998--2008 Martin Mares <mj@ucw.cz>
14 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
15 echo >&2 "Please run the configure script from the top-level Makefile"
19 echo_n "Configuring libpci for your system..."
20 if [ -z "$HOST" ] ; then
23 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
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/_.*//'`
29 cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
31 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
35 if [ "$sys" = "CYGWIN_NT-5.1" -o "$sys" = "CYGWIN_NT-6.0" ]
41 [ -n "$RELEASE" ] && rel="${RELEASE}"
42 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
43 host=`echo $HOST | sed -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\3/' -e 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
44 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
45 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
46 echo " $host $rel $cpu $sys"
50 echo >$c '#define PCI_CONFIG_H'
51 echo >>$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
52 echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
55 echo_n "Looking for access methods..."
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"'
67 i?86|x86_64) echo_n " i386-ports"
68 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
71 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
75 i?86) echo_n " i386-ports"
76 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
79 echo " The PCI library does not support Solaris for this architecture: $cpu"
83 echo >>$c '#define PCI_HAVE_STDINT_H'
87 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
88 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
93 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
94 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
99 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
100 echo >>$m 'CFLAGS=-g'
101 echo >>$m 'INSTALL=installbsd'
102 echo >>$m 'DIRINSTALL=mkdir -p'
105 echo_n " nbsd-libpci"
106 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
107 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
108 echo >>$m 'LIBNAME=libpciutils'
109 echo >>$m 'WITH_LIBS+=-lpci'
114 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
118 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
119 echo >>$m 'WITH_LIBS+=-lioperm'
122 echo " Unfortunately, your OS is not supported by the PCI Library"
127 echo >>$c '#define PCI_HAVE_PM_DUMP'
130 echo_n "Checking for zlib support... "
131 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
132 echo "$ZLIB (set manually)"
134 if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
139 echo "$ZLIB (auto-detected)"
141 if [ "$ZLIB" = yes ] ; then
142 echo >>$c '#define PCI_COMPRESSED_IDS'
143 echo >>$c '#define PCI_IDS "pci.ids.gz"'
145 echo >>$m 'WITH_LIBS+=$(LIBZ)'
147 echo >>$c '#define PCI_IDS "pci.ids"'
149 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
151 echo_n "Checking for DNS support... "
152 if [ "$DNS" = yes -o "$DNS" = no ] ; then
153 echo "$DNS (set manually)"
155 if [ -f /usr/include/resolv.h ] ; then
160 echo "$DNS (auto-detected)"
162 if [ "$DNS" = yes ] ; then
163 echo >>$c "#define PCI_USE_DNS"
164 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
165 echo >>$m "WITH_LIBS+=$LIBRESOLV"
168 echo "Checking whether to build a shared library... $SHARED (set manually)"
169 if [ "$SHARED" = no ] ; then
170 echo >>$m 'PCILIB=$(LIBNAME).a'
171 echo >>$m 'LDLIBS=$(WITH_LIBS)'
172 echo >>$m 'LIB_LDLIBS='
174 echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
175 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
177 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
178 echo >>$c '#define PCI_SHARED_LIB'
179 if [ "$SHARED" = yes ] ; then
180 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
183 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
185 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
186 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m