1 # Makefile for The PCI Utilities
2 # (c) 1998--2008 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)
14 # Support for compressed pci.ids (yes/no, default: detect)
17 # Support for resolving ID's by DNS (yes/no, default: detect)
20 # Installation directories
22 SBINDIR=$(PREFIX)/sbin
23 SHAREDIR=$(PREFIX)/share
25 MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
26 INCDIR=$(PREFIX)/include
28 PKGCFDIR=$(LIBDIR)/pkgconfig
38 PCILIBPC=lib/libpci.pc
39 PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
40 PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
42 -include lib/config.mk
46 all: $(PCILIB) lspci setpci lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
48 $(PCILIB): $(PCIINC) force
53 lib/config.h lib/config.mk:
56 lspci: lspci.o common.o $(PCILIB)
57 setpci: setpci.o common.o $(PCILIB)
59 lspci.o: lspci.c pciutils.h $(PCIINC)
60 setpci.o: setpci.c pciutils.h $(PCIINC)
61 common.o: common.c pciutils.h $(PCIINC)
63 update-pciids: update-pciids.sh
64 sed <$< >$@ "s@^DEST=.*@DEST=$(IDSDIR)/$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@"
68 $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
71 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)#"
74 rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
75 rm -f update-pciids lspci setpci lib/config.* lib/example *.[78] pci.ids.* lib/*.pc
81 # -c is ignored on Linux, but required on FreeBSD
82 $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
83 $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR)
84 $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
85 $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
86 $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
87 $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
89 install-lib: $(PCIINC_INS) $(PCILIB) $(PCILIBPC)
90 $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(LIBDIR) $(DESTDIR)$(PKGCFDIR)
91 $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci
92 $(INSTALL) -c -m 644 $(PCILIB) $(DESTDIR)$(LIBDIR)
93 $(INSTALL) -c -m 644 $(PCILIBPC) $(DESTDIR)$(PKGCFDIR)
96 rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
97 rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
98 rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
99 rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
104 .PHONY: all clean distclean install install-lib uninstall force