2 # Configuration script for the PCI library
3 # (c) 1998--2013 Martin Mares <mj@ucw.cz>
17 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
18 echo >&2 "Please run the configure script from the top-level Makefile"
22 echo_n "Configuring libpci for your system..."
23 if [ -z "$HOST" ] ; then
27 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
29 rel=`/usr/bin/oslevel`
30 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
31 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
33 cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'`
35 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
39 if [ "$sys" = "CYGWIN_NT-5.1" -o "$sys" = "CYGWIN_NT-6.0" ]
45 [ -n "$RELEASE" ] && rel="${RELEASE}"
46 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
47 host=`echo $HOST | sed -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\3/' -e 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
48 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
49 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
50 echo " $host $rel $cpu $sys"
54 echo >$c '#define PCI_CONFIG_H'
55 echo >>$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
56 echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
59 echo_n "Looking for access methods..."
66 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
67 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
68 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
69 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
70 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
72 i?86|x86_64) echo_n " i386-ports"
73 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
76 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
80 i?86) echo_n " i386-ports"
81 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
84 echo " The PCI library does not support Solaris for this architecture: $cpu"
88 echo >>$c '#define PCI_HAVE_STDINT_H'
92 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
93 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
94 if [ "$realsys" != "GNU/kFreeBSD" ] ; then
100 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
101 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
107 echo >>$c '#define PCI_HAVE_PM_DARWIN_DEVICE'
108 echo >>$m 'WITH_LIBS+=-lresolv -framework CoreFoundation -framework IOKit'
109 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
115 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
116 echo >>$m 'CFLAGS=-g'
117 echo >>$m 'INSTALL=installbsd'
118 echo >>$m 'DIRINSTALL=mkdir -p'
121 echo_n " nbsd-libpci"
122 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
123 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
124 echo >>$m 'LIBNAME=libpciutils'
125 echo >>$m 'WITH_LIBS+=-lpci'
130 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
134 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
135 echo >>$m 'WITH_LIBS+=-lioperm'
139 i?86|x86_64) echo_n " i386-ports"
140 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
143 echo >>$c '#define PCI_HAVE_STDINT_H'
146 echo " Unfortunately, your OS is not supported by the PCI Library"
151 echo >>$m "LIBEXT="$LIBEXT
152 echo >>$c '#define PCI_HAVE_PM_DUMP'
155 echo_n "Checking for zlib support... "
156 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
157 echo "$ZLIB (set manually)"
159 if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
164 echo "$ZLIB (auto-detected)"
166 if [ "$ZLIB" = yes ] ; then
167 echo >>$c '#define PCI_COMPRESSED_IDS'
168 echo >>$c '#define PCI_IDS "pci.ids.gz"'
170 echo >>$m 'WITH_LIBS+=$(LIBZ)'
172 echo >>$c '#define PCI_IDS "pci.ids"'
174 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
176 echo_n "Checking for DNS support... "
177 if [ "$DNS" = yes -o "$DNS" = no ] ; then
178 echo "$DNS (set manually)"
180 if [ -f /usr/include/resolv.h ] ; then
185 echo "$DNS (auto-detected)"
187 if [ "$DNS" = yes ] ; then
188 echo >>$c "#define PCI_USE_DNS"
189 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
190 echo >>$m "WITH_LIBS+=$LIBRESOLV"
193 if [ "$sys" = linux ] ; then
194 echo_n "Checking for libkmod... "
196 if [ -z "$PKG_CONFIG" ] ; then
197 PKG_CONFIG=pkg-config
199 if [ "$LIBKMOD" != no ] ; then
200 if ! which $PKG_CONFIG >/dev/null ; then
201 echo_n "($PKG_CONFIG not found) "
202 elif $PKG_CONFIG libkmod ; then
206 if [ "$LIBKMOD" = yes -o "$LIBKMOD" = no ] ; then
207 echo "$LIBKMOD (set manually)"
208 if [ "$LIBKMOD" = yes -a -z "$LIBKMOD_DETECTED" ] ; then
209 echo "Requested use of libkmod, but it is not available. Giving up."
213 if [ -n "$LIBKMOD_DETECTED" ] ; then
218 echo "$LIBKMOD (auto-detected)"
220 if [ "$LIBKMOD" = yes ] ; then
221 echo >>$c "#define PCI_USE_LIBKMOD"
222 echo >>$m "LIBKMOD_CFLAGS=$($PKG_CONFIG --cflags libkmod)"
223 echo >>$m "LIBKMOD_LIBS=$($PKG_CONFIG --libs libkmod)"
227 echo "Checking whether to build a shared library... $SHARED (set manually)"
228 if [ "$SHARED" = no ] ; then
229 echo >>$m 'PCILIB=$(LIBNAME).a'
230 echo >>$m 'LDLIBS=$(WITH_LIBS)'
231 echo >>$m 'LIB_LDLIBS='
233 if [ "$LIBEXT" = so ]; then
234 echo >>$m 'PCILIB=$(LIBNAME).$(LIBEXT).$(VERSION)'
236 echo >>$m 'PCILIB=$(LIBNAME).$(VERSION).$(LIBEXT)'
238 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
240 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
241 echo >>$c '#define PCI_SHARED_LIB'
242 if [ "$SHARED" = yes -a "$LIBEXT" = so ]; then
243 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).$(LIBEXT)$(ABI_VERSION)'
246 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
248 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
249 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m