2 # Configuration script for the PCI library
3 # (c) 1998--2008 Martin Mares <mj@ucw.cz>
14 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
15 echo >&2 "Please run the configure script from the top-level Makefile"
19 echo_n "Configuring libpci for your system..."
20 if [ -z "$HOST" ] ; then
23 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
25 rel=`/usr/bin/oslevel`
26 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
27 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
29 cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
31 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
35 if [ "$sys" = "CYGWIN_NT-5.1" ]
41 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
42 host=`echo $HOST | sed 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
43 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
44 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
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..."
60 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
61 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
62 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
63 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
64 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
66 i386|x86_64) echo_n " i386-ports"
67 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
70 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
74 i386) echo_n " i386-ports"
75 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
78 echo " The PCI library does not support Solaris for this architecture: $cpu"
82 echo >>$c '#define PCI_HAVE_STDINT_H'
86 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
87 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
92 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
93 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
98 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
100 echo >>$m 'INSTALL=installbsd'
101 echo >>$m 'DIRINSTALL=mkdir -p'
104 echo_n " nbsd-libpci"
105 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
106 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
107 echo >>$m 'LIBNAME=libpciutils'
108 echo >>$m 'WITH_LIBS+=-lpci'
113 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
117 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
118 echo >>$m 'LDLIBS+=-lioperm'
121 echo " Unfortunately, your OS is not supported by the PCI Library"
126 echo >>$c '#define PCI_HAVE_PM_DUMP'
129 echo_n "Checking for zlib support... "
130 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
131 echo "$ZLIB (set manually)"
133 if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
138 echo "$ZLIB (auto-detected)"
140 if [ "$ZLIB" = yes ] ; then
141 echo >>$c '#define PCI_COMPRESSED_IDS'
142 echo >>$c '#define PCI_IDS "pci.ids.gz"'
144 echo >>$m 'WITH_LIBS+=$(LIBZ)'
146 echo >>$c '#define PCI_IDS "pci.ids"'
148 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
150 echo_n "Checking for DNS support... "
151 if [ "$DNS" = yes -o "$DNS" = no ] ; then
152 echo "$DNS (set manually)"
154 if [ -f /usr/include/resolv.h ] ; then
159 echo "$DNS (auto-detected)"
161 if [ "$DNS" = yes ] ; then
162 echo >>$c "#define PCI_USE_DNS"
163 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
164 echo >>$m "WITH_LIBS+=$LIBRESOLV"
167 echo "Checking whether to build a shared library... $SHARED (set manually)"
168 if [ "$SHARED" = no ] ; then
169 echo >>$m 'PCILIB=$(LIBNAME).a'
170 echo >>$m 'LDLIBS=$(WITH_LIBS)'
171 echo >>$m 'LIB_LDLIBS='
173 echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
174 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
176 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
177 echo >>$c '#define PCI_SHARED_LIB'
178 if [ "$SHARED" = yes ] ; then
179 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
182 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
184 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
185 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m