]> mj.ucw.cz Git - pciutils.git/blob - Makefile
f8a869b4c91037f93f2dc94714328c24566935aa
[pciutils.git] / Makefile
1 # Makefile for The PCI Utilities
2 # (c) 1998--2003 Martin Mares <mj@ucw.cz>
3
4 OPT=-O2 -fomit-frame-pointer
5 CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline
6
7 VERSION=2.1.99-test2
8 DATE=2003-12-27
9
10 PREFIX=/usr/local
11 SBINDIR=$(PREFIX)/sbin
12 SHAREDIR=$(PREFIX)/share
13 MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
14 INSTALL=install
15 DIRINSTALL=install -d
16 PCILIB=lib/libpci.a
17 PCIINC=lib/config.h lib/header.h lib/pci.h
18
19 ifeq ($(shell uname),NetBSD)
20 PCILIB=libpciutils.a
21 LDFLAGS+=-lpci
22 else
23 ifeq ($(shell uname),AIX)
24 CFLAGS=-g
25 INSTALL=installbsd
26 DIRINSTALL=mkdir -p
27 endif
28 endif
29
30 export
31
32 all: $(PCILIB) lspci setpci lspci.8 setpci.8 update-pciids update-pciids.8 pci.ids
33
34 $(PCILIB): $(PCIINC) force
35         $(MAKE) -C lib all
36
37 force:
38
39 lib/config.h:
40         cd lib && ./configure $(SHAREDIR) $(VERSION)
41
42 lspci: lspci.o common.o $(PCILIB)
43 setpci: setpci.o common.o $(PCILIB)
44
45 lspci.o: lspci.c pciutils.h $(PCIINC)
46 setpci.o: setpci.c pciutils.h $(PCIINC)
47 common.o: common.c pciutils.h $(PCIINC)
48
49 update-pciids: update-pciids.sh
50         sed <$< >$@ "s@^DEST=.*@DEST=$(SHAREDIR)/pci.ids@"
51
52 %.8: %.man
53         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#@SHAREDIR@#$(SHAREDIR)#"
54
55 clean:
56         rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core`
57         rm -f update-pciids lspci setpci lib/config.* *.8 pci.ids.*
58         rm -rf maint/dist
59
60 distclean: clean
61
62 install: all
63 # -c is ignored on Linux, but required on FreeBSD
64         $(DIRINSTALL) -m 755 $(SBINDIR) $(SHAREDIR) $(MANDIR)/man8
65         $(INSTALL) -c -m 755 -s lspci setpci $(SBINDIR)
66         $(INSTALL) -c -m 755 update-pciids $(SBINDIR)
67         $(INSTALL) -c -m 644 pci.ids $(SHAREDIR)
68         $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(MANDIR)/man8
69
70 uninstall: all
71         rm -f $(SBINDIR)/lspci $(SBINDIR)/setpci $(SBINDIR)/update-pciids
72         rm -f $(SHAREDIR)/pci.ids
73         rm -f $(MANDIR)/man8/lspci.8 $(MANDIR)/man8/setpci.8 $(MANDIR)/man8/update-pciids.8
74
75 get-ids:
76         cp ~/tree/pciids/pci.ids pci.ids
77
78 .PHONY: all clean distclean install uninstall get-ids force