2 # Configuration script for the PCI library
3 # (c) 1998--2013 Martin Mares <mj@ucw.cz>
12 if [ -z "$VERSION" ] ; 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-AT386/i386/;s/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'`
30 if [ "$sys" = "DragonFly" ]
34 if [ "$sys" = "GNU/kFreeBSD" ]
42 if [ "$sys" = "CYGWIN_NT-5.1" -o "$sys" = "CYGWIN_NT-6.0" ]
48 [ -n "$RELEASE" ] && rel="${RELEASE}"
49 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
50 host=`echo $HOST | sed -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\3/' -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\2/' -e 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
51 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
52 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
53 echo " $host $rel $cpu $sys"
57 echo >$c '#define PCI_CONFIG_H'
58 echo >>$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
59 echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
62 echo_n "Looking for access methods..."
66 SYSINCLUDE=/usr/include
72 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
73 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
74 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
75 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
76 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
78 i?86|x86_64) echo_n " i386-ports"
79 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
82 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
87 i?86) echo_n " i386-ports"
88 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
91 echo " The PCI library does not support Solaris for this architecture: $cpu"
95 echo >>$c '#define PCI_HAVE_STDINT_H'
99 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
100 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
101 if [ "$sys" != "kfreebsd" ] ; then
106 echo_n " obsd-device"
107 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
108 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
114 echo >>$c '#define PCI_HAVE_PM_DARWIN_DEVICE'
115 echo >>$m 'WITH_LIBS+=-lresolv -framework CoreFoundation -framework IOKit'
116 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
119 SYSINCLUDE=$(xcrun --sdk macosx --show-sdk-path)/usr/include
123 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
124 echo >>$m 'CFLAGS=-g'
125 echo >>$m 'INSTALL=installbsd'
126 echo >>$m 'DIRINSTALL=mkdir -p'
129 echo_n " nbsd-libpci"
130 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
131 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
132 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
133 echo >>$m 'LIBNAME=libpciutils'
134 echo >>$m 'WITH_LIBS+=-lpci'
138 echo_n " hurd i386-ports"
139 echo >>$c '#define PCI_HAVE_PM_HURD_CONF'
140 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
144 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
149 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
150 if [ "$sys" = "cygwin" ] ; then
151 # ioperm is cygwin specific library and used only by lib/i386-io-cygwin.h
152 echo >>$m 'WITH_LIBS+=-lioperm'
153 elif [ "$sys" = "windows" ] ; then
154 # advapi32 is windows system library and used only by lib/i386-io-windows.h
155 echo >>$m 'WITH_LIBS+=-ladvapi32'
161 i?86|x86_64) echo_n " i386-ports"
162 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
165 echo >>$c '#define PCI_HAVE_STDINT_H'
168 echo >>$c '#define PCI_PATH_SYLIXOS_DEVICE "/proc/pci"'
169 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
170 echo >>$c '#define PCI_HAVE_PM_SYLIXOS_DEVICE'
175 echo " Unfortunately, your OS is not supported by the PCI Library"
180 echo >>$m "LIBEXT="$LIBEXT
181 echo >>$m "EXEEXT="$EXEEXT
182 echo >>$m "LSPCIDIR=\$($LSPCIDIR)"
183 echo >>$c '#define PCI_HAVE_PM_DUMP'
186 echo_n "Checking for zlib support... "
187 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
188 echo "$ZLIB (set manually)"
190 if [ -f "$SYSINCLUDE/zlib.h" -o -f /usr/local/include/zlib.h ] ; then
195 echo "$ZLIB (auto-detected)"
197 if [ "$ZLIB" = yes ] ; then
198 echo >>$c '#define PCI_COMPRESSED_IDS'
199 echo >>$c '#define PCI_IDS "pci.ids.gz"'
201 echo >>$m 'WITH_LIBS+=$(LIBZ)'
203 echo >>$c '#define PCI_IDS "pci.ids"'
205 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
207 echo_n "Checking for DNS support... "
208 if [ "$DNS" = yes -o "$DNS" = no ] ; then
209 echo "$DNS (set manually)"
211 if [ "$sys" != "windows" -a -f "$SYSINCLUDE/resolv.h" ] ; then
216 echo "$DNS (auto-detected)"
218 if [ "$DNS" = yes ] ; then
219 echo >>$c "#define PCI_USE_DNS"
220 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
221 echo >>$m "WITH_LIBS+=$LIBRESOLV"
224 if [ "$sys" = linux ] ; then
225 echo_n "Checking for libkmod... "
227 if [ -z "$PKG_CONFIG" ] ; then
228 PKG_CONFIG=pkg-config
230 if [ "$LIBKMOD" != no ] ; then
231 if ! which $PKG_CONFIG >/dev/null ; then
232 echo_n "($PKG_CONFIG not found) "
233 elif $PKG_CONFIG libkmod ; then
237 if [ "$LIBKMOD" = yes -o "$LIBKMOD" = no ] ; then
238 echo "$LIBKMOD (set manually)"
239 if [ "$LIBKMOD" = yes -a -z "$LIBKMOD_DETECTED" ] ; then
240 echo "Requested use of libkmod, but it is not available. Giving up."
244 if [ -n "$LIBKMOD_DETECTED" ] ; then
249 echo "$LIBKMOD (auto-detected)"
251 if [ "$LIBKMOD" = yes ] ; then
252 echo >>$c "#define PCI_USE_LIBKMOD"
253 echo >>$m "LIBKMOD_CFLAGS=$($PKG_CONFIG --cflags libkmod)"
254 echo >>$m "LIBKMOD_LIBS=$($PKG_CONFIG --libs libkmod)"
257 echo_n "Checking for udev hwdb support... "
258 if [ "$HWDB" = yes -o "$HWDB" = no ] ; then
259 echo "$HWDB (set manually)"
261 if `which pkg-config >/dev/null && pkg-config --atleast-version=196 libudev` ; then
266 echo "$HWDB (auto-detected)"
268 if [ "$HWDB" = yes ] ; then
269 echo >>$c '#define PCI_HAVE_HWDB'
270 echo >>$m 'LIBUDEV=-ludev'
271 echo >>$m 'WITH_LIBS+=$(LIBUDEV)'
275 echo "Checking whether to build a shared library... $SHARED (set manually)"
276 if [ "$SHARED" = no ] ; then
277 echo >>$m 'PCILIB=$(LIBNAME).a'
278 echo >>$m 'LDLIBS=$(WITH_LIBS)'
279 echo >>$m 'LIB_LDLIBS='
281 if [ "$LIBEXT" = so ]; then
282 echo >>$m 'PCILIB=$(LIBNAME).$(LIBEXT).$(VERSION)'
284 echo >>$m 'PCILIB=$(LIBNAME).$(VERSION).$(LIBEXT)'
286 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
288 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
289 echo >>$c '#define PCI_SHARED_LIB'
290 if [ "$SHARED" = yes -a "$LIBEXT" = so ]; then
291 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).$(LIBEXT)$(ABI_VERSION)'
294 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
296 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
297 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m