From 5670e4275fb3f1cfb8b22bd8028b5725d5d0af41 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 20 Jun 2007 20:45:00 +0200 Subject: [PATCH] Generate and install files for pkg-config. Using `pkg-config' is a standard way to query for information on linking to other packages. This is particularly helpful for libpci where there is no simple way to know if zlib compression is built in or not. With this .pc file, linking to libpci is simple: $ cc `pkg-config --cflags --libs libpci` -o myapp myapp.c Signed-off-by: Dan Nicholson --- Makefile | 13 ++++++++----- lib/.gitignore | 1 + lib/Makefile | 11 ++++++++++- lib/configure | 3 ++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 8c4f512..378d19d 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,13 @@ SBINDIR=$(PREFIX)/sbin SHAREDIR=$(PREFIX)/share IDSDIR=$(SHAREDIR) MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi) -INCDIR=$(PREFIX)/include/pci +INCDIR=$(PREFIX)/include LIBDIR=$(PREFIX)/lib +PKGCFDIR=$(LIBDIR)/pkgconfig INSTALL=install DIRINSTALL=install -d 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 @@ -53,7 +55,7 @@ update-pciids: update-pciids.sh 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 *.8 pci.ids.* + rm -f update-pciids lspci setpci lib/config.* lib/example *.8 pci.ids.* lib/*.pc rm -rf maint/dist distclean: clean @@ -66,10 +68,11 @@ install: all $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR) $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8 -install-lib: $(PCIINC_INS) $(PCILIB) - $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR) $(DESTDIR)$(LIBDIR) - $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR) +install-lib: $(PCIINC_INS) $(PCILIB) $(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) uninstall: all rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids diff --git a/lib/.gitignore b/lib/.gitignore index efc47ae..9bed745 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,2 +1,3 @@ config.h config.mk +libpci.pc diff --git a/lib/Makefile b/lib/Makefile index ae11863..9751eb5 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -7,6 +7,7 @@ OBJS=access.o generic.o dump.o names.o filter.o 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 @@ -49,13 +50,21 @@ OBJS += nbsd-libpci.o PCILIB=libpciutils.a endif -all: $(PCILIB) +all: $(PCILIB) $(PCILIBPC) $(PCILIB): $(OBJS) rm -f $@ ar rcs $@ $^ ranlib $@ +$(PCILIBPC): $(PCILIBPC).in + sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \ + -e 's,@INCDIR@,$(INCDIR),' \ + -e 's,@LIBDIR@,$(LIBDIR),' \ + -e 's,@IDSDIR@,$(IDSDIR),' \ + -e 's,@VERSION@,$(VERSION),' \ + -e 's,@LIBZ@,$(LIBZ),' + access.o: access.c $(INCL) i386-ports.o: i386-ports.c $(INCL) i386-io-hurd.h i386-io-linux.h i386-io-sunos.h proc.o: proc.c $(INCL) pread.h diff --git a/lib/configure b/lib/configure index a031ca7..91bd03e 100755 --- a/lib/configure +++ b/lib/configure @@ -121,7 +121,8 @@ fi if [ "$zlib" = yes ] ; then echo >>$c '#define PCI_COMPRESSED_IDS' echo >>$c '#define PCI_IDS "pci.ids.gz"' - echo >>$m 'LDFLAGS+=-lz' + echo >>$m 'LIBZ=-lz' + echo >>$m 'LDFLAGS+=$(LIBZ)' else echo >>$c '#define PCI_IDS "pci.ids"' fi -- 2.39.2