]> git.ipfire.org Git - thirdparty/pciutils.git/blob - Makefile
Updated pci.ids to today's snapshot
[thirdparty/pciutils.git] / Makefile
1 # Makefile for The PCI Utilities
2 # (c) 1998--2018 Martin Mares <mj@ucw.cz>
3
4 OPT=-O2
5 CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes
6
7 VERSION=3.6.1
8 DATE=2018-07-12
9
10 # Host OS and release (override if you are cross-compiling)
11 HOST=
12 RELEASE=
13 CROSS_COMPILE=
14
15 # Support for compressed pci.ids (yes/no, default: detect)
16 ZLIB=
17
18 # Support for resolving ID's by DNS (yes/no, default: detect)
19 DNS=
20
21 # Build libpci as a shared library (yes/no; or local for testing; requires GCC)
22 SHARED=no
23
24 # Use libkmod to resolve kernel modules on Linux (yes/no, default: detect)
25 LIBKMOD=
26
27 # Use libudev to resolve device names using hwdb on Linux (yes/no, default: detect)
28 HWDB=
29
30 # ABI version suffix in the name of the shared library
31 # (as we use proper symbol versioning, this seldom needs changing)
32 ABI_VERSION=.3
33
34 # Installation directories
35 PREFIX=/usr/local
36 SBINDIR=$(PREFIX)/sbin
37 SHAREDIR=$(PREFIX)/share
38 IDSDIR=$(SHAREDIR)
39 MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
40 INCDIR=$(PREFIX)/include
41 LIBDIR=$(PREFIX)/lib
42 PKGCFDIR=$(LIBDIR)/pkgconfig
43
44 # Commands
45 INSTALL=install
46 DIRINSTALL=install -d
47 STRIP=-s
48 CC=$(CROSS_COMPILE)gcc
49 AR=$(CROSS_COMPILE)ar
50 RANLIB=$(CROSS_COMPILE)ranlib
51
52 # Base name of the library (overriden on NetBSD, which has its own libpci)
53 LIBNAME=libpci
54
55 -include lib/config.mk
56
57 PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
58 PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
59
60 export
61
62 all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
63
64 lib/$(PCILIB): $(PCIINC) force
65 $(MAKE) -C lib all
66
67 force:
68
69 lib/config.h lib/config.mk:
70 cd lib && ./configure
71
72 lspci: 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.o lib/$(PCILIB)
73 setpci: setpci.o common.o lib/$(PCILIB)
74
75 LSPCIINC=lspci.h pciutils.h $(PCIINC)
76 lspci.o: lspci.c $(LSPCIINC)
77 ls-vpd.o: ls-vpd.c $(LSPCIINC)
78 ls-caps.o: ls-caps.c $(LSPCIINC)
79 ls-ecaps.o: ls-ecaps.c $(LSPCIINC)
80 ls-kernel.o: ls-kernel.c $(LSPCIINC)
81 ls-tree.o: ls-tree.c $(LSPCIINC)
82 ls-map.o: ls-map.c $(LSPCIINC)
83
84 setpci.o: setpci.c pciutils.h $(PCIINC)
85 common.o: common.c pciutils.h $(PCIINC)
86
87 lspci: LDLIBS+=$(LIBKMOD_LIBS)
88 ls-kernel.o: CFLAGS+=$(LIBKMOD_CFLAGS)
89
90 update-pciids: update-pciids.sh
91 sed <$< >$@ "s@^DEST=.*@DEST=$(IDSDIR)/$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@"
92 chmod +x $@
93
94 # The example of use of libpci
95 example: example.o lib/$(PCILIB)
96 example.o: example.c $(PCIINC)
97
98 %: %.o
99 $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
100
101 %.8 %.7: %.man
102 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)#"
103
104 ctags:
105 rm -f tags
106 find . -name '*.[hc]' -exec ctags --append {} +
107
108 TAGS:
109 rm -f TAGS
110 find . -name '*.[hc]' -exec etags --append {} +
111
112 clean:
113 rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
114 rm -f update-pciids lspci setpci example lib/config.* *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.* tags
115 rm -rf maint/dist
116
117 distclean: clean
118
119 install: all
120 # -c is ignored on Linux, but required on FreeBSD
121 $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
122 $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR)
123 $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
124 $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
125 $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
126 $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
127 ifeq ($(SHARED),yes)
128 ifeq ($(LIBEXT),dylib)
129 ln -sf $(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME)$(ABI_VERSION).$(LIBEXT)
130 else
131 ln -sf $(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).$(LIBEXT)$(ABI_VERSION)
132 endif
133 endif
134
135 ifeq ($(SHARED),yes)
136 install: install-pcilib
137 endif
138
139 install-pcilib: lib/$(PCILIB)
140 $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR)
141 $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
142
143 install-lib: $(PCIINC_INS) lib/$(PCILIBPC) install-pcilib
144 $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(PKGCFDIR)
145 $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci
146 $(INSTALL) -c -m 644 lib/$(PCILIBPC) $(DESTDIR)$(PKGCFDIR)
147 ifeq ($(SHARED),yes)
148 ifeq ($(LIBEXT),dylib)
149 ln -sf $(LIBNAME)$(ABI_VERSION).$(LIBEXT) $(DESTDIR)$(LIBDIR)/$(LIBNAME).$(LIBEXT)
150 else
151 ln -sf $(LIBNAME).$(LIBEXT)$(ABI_VERSION) $(DESTDIR)$(LIBDIR)/$(LIBNAME).$(LIBEXT)
152 endif
153 endif
154
155 uninstall: all
156 rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
157 rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
158 rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
159 rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
160 ifeq ($(SHARED),yes)
161 rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
162 endif
163
164 pci.ids.gz: pci.ids
165 gzip -9n <$< >$@
166
167 .PHONY: all clean distclean install install-lib uninstall force tags TAGS