2 # Configuration script for the PCI library
3 # (c) 1998--2009 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
26 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
28 rel=`/usr/bin/oslevel`
29 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
30 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
32 cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
34 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
38 if [ "$sys" = "CYGWIN_NT-5.1" -o "$sys" = "CYGWIN_NT-6.0" ]
44 [ -n "$RELEASE" ] && rel="${RELEASE}"
45 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
46 host=`echo $HOST | sed -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\3/' -e 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
47 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
48 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
49 echo " $host $rel $cpu $sys"
53 echo >$c '#define PCI_CONFIG_H'
54 echo >>$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
55 echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
58 echo_n "Looking for access methods..."
64 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
65 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
66 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
67 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
68 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
70 i?86|x86_64) echo_n " i386-ports"
71 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
74 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
78 i?86) echo_n " i386-ports"
79 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
82 echo " The PCI library does not support Solaris for this architecture: $cpu"
86 echo >>$c '#define PCI_HAVE_STDINT_H'
90 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
91 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
96 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
97 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
102 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
103 echo >>$m 'CFLAGS=-g'
104 echo >>$m 'INSTALL=installbsd'
105 echo >>$m 'DIRINSTALL=mkdir -p'
108 echo_n " nbsd-libpci"
109 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
110 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
111 echo >>$m 'LIBNAME=libpciutils'
112 echo >>$m 'WITH_LIBS+=-lpci'
117 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
121 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
122 echo >>$m 'WITH_LIBS+=-lioperm'
125 echo " Unfortunately, your OS is not supported by the PCI Library"
130 echo >>$c '#define PCI_HAVE_PM_DUMP'
133 echo_n "Checking for zlib support... "
134 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
135 echo "$ZLIB (set manually)"
137 if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
142 echo "$ZLIB (auto-detected)"
144 if [ "$ZLIB" = yes ] ; then
145 echo >>$c '#define PCI_COMPRESSED_IDS'
146 echo >>$c '#define PCI_IDS "pci.ids.gz"'
148 echo >>$m 'WITH_LIBS+=$(LIBZ)'
150 echo >>$c '#define PCI_IDS "pci.ids"'
152 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
154 echo_n "Checking for DNS support... "
155 if [ "$DNS" = yes -o "$DNS" = no ] ; then
156 echo "$DNS (set manually)"
158 if [ -f /usr/include/resolv.h ] ; then
163 echo "$DNS (auto-detected)"
165 if [ "$DNS" = yes ] ; then
166 echo >>$c "#define PCI_USE_DNS"
167 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
168 echo >>$m "WITH_LIBS+=$LIBRESOLV"
171 echo "Checking whether to build a shared library... $SHARED (set manually)"
172 if [ "$SHARED" = no ] ; then
173 echo >>$m 'PCILIB=$(LIBNAME).a'
174 echo >>$m 'LDLIBS=$(WITH_LIBS)'
175 echo >>$m 'LIB_LDLIBS='
177 echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
178 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
180 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
181 echo >>$c '#define PCI_SHARED_LIB'
182 if [ "$SHARED" = yes ] ; then
183 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
186 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
188 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
189 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m