]> mj.ucw.cz Git - pciutils.git/blob - lib/configure
69f4272838c12f802487904fe8e580ed36ed4125
[pciutils.git] / lib / configure
1 #!/bin/sh
2 # Configuration script for the PCI library
3 # (c) 1998--2009 Martin Mares <mj@ucw.cz>
4
5 LC_ALL=C
6 export LC_ALL
7
8 echo_n() {
9         if [ -n "$BASH" ]
10         then
11                 echo -n "$*"
12         else
13                 echo "$*\c"
14         fi
15 }
16
17 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
18         echo >&2 "Please run the configure script from the top-level Makefile"
19         exit 1
20 fi
21
22 echo_n "Configuring libpci for your system..."
23 if [ -z "$HOST" ] ; then
24         sys=`uname -s`
25         rel=`uname -r`
26         if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
27         then
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/_.*//'`
31         else
32                 cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
33         fi
34         if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
35         then
36                 sys=freebsd
37         fi
38         if [ "$sys" = "CYGWIN_NT-5.1" -o "$sys" = "CYGWIN_NT-6.0" ]
39         then
40                 sys=cygwin
41         fi
42         HOST=${3:-$cpu-$sys}
43 fi
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"
50
51 c=config.h
52 m=config.mk
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]'`"
56 echo >$m 'WITH_LIBS='
57
58 echo_n "Looking for access methods..."
59 LIBRESOLV=-lresolv
60
61 case $sys in
62         linux*)
63                 echo_n " sysfs proc"
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"'
69                 case $cpu in
70                                 i?86|x86_64)    echo_n " i386-ports"
71                                                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
72                                                 ;;
73                 esac
74                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
75                 ;;
76         sunos)
77                 case $cpu in
78                                 i?86)           echo_n " i386-ports"
79                                                 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
80                                                 ;;
81                                 *)
82                                                 echo " The PCI library does not support Solaris for this architecture: $cpu"
83                                                 exit 1
84                                                 ;;
85                 esac
86                 echo >>$c '#define PCI_HAVE_STDINT_H'
87                 ;;
88         freebsd)
89                 echo_n " fbsd-device"
90                 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
91                 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
92                 LIBRESOLV=
93                 ;;
94         openbsd)
95                 echo_n " obsd-device"
96                 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
97                 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
98                 LIBRESOLV=
99                 ;;
100         aix)
101                 echo_n " aix-device"
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'
106                 ;;
107         netbsd)
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'
113                 LIBRESOLV=
114                 ;;
115         gnu)
116                 echo_n " i386-ports"
117                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
118                 ;;
119         cygwin)
120                 echo_n " i386-ports"
121                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
122                 echo >>$m 'WITH_LIBS+=-lioperm'
123                 ;;
124         *)
125                 echo " Unfortunately, your OS is not supported by the PCI Library"
126                 exit 1
127                 ;;
128 esac
129
130 echo >>$c '#define PCI_HAVE_PM_DUMP'
131 echo " dump"
132
133 echo_n "Checking for zlib support... "
134 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
135         echo "$ZLIB (set manually)"
136 else
137         if [ -f /usr/include/zlib.h -o -f /usr/local/include/zlib.h ] ; then
138                 ZLIB=yes
139         else
140                 ZLIB=no
141         fi
142         echo "$ZLIB (auto-detected)"
143 fi
144 if [ "$ZLIB" = yes ] ; then
145         echo >>$c '#define PCI_COMPRESSED_IDS'
146         echo >>$c '#define PCI_IDS "pci.ids.gz"'
147         echo >>$m 'LIBZ=-lz'
148         echo >>$m 'WITH_LIBS+=$(LIBZ)'
149 else
150         echo >>$c '#define PCI_IDS "pci.ids"'
151 fi
152 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
153
154 echo_n "Checking for DNS support... "
155 if [ "$DNS" = yes -o "$DNS" = no ] ; then
156         echo "$DNS (set manually)"
157 else
158         if [ -f /usr/include/resolv.h ] ; then
159                 DNS=yes
160         else
161                 DNS=no
162         fi
163         echo "$DNS (auto-detected)"
164 fi
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"
169 fi
170
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='
176 else
177         echo >>$m 'PCILIB=$(LIBNAME).so.$(VERSION)'
178         # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
179         echo >>$m 'LDLIBS='
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)'
184         fi
185 fi
186 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
187
188 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
189 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m