From d0130eb36208ef46bf26498ffec5b68f39e8a24c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Mon, 18 Apr 2022 22:40:58 +0200 Subject: [PATCH] Makefile: Split variable for output shared library and import linking library Use new variable $(PCIIMPLIB) for storing name of the libpci import library for linking with shared library $(PCILIB). This would allow compilation of lspci and setpci applications on systems where linking needs to be done with import library. --- Makefile | 16 +++++++++++----- lib/configure | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 70a0b5f..de37e50 100644 --- a/Makefile +++ b/Makefile @@ -64,9 +64,9 @@ PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h export -all: lib/$(PCILIB) lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lspci.8 setpci.8 pcilib.7 pci.ids.5 update-pciids update-pciids.8 $(PCI_IDS) +all: lib/$(PCIIMPLIB) lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lspci.8 setpci.8 pcilib.7 pci.ids.5 update-pciids update-pciids.8 $(PCI_IDS) -lib/$(PCILIB): $(PCIINC) force +lib/$(PCIIMPLIB): $(PCIINC) force $(MAKE) -C lib all force: @@ -80,8 +80,8 @@ PCIINC+=compat/getopt.h COMMON+=compat/getopt.o endif -lspci$(EXEEXT): lspci.o ls-vpd.o ls-caps.o ls-caps-vendor.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o $(COMMON) lib/$(PCILIB) -setpci$(EXEEXT): setpci.o $(COMMON) lib/$(PCILIB) +lspci$(EXEEXT): lspci.o ls-vpd.o ls-caps.o ls-caps-vendor.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o $(COMMON) lib/$(PCIIMPLIB) +setpci$(EXEEXT): setpci.o $(COMMON) lib/$(PCIIMPLIB) LSPCIINC=lspci.h pciutils.h $(PCIINC) lspci.o: lspci.c $(LSPCIINC) @@ -104,7 +104,7 @@ update-pciids: update-pciids.sh chmod +x $@ # The example of use of libpci -example$(EXEEXT): example.o lib/$(PCILIB) +example$(EXEEXT): example.o lib/$(PCIIMPLIB) example.o: example.c $(PCIINC) %$(EXEEXT): %.o @@ -162,6 +162,9 @@ install-lib: $(PCIINC_INS) install-pcilib $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(PKGCFDIR) $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci $(INSTALL) -c -m 644 lib/$(PCILIBPC) $(DESTDIR)$(PKGCFDIR) +ifneq ($(PCIIMPLIB),$(PCILIB)) + $(INSTALL) -c -m 644 lib/$(PCIIMPLIB) $(DESTDIR)$(LIBDIR) +endif ifeq ($(SHARED),yes) ifeq ($(LIBEXT),dylib) ln -sf $(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).$(ABI_VERSION).$(LIBEXT) @@ -185,6 +188,9 @@ endif rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) rm -f $(DESTDIR)$(PKGCFDIR)/$(PCILIBPC) rm -f $(addprefix $(DESTDIR)$(INCDIR)/pci/,$(notdir $(PCIINC_INS))) +ifneq ($(PCIIMPLIB),$(PCILIB)) + rm -f $(DESTDIR)$(LIBDIR)/$(PCIIMPLIB) +endif ifeq ($(SHARED),yes) rm -f $(DESTDIR)$(LIBDIR)/$(LIBNAME).$(LIBEXT) ifeq ($(LIBEXT),dylib) diff --git a/lib/configure b/lib/configure index f89b069..d6e2c09 100755 --- a/lib/configure +++ b/lib/configure @@ -306,5 +306,7 @@ else fi echo >>$m 'PCILIBPC=$(LIBNAME).pc' +echo >>$m 'PCIIMPLIB=$(PCILIB)' + echo >>$c "#define PCILIB_VERSION \"$VERSION\"" sed '/"/{s/^#define \([^ ]*\) "\(.*\)"$/\1=\2/;p;d;};s/^#define \(.*\)/\1=1/' <$c >>$m -- 2.39.2