Use `make SHARED=yes' or `make SHARED=local' to enable this feature.
Restriction of symbol exports and symbol versioning will come soon.
*.a
*.o
+*.so
*.[0-9]
lspci
setpci
# Support for resolving ID's by DNS (yes/no, default: detect)
DNS=
+# Build libpci as a shared library (yes/no; or local for testing; requires GCC)
+SHARED=no
+
+# ABI version suffix in the name of the shared library
+ABI_VERSION=.2.2.99
+
# Installation directories
PREFIX=/usr/local
SBINDIR=$(PREFIX)/sbin
AR=ar
RANLIB=ranlib
-PCILIB=lib/libpci.a
-PCILIBPC=lib/libpci.pc
-PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
-PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
+# Base name of the library (overriden on NetBSD, which has its own libpci)
+LIBNAME=libpci
-include lib/config.mk
+PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
+PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
+
export
-all: $(PCILIB) lspci setpci lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
+all: lib/$(PCILIB) lspci setpci lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
-$(PCILIB): $(PCIINC) force
+lib/$(PCILIB): $(PCIINC) force
$(MAKE) -C lib all
force:
lib/config.h lib/config.mk:
cd lib && ./configure
-lspci: lspci.o common.o $(PCILIB)
-setpci: setpci.o common.o $(PCILIB)
+lspci: lspci.o common.o lib/$(PCILIB)
+setpci: setpci.o common.o lib/$(PCILIB)
lspci.o: lspci.c pciutils.h $(PCIINC)
setpci.o: setpci.c pciutils.h $(PCIINC)
clean:
rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
- rm -f update-pciids lspci setpci lib/config.* lib/example *.[78] pci.ids.* lib/*.pc
+ rm -f update-pciids lspci setpci lib/config.* lib/example *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
rm -rf maint/dist
distclean: clean
$(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
$(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
$(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
+ifeq ($(SHARED),yes)
+ $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR)
+ $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
+endif
-install-lib: $(PCIINC_INS) $(PCILIB) $(PCILIBPC)
+install-lib: $(PCIINC_INS) lib/$(PCILIB) lib/$(PCILIBPC)
$(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(LIBDIR) $(DESTDIR)$(PKGCFDIR)
$(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci
- $(INSTALL) -c -m 644 $(PCILIB) $(DESTDIR)$(LIBDIR)
- $(INSTALL) -c -m 644 $(PCILIBPC) $(DESTDIR)$(PKGCFDIR)
+ $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
+ $(INSTALL) -c -m 644 lib/$(PCILIBPC) $(DESTDIR)$(PKGCFDIR)
uninstall: all
rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
2. Compiling and (un)installing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Just run "make" to compile the package and then "make install" to install it.
+Please note that GNU make is needed on most platforms.
If you want to change the default installation location, please override
the PREFIX variable specified in the Makefile -- e.g., you can use
to eventually run it from. This is useful for people who are packaging
pciutils to install on other computers.
-The configure script will automatically enable support for a compressed
-pci.ids if you have zlib installed. You can override its guess by using
-"make ZLIB=no" or "make ZLIB=yes". If compressed support is enabled,
-pciutils will use pci.ids.gz in preference to pci.ids, even if the
-pci.ids file is newer. If the pci.ids.gz file is missing, it will use
-pci.ids instead.
+There are several options which can be set in the Makefile or overridden
+when running make:
+
+ ZLIB=yes/no Enable support for compressed pci.ids (requires zlib).
+ If it is enabled, pciutils will use pci.ids.gz in preference to
+ pci.ids, even if the pci.ids file is newer. If the pci.ids.gz
+ file is missing, it will use pci.ids instead. If you do not
+ specify this option, the configure script will try to guess
+ automatically based on the presence of zlib.
+
+ DNS=yes/no Enable support for querying the central database of PCI ID's
+ using DNS. Requires libresolv (which is available on most
+ systems as a part of the standard libraries) and tries to
+ autodetect its presence if the option is not specified.
+
+ SHARED=yes/ Build libpci as a shared library. Requires the GNU toolchain.
+ no/local The ABI of the shared library is intended to remain backward
+ compatible for a long time (we use symbol versioning to achieve
+ that, like GNU libc does). The value `local' includes the
+ right directory name in the binaries, so the utilities can be
+ run without installation. This is not recommended for any
+ production builds.
+
+"make install-lib" installs the library together with its header files
+for use by other programs.
When you are bored of dumping PCI registers, just use "make uninstall".
include config.mk
-OBJS=init.o access.o generic.o dump.o names.o filter.o names-hash.o names-parse.o names-net.o names-cache.o params.o
+OBJS=init access generic dump names filter names-hash names-parse names-net names-cache params
INCL=internal.h pci.h config.h header.h sysdep.h types.h
-PCILIB=libpci.a
-PCILIBPC=libpci.pc
-
ifdef PCI_HAVE_PM_LINUX_SYSFS
-OBJS += sysfs.o
+OBJS += sysfs
endif
ifdef PCI_HAVE_PM_LINUX_PROC
-OBJS += proc.o
+OBJS += proc
endif
ifdef PCI_HAVE_PM_INTEL_CONF
-OBJS += i386-ports.o
+OBJS += i386-ports
endif
ifdef PCI_HAVE_PM_DUMP
-OBJS += dump.o
+OBJS += dump
endif
ifdef PCI_HAVE_PM_FBSD_DEVICE
-OBJS += fbsd-device.o
+OBJS += fbsd-device
CFLAGS += -I/usr/src/sys
ifdef FREEBSD_SYS
CFLAGS += -I${FREEBSD_SYS}
endif
ifdef PCI_HAVE_PM_OBSD_DEVICE
-OBJS += obsd-device.o
+OBJS += obsd-device
endif
ifdef PCI_HAVE_PM_AIX_DEVICE
-OBJS += aix-device.o
+OBJS += aix-device
endif
ifdef PCI_HAVE_PM_NBSD_LIBPCI
-OBJS += nbsd-libpci.o
-PCILIB=libpciutils.a
+OBJS += nbsd-libpci
endif
all: $(PCILIB) $(PCILIBPC)
-$(PCILIB): $(OBJS)
+ifeq ($(SHARED),no)
+$(PCILIB): $(addsuffix .o,$(OBJS))
rm -f $@
$(AR) rcs $@ $^
$(RANLIB) $@
+else
+CFLAGS += -fPIC
+$(PCILIB): $(addsuffix .o,$(OBJS))
+ $(CC) -shared $(SONAME) -o $@ $^ $(LIB_LDLIBS)
+endif
-$(PCILIBPC): $(PCILIBPC).in
+$(PCILIBPC): libpci.pc.in
sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \
-e 's,@INCDIR@,$(INCDIR),' \
-e 's,@LIBDIR@,$(LIBDIR),' \
m=config.mk
echo >$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`"
echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`"
-echo >$m 'LDLIBS='
+echo >$m 'WITH_LIBS='
echo_n "Looking for access methods..."
echo_n " nbsd-libpci"
echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI'
echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"'
- echo >>$m 'PCILIB=lib/libpciutils.a'
- echo >>$m 'LDLIBS+=-lpci'
+ echo >>$m 'LIBNAME=libpciutils'
+ echo >>$m 'WITH_LIBS+=-lpci'
;;
gnu)
echo_n " i386-ports"
echo >>$c '#define PCI_COMPRESSED_IDS'
echo >>$c '#define PCI_IDS "pci.ids.gz"'
echo >>$m 'LIBZ=-lz'
- echo >>$m 'LDLIBS+=$(LIBZ)'
+ echo >>$m 'WITH_LIBS+=$(LIBZ)'
else
echo >>$c '#define PCI_IDS "pci.ids"'
fi
if [ "$DNS" = yes ] ; then
echo >>$c "#define PCI_USE_DNS"
echo >>$c "#define PCI_ID_DOMAIN \"pci-id.ucw.cz\""
- echo >>$m 'LDLIBS+=-lresolv'
+ echo >>$m 'WITH_LIBS+=-lresolv'
fi
+echo "Checking whether to build a shared library... $SHARED (set manually)"
+if [ "$SHARED" = no ] ; then
+ echo >>$m 'PCILIB=$(LIBNAME).a'
+ echo >>$m 'LDLIBS=$(WITH_LIBS)'
+ echo >>$m 'LIB_LDLIBS='
+else
+ echo >>$m 'PCILIB=$(LIBNAME)-$(VERSION).so'
+ # We link the dependencies _to_ the library, so we do not need explicit deps in .pc
+ echo >>$m 'LDLIBS='
+ echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)'
+ if [ "$SHARED" = yes ] ; then
+ echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)'
+ fi
+fi
+echo >>$m 'PCILIBPC=$(LIBNAME).pc'
+
echo >>$c "#define PCILIB_VERSION \"$VERSION\""
sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m