]>
Commit | Line | Data |
---|---|---|
4284af58 | 1 | # Makefile for The PCI Utilities |
bb8c9863 | 2 | # (c) 1998--2008 Martin Mares <mj@ucw.cz> |
98e39e09 | 3 | |
54e13765 | 4 | OPT=-O2 |
3e9c7a18 | 5 | CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes |
727ce158 | 6 | |
7dbbb6b1 MM |
7 | VERSION=3.1.0-alpha1 |
8 | DATE=2008-11-11 | |
168b4f46 | 9 | |
3b75e19a MM |
10 | # Host OS and release (override if you are cross-compiling) |
11 | HOST= | |
12 | RELEASE= | |
f683f54a | 13 | CROSS_COMPILE= |
3b75e19a MM |
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 | ||
d7ea742c MM |
21 | # Build libpci as a shared library (yes/no; or local for testing; requires GCC) |
22 | SHARED=no | |
23 | ||
24 | # ABI version suffix in the name of the shared library | |
cec9f7e7 | 25 | ABI_VERSION=.3 |
d7ea742c | 26 | |
3b75e19a | 27 | # Installation directories |
c83293eb MM |
28 | PREFIX=/usr/local |
29 | SBINDIR=$(PREFIX)/sbin | |
30 | SHAREDIR=$(PREFIX)/share | |
54e13765 | 31 | IDSDIR=$(SHAREDIR) |
b0f1a03b | 32 | MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi) |
5670e427 | 33 | INCDIR=$(PREFIX)/include |
3052f51e | 34 | LIBDIR=$(PREFIX)/lib |
5670e427 | 35 | PKGCFDIR=$(LIBDIR)/pkgconfig |
3b75e19a MM |
36 | |
37 | # Commands | |
14d6c0a3 MM |
38 | INSTALL=install |
39 | DIRINSTALL=install -d | |
3b75e19a | 40 | STRIP=-s |
f683f54a ABL |
41 | CC=$(CROSS_COMPILE)gcc |
42 | AR=$(CROSS_COMPILE)ar | |
43 | RANLIB=$(CROSS_COMPILE)ranlib | |
3b75e19a | 44 | |
d7ea742c MM |
45 | # Base name of the library (overriden on NetBSD, which has its own libpci) |
46 | LIBNAME=libpci | |
c83293eb | 47 | |
cc062b4a | 48 | -include lib/config.mk |
f6c86928 | 49 | |
d7ea742c MM |
50 | PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h |
51 | PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h | |
52 | ||
727ce158 MM |
53 | export |
54 | ||
bc46bc39 | 55 | all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS) |
727ce158 | 56 | |
d7ea742c | 57 | lib/$(PCILIB): $(PCIINC) force |
727ce158 | 58 | $(MAKE) -C lib all |
e4842ff3 | 59 | |
11f7b31b MM |
60 | force: |
61 | ||
cc062b4a | 62 | lib/config.h lib/config.mk: |
3b75e19a | 63 | cd lib && ./configure |
98e39e09 | 64 | |
d7ea742c MM |
65 | lspci: lspci.o common.o lib/$(PCILIB) |
66 | setpci: setpci.o common.o lib/$(PCILIB) | |
727ce158 | 67 | |
4afd29d3 MM |
68 | lspci.o: lspci.c pciutils.h $(PCIINC) |
69 | setpci.o: setpci.c pciutils.h $(PCIINC) | |
70 | common.o: common.c pciutils.h $(PCIINC) | |
727ce158 | 71 | |
1b95f396 | 72 | update-pciids: update-pciids.sh |
cc062b4a MM |
73 | sed <$< >$@ "s@^DEST=.*@DEST=$(IDSDIR)/$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@" |
74 | chmod +x $@ | |
1b95f396 | 75 | |
bc46bc39 MM |
76 | # The example of use of libpci |
77 | example: example.o lib/$(PCILIB) | |
78 | example.o: example.c $(PCIINC) | |
79 | ||
6cdb9d93 MM |
80 | %: %.o |
81 | $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@ | |
82 | ||
f2bf13dc | 83 | %.8 %.7: %.man |
54e13765 | 84 | 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)#" |
98e39e09 MM |
85 | |
86 | clean: | |
c7f5314d | 87 | rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"` |
bc46bc39 | 88 | rm -f update-pciids lspci setpci example lib/config.* *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.* |
ab12277e MM |
89 | rm -rf maint/dist |
90 | ||
91 | distclean: clean | |
f17b962b MM |
92 | |
93 | install: all | |
ee551b73 | 94 | # -c is ignored on Linux, but required on FreeBSD |
cd73a9d0 | 95 | $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7 |
27fa4e65 | 96 | $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR) |
f4ddb8d3 | 97 | $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR) |
cc062b4a | 98 | $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR) |
f4ddb8d3 | 99 | $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8 |
f2bf13dc | 100 | $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7 |
d7ea742c MM |
101 | ifeq ($(SHARED),yes) |
102 | $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR) | |
103 | $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR) | |
349c0fe9 | 104 | ln -sf $(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION) |
d7ea742c | 105 | endif |
f17b962b | 106 | |
d7ea742c | 107 | install-lib: $(PCIINC_INS) lib/$(PCILIB) lib/$(PCILIBPC) |
5670e427 MM |
108 | $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(LIBDIR) $(DESTDIR)$(PKGCFDIR) |
109 | $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci | |
d7ea742c MM |
110 | $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR) |
111 | $(INSTALL) -c -m 644 lib/$(PCILIBPC) $(DESTDIR)$(PKGCFDIR) | |
349c0fe9 MM |
112 | ifeq ($(SHARED),yes) |
113 | ln -sf $(LIBNAME).so$(ABI_VERSION) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so | |
114 | endif | |
3052f51e | 115 | |
82ce97c9 | 116 | uninstall: all |
f4ddb8d3 | 117 | rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids |
cc062b4a | 118 | rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS) |
f4ddb8d3 | 119 | rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8 |
c2381ab5 | 120 | rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7 |
349c0fe9 MM |
121 | ifeq ($(SHARED),yes) |
122 | rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION) | |
123 | endif | |
82ce97c9 | 124 | |
cc062b4a MM |
125 | pci.ids.gz: pci.ids |
126 | gzip -9 <$< >$@ | |
a33d0eb7 | 127 | |
3b75e19a | 128 | .PHONY: all clean distclean install install-lib uninstall force |