]> mj.ucw.cz Git - pciutils.git/blob - lib/configure
Use LDLIBS for all libraries on which libpci depends.
[pciutils.git] / lib / configure
1 #!/bin/sh
2
3 echo_n() {
4         if [ -n "$BASH" ]
5         then
6                 echo -n "$*"
7         else
8                 echo "$*\c"
9         fi
10 }
11
12 echo_n "Configuring libpci for your system..."
13 idsdir=${1:-/usr/share}
14 version=${2:-0.0}
15 sys=`uname -s`
16 rel=`uname -r`
17 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
18 then
19         rel=`/usr/bin/oslevel`
20         proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
21         cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
22 else
23         cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/'`
24 fi
25 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
26 then
27         sys=freebsd
28 fi
29 host=${3:-$cpu-$sys}
30 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
31 host=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)$/\1--\2/' | tr '[A-Z]' '[a-z]'`
32 cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
33 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
34 rel=${4:-$rel}
35 echo " $host $rel"
36 zlib=$5
37
38 c=config.h
39 m=config.mk
40 echo >$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
41 echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
42 echo >$m 'LDLIBS='
43
44 echo_n "Looking for access methods..."
45
46 case $sys in
47         linux*)
48                 echo_n " sysfs proc"
49                 echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS'
50                 echo >>$c '#define PCI_HAVE_PM_LINUX_PROC'
51                 echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H'
52                 echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"'
53                 echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"'
54                 case $cpu in
55                                 i386)           echo_n " i386-ports"
56                                                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
57                                                 ;;
58                 esac
59                 echo >>$c '#define PCI_HAVE_64BIT_ADDRESS'
60                 echo >>$c '#define PCI_USE_DNS'
61                 echo >>$m 'LDLIBS+=-lresolv'
62                 ;;
63         sunos)
64                 case $cpu in
65                                 i386)           echo_n " i386-ports"
66                                                 echo >>$c "#define PCI_HAVE_PM_INTEL_CONF"
67                                                 ;;
68                                 *)
69                                                 echo " The PCI library does not support Solaris for this architecture: $cpu"
70                                                 exit 1
71                                                 ;;
72                 esac
73                 echo >>$c '#define PCI_HAVE_STDINT_H'
74                 echo >>$c '#define PCI_USE_DNS'
75                 echo >>$m 'LDLIBS+=-lresolv'
76                 ;;
77         freebsd)
78                 echo_n " fbsd-device"
79                 echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
80                 echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
81                 echo >>$c '#define PCI_USE_DNS'
82                 echo >>$m 'LDLIBS+=-lresolv'
83                 ;;
84         openbsd)
85                 echo_n " obsd-device"
86                 echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE'
87                 echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"'
88                 echo >>$c '#define PCI_USE_DNS'
89                 echo >>$m 'LDLIBS+=-lresolv'
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_USE_DNS'
101                 echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
102                 echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
103                 echo >>$m 'PCILIB=lib/libpciutils.a'
104                 echo >>$m 'LDLIBS+=-lpci -lresolv'
105                 ;;
106         gnu)
107                 echo_n " i386-ports"
108                 echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
109                 echo >>$c '#define PCI_USE_DNS'
110                 echo >>$m 'LDLIBS+=-lresolv'
111                 ;;
112         *)
113                 echo " Unfortunately, your OS is not supported by the PCI Library"
114                 exit 1
115                 ;;
116 esac
117
118 echo >>$c '#define PCI_HAVE_PM_DUMP'
119 echo " dump"
120
121 echo_n "Checking for zlib support... "
122 if [ "$zlib" = yes -o "$zlib" = no ] ; then
123         echo "$zlib (set manually)"
124 else
125         if [ -f /usr/include/zlib.h ] ; then
126                 zlib=yes
127         else
128                 zlib=no
129         fi
130         echo "$zlib (auto-detected)"
131 fi
132 if [ "$zlib" = yes ] ; then
133         echo >>$c '#define PCI_COMPRESSED_IDS'
134         echo >>$c '#define PCI_IDS "pci.ids.gz"'
135         echo >>$m 'LIBZ=-lz'
136         echo >>$m 'LDLIBS+=$(LIBZ)'
137 else
138         echo >>$c '#define PCI_IDS "pci.ids"'
139 fi
140 echo >>$c "#define PCI_PATH_IDS_DIR \"$idsdir\""
141 echo >>$c "#define PCI_ID_DOMAIN \"pci-id.ucw.cz\""
142
143 echo >>$c "#define PCILIB_VERSION \"$version\""
144 sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m