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..."
65 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
66 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
67 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
68 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
69 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
71 i?86|x86_64) echo_n " i386-ports"
72 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
75 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
79 i?86) echo_n " i386-ports"
80 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
83 echo " The PCI library does not support Solaris for this architecture: $cpu"
87 echo >>$c '#define PCI_HAVE_STDINT_H'
91 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
92 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
93 if [ "$realsys" != "GNU/kFreeBSD" ] ; then
99 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
100 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
105 echo_n " darwin-device"
106 echo >>$c '#define PCI_HAVE_PM_DARWIN_DEVICE'
107 echo >>$m 'WITH_LIBS+=-lresolv -framework CoreFoundation -framework IOKit'
108 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
113 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
114 echo >>$m 'CFLAGS=-g'
115 echo >>$m 'INSTALL=installbsd'
116 echo >>$m 'DIRINSTALL=mkdir -p'
119 echo_n " nbsd-libpci"
120 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
121 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
122 echo >>$m 'LIBNAME=libpciutils'
123 echo >>$m 'WITH_LIBS+=-lpci'
128 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
132 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
133 echo >>$m 'WITH_LIBS+=-lioperm'
137 i?86|x86_64) echo_n " i386-ports"
138 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
141 echo >>$c '#define PCI_HAVE_STDINT_H'
144 echo " Unfortunately, your OS is not supported by the PCI Library"
149 echo >>$c '#define PCI_HAVE_PM_DUMP'
152 echo_n "Checking for zlib support... "
153 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
154 echo "$ZLIB (set manually)"
156 if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
161 echo "$ZLIB (auto-detected)"
163 if [ "$ZLIB" = yes ] ; then
164 echo >>$c '#define PCI_COMPRESSED_IDS'
165 echo >>$c '#define PCI_IDS "pci.ids.gz"'
167 echo >>$m 'WITH_LIBS+=$(LIBZ)'
169 echo >>$c '#define PCI_IDS "pci.ids"'
171 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
173 echo_n "Checking for DNS support... "
174 if [ "$DNS" = yes -o "$DNS" = no ] ; then
175 echo "$DNS (set manually)"
177 if [ -f /usr/include/resolv.h ] ; then
182 echo "$DNS (auto-detected)"
184 if [ "$DNS" = yes ] ; then
185 echo >>$c "#define PCI_USE_DNS"
186 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
187 echo >>$m "WITH_LIBS+=$LIBRESOLV"
190 if [ "$sys" = linux ] ; then
191 echo_n "Checking for libkmod... "
193 if [ -z "$PKG_CONFIG" ] ; then
194 PKG_CONFIG=pkg-config
196 if [ "$LIBKMOD" != no ] ; then
197 if ! which $PKG_CONFIG >/dev/null ; then
198 echo_n "($PKG_CONFIG not found) "
199 elif $PKG_CONFIG libkmod ; then
203 if [ "$LIBKMOD" = yes -o "$LIBKMOD" = no ] ; then
204 echo "$LIBKMOD (set manually)"
205 if [ "$LIBKMOD" = yes -a -z "$LIBKMOD_DETECTED" ] ; then
206 echo "Requested use of libkmod, but it is not available. Giving up."
210 if [ -n "$LIBKMOD_DETECTED" ] ; then
215 echo "$LIBKMOD (auto-detected)"
217 if [ "$LIBKMOD" = yes ] ; then
218 echo >>$c "#define PCI_USE_LIBKMOD"
219 echo >>$m "LIBKMOD_CFLAGS=$($PKG_CONFIG --cflags libkmod)"
220 echo >>$m "LIBKMOD_LIBS=$($PKG_CONFIG --libs libkmod)"
224 echo "Checking whether to build a shared library... $SHARED (set manually)"
225 if [ "$SHARED" = no ] ; then
226 echo >>$m 'PCILIB=$(LIBNAME).a'
227 echo >>$m 'LDLIBS=$(WITH_LIBS)'
228 echo >>$m 'LIB_LDLIBS='
230 echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
231 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
233 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
234 echo >>$c '#define PCI_SHARED_LIB'
235 if [ "$SHARED" = yes ] ; then
236 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
239 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
241 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
242 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m