2 # Configuration script for the PCI library
3 # (c) 1998--2013 Martin Mares <mj@ucw.cz>
12 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
13 echo >&2 "Please run the configure script from the top-level Makefile"
17 echo_n "Configuring libpci for your system..."
18 if [ -z "$HOST" ] ; then
22 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
24 rel=`/usr/bin/oslevel`
25 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
26 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
28 cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'`
30 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
34 if [ "$sys" = "CYGWIN_NT-5.1" -o "$sys" = "CYGWIN_NT-6.0" ]
40 [ -n "$RELEASE" ] && rel="${RELEASE}"
41 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
42 host=`echo $HOST | sed -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\3/' -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\2/' -e 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
43 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
44 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
45 echo " $host $rel $cpu $sys"
49 echo >$c '#define PCI_CONFIG_H'
50 echo >>$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
51 echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
54 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"'
89 if [ "$realsys" != "GNU/kFreeBSD" ] ; then
95 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
96 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
102 echo >>$c '#define PCI_HAVE_PM_DARWIN_DEVICE'
103 echo >>$m 'WITH_LIBS+=-lresolv -framework CoreFoundation -framework IOKit'
104 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
110 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
111 echo >>$m 'CFLAGS=-g'
112 echo >>$m 'INSTALL=installbsd'
113 echo >>$m 'DIRINSTALL=mkdir -p'
116 echo_n " nbsd-libpci"
117 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
118 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
119 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
120 echo >>$m 'LIBNAME=libpciutils'
121 echo >>$m 'WITH_LIBS+=-lpci'
125 echo_n " hurd i386-ports"
126 echo >>$c '#define PCI_HAVE_PM_HURD_CONF'
127 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
131 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
135 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
136 echo >>$m 'WITH_LIBS+=-lioperm'
140 i?86|x86_64) echo_n " i386-ports"
141 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
144 echo >>$c '#define PCI_HAVE_STDINT_H'
147 echo >>$c '#define PCI_PATH_SYLIXOS_DEVICE "/proc/pci"'
148 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
149 echo >>$c '#define PCI_HAVE_PM_SYLIXOS_DEVICE'
154 echo " Unfortunately, your OS is not supported by the PCI Library"
159 echo >>$m "LIBEXT="$LIBEXT
160 echo >>$c '#define PCI_HAVE_PM_DUMP'
163 echo_n "Checking for zlib support... "
164 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
165 echo "$ZLIB (set manually)"
167 if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
172 echo "$ZLIB (auto-detected)"
174 if [ "$ZLIB" = yes ] ; then
175 echo >>$c '#define PCI_COMPRESSED_IDS'
176 echo >>$c '#define PCI_IDS "pci.ids.gz"'
178 echo >>$m 'WITH_LIBS+=$(LIBZ)'
180 echo >>$c '#define PCI_IDS "pci.ids"'
182 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
184 echo_n "Checking for DNS support... "
185 if [ "$DNS" = yes -o "$DNS" = no ] ; then
186 echo "$DNS (set manually)"
188 if [ -f /usr/include/resolv.h ] ; then
193 echo "$DNS (auto-detected)"
195 if [ "$DNS" = yes ] ; then
196 echo >>$c "#define PCI_USE_DNS"
197 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
198 echo >>$m "WITH_LIBS+=$LIBRESOLV"
201 if [ "$sys" = linux ] ; then
202 echo_n "Checking for libkmod... "
204 if [ -z "$PKG_CONFIG" ] ; then
205 PKG_CONFIG=pkg-config
207 if [ "$LIBKMOD" != no ] ; then
208 if ! which $PKG_CONFIG >/dev/null ; then
209 echo_n "($PKG_CONFIG not found) "
210 elif $PKG_CONFIG libkmod ; then
214 if [ "$LIBKMOD" = yes -o "$LIBKMOD" = no ] ; then
215 echo "$LIBKMOD (set manually)"
216 if [ "$LIBKMOD" = yes -a -z "$LIBKMOD_DETECTED" ] ; then
217 echo "Requested use of libkmod, but it is not available. Giving up."
221 if [ -n "$LIBKMOD_DETECTED" ] ; then
226 echo "$LIBKMOD (auto-detected)"
228 if [ "$LIBKMOD" = yes ] ; then
229 echo >>$c "#define PCI_USE_LIBKMOD"
230 echo >>$m "LIBKMOD_CFLAGS=$($PKG_CONFIG --cflags libkmod)"
231 echo >>$m "LIBKMOD_LIBS=$($PKG_CONFIG --libs libkmod)"
234 echo_n "Checking for udev hwdb support... "
235 if [ "$HWDB" = yes -o "$HWDB" = no ] ; then
236 echo "$HWDB (set manually)"
238 if `which pkg-config >/dev/null && pkg-config --atleast-version=196 libudev` ; then
243 echo "$HWDB (auto-detected)"
245 if [ "$HWDB" = yes ] ; then
246 echo >>$c '#define PCI_HAVE_HWDB'
247 echo >>$m 'LIBUDEV=-ludev'
248 echo >>$m 'WITH_LIBS+=$(LIBUDEV)'
252 echo "Checking whether to build a shared library... $SHARED (set manually)"
253 if [ "$SHARED" = no ] ; then
254 echo >>$m 'PCILIB=$(LIBNAME).a'
255 echo >>$m 'LDLIBS=$(WITH_LIBS)'
256 echo >>$m 'LIB_LDLIBS='
258 if [ "$LIBEXT" = so ]; then
259 echo >>$m 'PCILIB=$(LIBNAME).$(LIBEXT).$(VERSION)'
261 echo >>$m 'PCILIB=$(LIBNAME).$(VERSION).$(LIBEXT)'
263 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
265 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
266 echo >>$c '#define PCI_SHARED_LIB'
267 if [ "$SHARED" = yes -a "$LIBEXT" = so ]; then
268 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).$(LIBEXT)$(ABI_VERSION)'
271 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
273 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
274 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m