]> git.ipfire.org Git - thirdparty/pciutils.git/blob - lib/configure
By mistake, we were setting PCI_USE_DNS on Linux automatically.
[thirdparty/pciutils.git] / lib / configure
1 #!/bin/sh
2 # Configuration script for the PCI library
3 # (c) 1998--2008 Martin Mares <mj@ucw.cz>
4
5 echo_n() {
6 if [ -n "$BASH" ]
7 then
8 echo -n "$*"
9 else
10 echo "$*\c"
11 fi
12 }
13
14 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
15 echo >&2 "Please run the configure script from the top-level Makefile"
16 exit 1
17 fi
18
19 echo_n "Configuring libpci for your system..."
20 if [ -z "$HOST" ] ; then
21 sys=`uname -s`
22 rel=`uname -r`
23 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
24 then
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/_.*//'`
28 else
29 cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
30 fi
31 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
32 then
33 sys=freebsd
34 fi
35 HOST=${3:-$cpu-$sys}
36 fi
37 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
38 host=`echo $HOST | sed 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
39 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
40 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
41 echo " $host $rel"
42
43 c=config.h
44 m=config.mk
45 echo >$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
46 echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
47 echo >$m 'WITH_LIBS='
48
49 echo_n "Looking for access methods..."
50
51 case $sys in
52 linux*)
53 echo_n " sysfs proc"
54 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
55 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
56 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
57 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
58 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
59 case $cpu in
60 i386|x86_64) echo_n " i386-ports"
61 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
62 ;;
63 esac
64 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
65 ;;
66 sunos)
67 case $cpu in
68 i386) echo_n " i386-ports"
69 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
70 ;;
71 *)
72 echo " The PCI library does not support Solaris for this architecture: $cpu"
73 exit 1
74 ;;
75 esac
76 echo >>$c '#define PCI_HAVE_STDINT_H'
77 ;;
78 freebsd)
79 echo_n " fbsd-device"
80 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
81 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
82 ;;
83 openbsd)
84 echo_n " obsd-device"
85 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
86 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
87 ;;
88 aix)
89 echo_n " aix-device"
90 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
91 echo >>$m 'CFLAGS=-g'
92 echo >>$m 'INSTALL=installbsd'
93 echo >>$m 'DIRINSTALL=mkdir -p'
94 ;;
95 netbsd)
96 echo_n " nbsd-libpci"
97 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
98 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
99 echo >>$m 'LIBNAME=libpciutils'
100 echo >>$m 'WITH_LIBS+=-lpci'
101 ;;
102 gnu)
103 echo_n " i386-ports"
104 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
105 ;;
106 *)
107 echo " Unfortunately, your OS is not supported by the PCI Library"
108 exit 1
109 ;;
110 esac
111
112 echo >>$c '#define PCI_HAVE_PM_DUMP'
113 echo " dump"
114
115 echo_n "Checking for zlib support... "
116 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
117 echo "$ZLIB (set manually)"
118 else
119 if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
120 ZLIB=yes
121 else
122 ZLIB=no
123 fi
124 echo "$ZLIB (auto-detected)"
125 fi
126 if [ "$ZLIB" = yes ] ; then
127 echo >>$c '#define PCI_COMPRESSED_IDS'
128 echo >>$c '#define PCI_IDS "pci.ids.gz"'
129 echo >>$m 'LIBZ=-lz'
130 echo >>$m 'WITH_LIBS+=$(LIBZ)'
131 else
132 echo >>$c '#define PCI_IDS "pci.ids"'
133 fi
134 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
135
136 echo_n "Checking for DNS support... "
137 if [ "$DNS" = yes -o "$DNS" = no ] ; then
138 echo "$DNS (set manually)"
139 else
140 if [ -f /usr/include/resolv.h ] ; then
141 DNS=yes
142 else
143 DNS=no
144 fi
145 echo "$DNS (auto-detected)"
146 fi
147 if [ "$DNS" = yes ] ; then
148 echo >>$c "#define PCI_USE_DNS"
149 echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
150 echo >>$m 'WITH_LIBS+=-lresolv'
151 fi
152
153 echo "Checking whether to build a shared library... $SHARED (set manually)"
154 if [ "$SHARED" = no ] ; then
155 echo >>$m 'PCILIB=$(LIBNAME).a'
156 echo >>$m 'LDLIBS=$(WITH_LIBS)'
157 echo >>$m 'LIB_LDLIBS='
158 else
159 echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
160 # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
161 echo >>$m 'LDLIBS='
162 echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
163 if [ "$SHARED" = yes ] ; then
164 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
165 fi
166 fi
167 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
168
169 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
170 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m