1 # Makefile for The PCI Utilities
2 # (c) 1998--2013 Martin Mares <mj@ucw.cz>
5 CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes
10 # Host OS and release (override if you are cross-compiling)
15 # Support for compressed pci.ids (yes/no, default: detect)
18 # Support for resolving ID's by DNS (yes/no, default: detect)
21 # Build libpci as a shared library (yes/no; or local for testing; requires GCC)
24 # Use libkmod to resolve kernel modules on Linux (yes/no, default: detect)
27 # ABI version suffix in the name of the shared library
28 # (as we use proper symbol versioning, this seldom needs changing)
31 # Installation directories
33 SBINDIR=$(PREFIX)/sbin
34 SHAREDIR=$(PREFIX)/share
36 MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
37 INCDIR=$(PREFIX)/include
39 PKGCFDIR=$(LIBDIR)/pkgconfig
45 CC=$(CROSS_COMPILE)gcc
47 RANLIB=$(CROSS_COMPILE)ranlib
49 # Base name of the library (overriden on NetBSD, which has its own libpci)
52 -include lib/config.mk
54 PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
55 PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
59 all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
61 lib/$(PCILIB): $(PCIINC) force
66 lib/config.h lib/config.mk:
69 lspci: lspci.o ls-vpd.o ls-caps.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o common.o lib/$(PCILIB)
70 setpci: setpci.o common.o lib/$(PCILIB)
72 LSPCIINC=lspci.h pciutils.h $(PCIINC)
73 lspci.o: lspci.c $(LSPCIINC)
74 ls-vpd.o: ls-vpd.c $(LSPCIINC)
75 ls-caps.o: ls-caps.c $(LSPCIINC)
76 ls-ecaps.o: ls-ecaps.c $(LSPCIINC)
77 ls-kernel.o: ls-kernel.c $(LSPCIINC)
78 ls-tree.o: ls-tree.c $(LSPCIINC)
79 ls-map.o: ls-map.c $(LSPCIINC)
81 setpci.o: setpci.c pciutils.h $(PCIINC)
82 common.o: common.c pciutils.h $(PCIINC)
84 lspci: LDLIBS+=$(LIBKMOD_LIBS)
85 ls-kernel.o: CFLAGS+=$(LIBKMOD_CFLAGS)
87 update-pciids: update-pciids.sh
88 sed <$< >$@ "s@^DEST=.*@DEST=$(IDSDIR)/$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@"
91 # The example of use of libpci
92 example: example.o lib/$(PCILIB)
93 example.o: example.c $(PCIINC)
96 $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
99 M=`echo $(DATE) | sed 's/-01-/-January-/;s/-02-/-February-/;s/-03-/-March-/;s/-04-/-April-/;s/-05-/-May-/;s/-06-/-June-/;s/-07-/-July-/;s/-08-/-August-/;s/-09-/-September-/;s/-10-/-October-/;s/-11-/-November-/;s/-12-/-December-/;s/\(.*\)-\(.*\)-\(.*\)/\3 \2 \1/'` ; sed <$< >$@ "s/@TODAY@/$$M/;s/@VERSION@/pciutils-$(VERSION)/;s#@IDSDIR@#$(IDSDIR)#"
102 rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
103 rm -f update-pciids lspci setpci example lib/config.* *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
109 # -c is ignored on Linux, but required on FreeBSD
110 $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
111 $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR)
112 $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
113 $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
114 $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
115 $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
117 ln -sf $(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
121 install: install-pcilib
124 install-pcilib: lib/$(PCILIB)
125 $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR)
126 $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
128 install-lib: $(PCIINC_INS) lib/$(PCILIBPC) install-pcilib
129 $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(PKGCFDIR)
130 $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci
131 $(INSTALL) -c -m 644 lib/$(PCILIBPC) $(DESTDIR)$(PKGCFDIR)
133 ln -sf $(LIBNAME).so$(ABI_VERSION) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so
137 rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
138 rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
139 rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
140 rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
142 rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
148 .PHONY: all clean distclean install install-lib uninstall force