]> mj.ucw.cz Git - pciutils.git/blob - lib/configure
libresolv is not available on BSD systems, but they have resolver in libc.
[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 LIBRESOLV=-lresolv
51
52 case $sys in
53         linux*)
54                 echo_n " sysfs proc"
55                 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
56                 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
57                 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
58                 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
59                 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
60                 case $cpu in
61                                 i386|x86_64)    echo_n " i386-ports"
62                                                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
63                                                 ;;
64                 esac
65                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
66                 ;;
67         sunos)
68                 case $cpu in
69                                 i386)           echo_n " i386-ports"
70                                                 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
71                                                 ;;
72                                 *)
73                                                 echo " The PCI library does not support Solaris for this architecture: $cpu"
74                                                 exit 1
75                                                 ;;
76                 esac
77                 echo >>$c '#define PCI_HAVE_STDINT_H'
78                 ;;
79         freebsd)
80                 echo_n " fbsd-device"
81                 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
82                 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
83                 LIBRESOLV=
84                 ;;
85         openbsd)
86                 echo_n " obsd-device"
87                 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
88                 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
89                 LIBRESOLV=
90                 ;;
91         aix)
92                 echo_n " aix-device"
93                 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
94                 echo >>$m 'CFLAGS=-g'
95                 echo >>$m 'INSTALL=installbsd'
96                 echo >>$m 'DIRINSTALL=mkdir -p'
97                 ;;
98         netbsd)
99                 echo_n " nbsd-libpci"
100                 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
101                 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
102                 echo >>$m 'LIBNAME=libpciutils'
103                 echo >>$m 'WITH_LIBS+=-lpci'
104                 LIBRESOLV=
105                 ;;
106         gnu)
107                 echo_n " i386-ports"
108                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
109                 ;;
110         *)
111                 echo " Unfortunately, your OS is not supported by the PCI Library"
112                 exit 1
113                 ;;
114 esac
115
116 echo >>$c '#define PCI_HAVE_PM_DUMP'
117 echo " dump"
118
119 echo_n "Checking for zlib support... "
120 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
121         echo "$ZLIB (set manually)"
122 else
123         if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
124                 ZLIB=yes
125         else
126                 ZLIB=no
127         fi
128         echo "$ZLIB (auto-detected)"
129 fi
130 if [ "$ZLIB" = yes ] ; then
131         echo >>$c '#define PCI_COMPRESSED_IDS'
132         echo >>$c '#define PCI_IDS "pci.ids.gz"'
133         echo >>$m 'LIBZ=-lz'
134         echo >>$m 'WITH_LIBS+=$(LIBZ)'
135 else
136         echo >>$c '#define PCI_IDS "pci.ids"'
137 fi
138 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
139
140 echo_n "Checking for DNS support... "
141 if [ "$DNS" = yes -o "$DNS" = no ] ; then
142         echo "$DNS (set manually)"
143 else
144         if [ -f /usr/include/resolv.h ] ; then
145                 DNS=yes
146         else
147                 DNS=no
148         fi
149         echo "$DNS (auto-detected)"
150 fi
151 if [ "$DNS" = yes ] ; then
152         echo >>$c "#define PCI_USE_DNS"
153         echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
154         echo >>$m "WITH_LIBS+=$LIBRESOLV"
155 fi
156
157 echo "Checking whether to build a shared library... $SHARED (set manually)"
158 if [ "$SHARED" = no ] ; then
159         echo >>$m 'PCILIB=$(LIBNAME).a'
160         echo >>$m 'LDLIBS=$(WITH_LIBS)'
161         echo >>$m 'LIB_LDLIBS='
162 else
163         echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
164         # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
165         echo >>$m 'LDLIBS='
166         echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
167         if [ "$SHARED" = yes ] ; then
168                 echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
169         fi
170 fi
171 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
172
173 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
174 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m