]> mj.ucw.cz Git - pciutils.git/blob - lib/configure
libpci: mmio-ports: Add configure note messages
[pciutils.git] / lib / configure
1 #!/bin/sh
2 # Configuration script for the PCI library
3 # (c) 1998--2013 Martin Mares <mj@ucw.cz>
4
5 LC_ALL=C
6 export LC_ALL
7
8 echo_n() {
9         printf '%s' "$*"
10 }
11
12 if [ -z "$VERSION" ] ; then
13         echo >&2 "Please run the configure script from the top-level Makefile"
14         exit 1
15 fi
16
17 echo_n "Configuring libpci for your system..."
18 if [ -z "$HOST" ] ; then
19         sys=`uname -s`
20         rel=`uname -r`
21         realsys="$sys"
22         if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
23         then
24                 rel=`/usr/bin/oslevel`
25                 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
26                 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
27         else
28                 cpu=`uname -m | sed 's/^i.86-AT386/i386/;s/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'`
29         fi
30         if [ "$sys" = "DragonFly" ]
31         then
32                 sys=freebsd
33         fi
34         if [ "$sys" = "GNU/kFreeBSD" ]
35         then
36                 sys=kfreebsd
37         fi
38         if [ "$sys" = "GNU" ]
39         then
40                 sys=gnu
41         fi
42         if [ "$sys" = "CYGWIN_NT-5.1" -o "$sys" = "CYGWIN_NT-6.0" ]
43         then
44                 sys=cygwin
45         fi
46         HOST=${3:-$cpu-$sys}
47 fi
48 [ -n "$RELEASE" ] && rel="${RELEASE}"
49 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
50 host=`echo $HOST | sed -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\3/' -e 's/^\([^-]*\)-\([^-]*\)-\([^-]*\)$/\1-\2/' -e 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
51 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
52 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
53 echo " $host $rel $cpu $sys"
54
55 c=config.h
56 m=config.mk
57 echo >$c '#define PCI_CONFIG_H'
58 echo >>$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
59 echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
60 echo >$m 'WITH_LIBS='
61
62 echo_n "Looking for access methods..."
63 LIBRESOLV=-lresolv
64 LIBEXT=so
65 EXEEXT=
66 SYSINCLUDE=/usr/include
67 LSPCIDIR=SBINDIR
68
69 case $sys in
70         linux*)
71                 echo_n " sysfs proc mem-ports"
72                 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
73                 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
74                 echo >>$c '#define PCI_HAVE_PM_MMIO_CONF'
75                 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
76                 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
77                 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
78                 echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/mem"'
79                 case $cpu in
80                                 i?86|x86_64)    echo_n " i386-ports"
81                                                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
82                                                 ;;
83                 esac
84                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
85                 LSPCIDIR=BINDIR
86                 ;;
87         sunos)
88                 case $cpu in
89                                 i?86)           echo_n " i386-ports"
90                                                 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
91                                                 ;;
92                                 *)
93                                                 echo " The PCI library does not support Solaris for this architecture: $cpu"
94                                                 exit 1
95                                                 ;;
96                 esac
97                 echo >>$c '#define PCI_HAVE_STDINT_H'
98                 ;;
99         freebsd*|kfreebsd*)
100                 echo_n " fbsd-device mem-ports"
101                 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
102                 echo >>$c '#define PCI_HAVE_PM_MMIO_CONF'
103                 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
104                 echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/mem"'
105                 if [ "$sys" != "kfreebsd" ] ; then
106                         LIBRESOLV=
107                 fi
108                 ;;
109         openbsd)
110                 echo_n " obsd-device mem-ports"
111                 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
112                 echo >>$c '#define PCI_HAVE_PM_MMIO_CONF'
113                 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
114                 echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/mem"'
115                 LIBRESOLV=
116                 ;;
117
118         darwin*)
119                 echo_n " darwin"
120                 echo >>$c '#define PCI_HAVE_PM_DARWIN_DEVICE'
121                 echo >>$c '#define PCI_HAVE_PM_MMIO_CONF'
122                 echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/mem"'
123                 echo >>$m 'WITH_LIBS+=-lresolv -framework CoreFoundation -framework IOKit'
124                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
125                 LIBRESOLV=
126                 LIBEXT=dylib
127                 SYSINCLUDE=$(xcrun --sdk macosx --show-sdk-path)/usr/include
128                 ;;
129         aix)
130                 echo_n " aix-device"
131                 echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE'
132                 echo >>$c '#define PCI_HAVE_PM_MMIO_CONF'
133                 echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/mem"'
134                 echo >>$m 'CFLAGS=-g'
135                 echo >>$m 'INSTALL=installbsd'
136                 echo >>$m 'DIRINSTALL=mkdir -p'
137                 ;;
138         netbsd)
139                 echo_n " nbsd-libpci mem-ports"
140                 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
141                 echo >>$c '#define PCI_HAVE_PM_MMIO_CONF'
142                 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
143                 echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/mem"'
144                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
145                 echo >>$m 'LIBNAME=libpciutils'
146                 echo >>$m 'WITH_LIBS+=-lpci'
147                 LIBRESOLV=
148                 ;;
149         gnu)
150                 echo_n " hurd i386-ports"
151                 echo >>$c '#define PCI_HAVE_PM_HURD_CONF'
152                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
153                 echo >>$c '#define PCI_HAVE_PM_MMIO_CONF'
154                 echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/mem"'
155                 ;;
156         djgpp)
157                 echo_n " i386-ports"
158                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
159                 EXEEXT=.exe
160                 ;;
161         cygwin|windows)
162                 echo_n " win32-cfgmgr32 win32-sysdbg"
163                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
164                 echo >>$c '#define PCI_HAVE_PM_WIN32_CFGMGR32'
165                 echo >>$c '#define PCI_HAVE_PM_WIN32_SYSDBG'
166                 # Warning: MinGW-w64 (incorrectly) provides cfgmgr32 functions
167                 # also in other import libraries, not only in libcfgmgr32.a.
168                 # So always set -lcfgmgr32 as a first library parameter which
169                 # instruct linker to prefer symbols from cfgmgr32.dll.
170                 echo >>$m 'WITH_LIBS+=-lcfgmgr32'
171                 case $cpu in i?86|x86_64)
172                 echo_n " i386-ports"
173                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
174                 if [ "$sys" = "cygwin" ] ; then
175                         # ioperm is cygwin specific library and used only by lib/i386-io-cygwin.h
176                         echo >>$m 'WITH_LIBS+=-lioperm'
177                 elif [ "$sys" = "windows" ] ; then
178                         # advapi32 is windows system library and used only by lib/i386-io-windows.h
179                         echo >>$m 'WITH_LIBS+=-ladvapi32'
180                 fi
181                 ;; esac
182                 EXEEXT=.exe
183                 LIBEXT=dll
184                 ;;
185         beos|haiku)
186                 case $cpu in
187                                 i?86|x86_64)    echo_n " i386-ports"
188                                                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
189                                                 ;;
190                 esac
191                 echo >>$c '#define PCI_HAVE_PM_MMIO_CONF'
192                 echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/misc/mem"'
193                 echo >>$c '#define PCI_HAVE_STDINT_H'
194                 ;;
195         sylixos)
196                 echo >>$c '#define PCI_PATH_SYLIXOS_DEVICE "/proc/pci"'
197                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
198                 echo >>$c '#define PCI_HAVE_PM_SYLIXOS_DEVICE'
199                 IDSDIR="/etc/pci"
200                 LIBRESOLV=
201                 ;;
202         *)
203                 echo " Unfortunately, your OS is not supported by the PCI Library"
204                 exit 1
205                 ;;
206 esac
207
208 echo >>$m "LIBEXT="$LIBEXT
209 echo >>$m "EXEEXT="$EXEEXT
210 echo >>$m "LSPCIDIR=\$($LSPCIDIR)"
211 echo >>$c '#define PCI_HAVE_PM_DUMP'
212 echo " dump"
213
214 echo_n "Checking for zlib support... "
215 if [ "$ZLIB" = yes -o "$ZLIB" = no ] ; then
216         echo "$ZLIB (set manually)"
217 else
218         if [ -f "$SYSINCLUDE/zlib.h" -o -f /usr/local/include/zlib.h ] ; then
219                 ZLIB=yes
220         else
221                 ZLIB=no
222         fi
223         echo "$ZLIB (auto-detected)"
224 fi
225 if [ "$ZLIB" = yes ] ; then
226         echo >>$c '#define PCI_COMPRESSED_IDS'
227         echo >>$c '#define PCI_IDS "pci.ids.gz"'
228         echo >>$m 'LIBZ=-lz'
229         echo >>$m 'WITH_LIBS+=$(LIBZ)'
230 else
231         echo >>$c '#define PCI_IDS "pci.ids"'
232 fi
233 echo >>$c "#define PCI_PATH_IDS_DIR \"$IDSDIR\""
234
235 echo_n "Checking for DNS support... "
236 if [ "$DNS" = yes -o "$DNS" = no ] ; then
237         echo "$DNS (set manually)"
238 else
239         if [ "$sys" != "windows" -a -f "$SYSINCLUDE/resolv.h" ] ; then
240                 DNS=yes
241         else
242                 DNS=no
243         fi
244         echo "$DNS (auto-detected)"
245 fi
246 if [ "$DNS" = yes ] ; then
247         echo >>$c "#define PCI_USE_DNS"
248         echo >>$c "#define PCI_ID_DOMAIN \"pci.id.ucw.cz\""
249         echo >>$m "WITH_LIBS+=$LIBRESOLV"
250 fi
251
252 if [ "$sys" = linux ] ; then
253         echo_n "Checking for libkmod... "
254         LIBKMOD_DETECTED=
255         if [ -z "$PKG_CONFIG" ] ; then
256                 PKG_CONFIG=pkg-config
257         fi
258         if [ "$LIBKMOD" != no ] ; then
259                 if ! command -v $PKG_CONFIG >/dev/null ; then
260                         echo_n "($PKG_CONFIG not found) "
261                 elif $PKG_CONFIG libkmod ; then
262                         LIBKMOD_DETECTED=1
263                 fi
264         fi
265         if [ "$LIBKMOD" = yes -o "$LIBKMOD" = no ] ; then
266                 echo "$LIBKMOD (set manually)"
267                 if [ "$LIBKMOD" = yes -a -z "$LIBKMOD_DETECTED" ] ; then
268                         echo "Requested use of libkmod, but it is not available. Giving up."
269                         exit 1
270                 fi
271         else
272                 if [ -n "$LIBKMOD_DETECTED" ] ; then
273                         LIBKMOD=yes
274                 else
275                         LIBKMOD=no
276                 fi
277                 echo "$LIBKMOD (auto-detected)"
278         fi
279         if [ "$LIBKMOD" = yes ] ; then
280                 echo >>$c "#define PCI_USE_LIBKMOD"
281                 echo >>$m "LIBKMOD_CFLAGS=$($PKG_CONFIG --cflags libkmod)"
282                 echo >>$m "LIBKMOD_LIBS=$($PKG_CONFIG --libs libkmod)"
283         fi
284
285         echo_n "Checking for udev hwdb support... "
286         if [ "$HWDB" = yes -o "$HWDB" = no ] ; then
287                 echo "$HWDB (set manually)"
288         else
289                 if `command -v $PKG_CONFIG >/dev/null && $PKG_CONFIG --atleast-version=196 libudev` ; then
290                         HWDB=yes
291                 else
292                         HWDB=no
293                 fi
294                 echo "$HWDB (auto-detected)"
295         fi
296         if [ "$HWDB" = yes ] ; then
297                 echo >>$c '#define PCI_HAVE_HWDB'
298                 echo >>$m 'LIBUDEV=-ludev'
299                 echo >>$m 'WITH_LIBS+=$(LIBUDEV)'
300         fi
301 fi
302
303 echo "Checking whether to build a shared library... $SHARED (set manually)"
304 if [ "$SHARED" = no ] ; then
305         echo >>$m 'PCILIB=$(LIBNAME).a'
306         echo >>$m 'LDLIBS=$(WITH_LIBS)'
307         echo >>$m 'LIB_LDLIBS='
308 else
309         if [ "$LIBEXT" = so ]; then
310                 echo >>$m 'PCILIB=$(LIBNAME).$(LIBEXT).$(VERSION)'
311         elif [ "$LIBEXT" = dll ]; then
312                 echo >>$m 'PCILIB=$(LIBNAME)$(ABI_VERSION).$(LIBEXT)'
313         else
314                 echo >>$m 'PCILIB=$(LIBNAME).$(VERSION).$(LIBEXT)'
315         fi
316         # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
317         echo >>$m 'LDLIBS='
318         echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
319         echo >>$c '#define PCI_SHARED_LIB'
320         if [ "$LIBEXT" = so ]; then
321                 echo >>$m 'PCILIB_LDFLAGS+=-Wl,-soname,$(LIBNAME).$(LIBEXT).$(ABI_VERSION)'
322                 echo >>$m 'PCILIB_LDFLAGS+=-Wl,--version-script=libpci.ver'
323         elif [ "$LIBEXT" = dylib ]; then
324                 echo >>$m 'PCILIB_LDFLAGS+=-Wl,-install_name,$(LIBDIR)/$(PCILIB)'
325         elif [ "$LIBEXT" = dll ]; then
326                 echo >>$m 'PCIIMPDEF=$(LIBNAME)$(ABI_VERSION).def'
327                 # GCC's -fvisibility=hidden is broken for Windows targets, use -Wl,--exclude-all-symbols instead (supported since GNU LD 2.21)
328                 echo >>$m 'PCILIB_LDFLAGS+=-Wl,--exclude-all-symbols'
329         fi
330 fi
331 echo >>$m 'PCILIBPC=$(LIBNAME).pc'
332
333 if [ "$SHARED" != no ] && [ "$LIBEXT" = dll ]; then
334         echo >>$m 'PCIIMPLIB=$(PCILIB).a'
335 else
336         echo >>$m 'PCIIMPLIB=$(PCILIB)'
337 fi
338
339 echo >>$c "#define PCILIB_VERSION \"$VERSION\""
340 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m