]> mj.ucw.cz Git - pciutils.git/blob - Makefile
4624d72b98ed0be5a1b57190c60db0777a43f893
[pciutils.git] / Makefile
1 # Makefile for The PCI Utilities
2 # (c) 1998--2008 Martin Mares <mj@ucw.cz>
3
4 OPT=-O2
5 CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes
6
7 VERSION=2.2.10-net2
8 DATE=2008-02-13
9
10 # Host OS and release (override if you are cross-compiling)
11 HOST=
12 RELEASE=
13
14 # Support for compressed pci.ids (yes/no, default: detect)
15 ZLIB=
16
17 # Support for resolving ID's by DNS (yes/no, default: detect)
18 DNS=
19
20 # Build libpci as a shared library (yes/no; or local for testing; requires GCC)
21 SHARED=no
22
23 # ABI version suffix in the name of the shared library
24 ABI_VERSION=.2.2.99
25
26 # Installation directories
27 PREFIX=/usr/local
28 SBINDIR=$(PREFIX)/sbin
29 SHAREDIR=$(PREFIX)/share
30 IDSDIR=$(SHAREDIR)
31 MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
32 INCDIR=$(PREFIX)/include
33 LIBDIR=$(PREFIX)/lib
34 PKGCFDIR=$(LIBDIR)/pkgconfig
35
36 # Commands
37 INSTALL=install
38 DIRINSTALL=install -d
39 STRIP=-s
40 AR=ar
41 RANLIB=ranlib
42
43 # Base name of the library (overriden on NetBSD, which has its own libpci)
44 LIBNAME=libpci
45
46 -include lib/config.mk
47
48 PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
49 PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
50
51 export
52
53 all: lib/$(PCILIB) lspci setpci lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
54
55 lib/$(PCILIB): $(PCIINC) force
56         $(MAKE) -C lib all
57
58 force:
59
60 lib/config.h lib/config.mk:
61         cd lib && ./configure
62
63 lspci: lspci.o common.o lib/$(PCILIB)
64 setpci: setpci.o common.o lib/$(PCILIB)
65
66 lspci.o: lspci.c pciutils.h $(PCIINC)
67 setpci.o: setpci.c pciutils.h $(PCIINC)
68 common.o: common.c pciutils.h $(PCIINC)
69
70 update-pciids: update-pciids.sh
71         sed <$< >$@ "s@^DEST=.*@DEST=$(IDSDIR)/$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@"
72         chmod +x $@
73
74 %: %.o
75         $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
76
77 %.8 %.7: %.man
78         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)#"
79
80 clean:
81         rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
82         rm -f update-pciids lspci setpci lib/config.* lib/example *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
83         rm -rf maint/dist
84
85 distclean: clean
86
87 install: all
88 # -c is ignored on Linux, but required on FreeBSD
89         $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
90         $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR)
91         $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
92         $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
93         $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
94         $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
95 ifeq ($(SHARED),yes)
96         $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR)
97         $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
98 endif
99
100 install-lib: $(PCIINC_INS) lib/$(PCILIB) lib/$(PCILIBPC)
101         $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(LIBDIR) $(DESTDIR)$(PKGCFDIR)
102         $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci
103         $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
104         $(INSTALL) -c -m 644 lib/$(PCILIBPC) $(DESTDIR)$(PKGCFDIR)
105
106 uninstall: all
107         rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
108         rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
109         rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
110         rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
111
112 pci.ids.gz: pci.ids
113         gzip -9 <$< >$@
114
115 .PHONY: all clean distclean install install-lib uninstall force