]> mj.ucw.cz Git - pciutils.git/blob - Makefile
4fc7c4107947e931950362e9f0dfbc4791b6fa6e
[pciutils.git] / Makefile
1 # Makefile for Linux 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.12
8 SUFFIX=-pre1
9 DATE=2003-12-26
10
11 PREFIX=/usr/local
12 SBINDIR=$(PREFIX)/sbin
13 SHAREDIR=$(PREFIX)/share
14 MANDIR=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
15 INSTALL=install
16 DIRINSTALL=install -d
17 PCILIB=libpci.a
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: lib lspci setpci lspci.8 setpci.8 update-pciids update-pciids.8 pci.ids
33
34 lib: lib/config.h
35         $(MAKE) -C lib all
36
37 lib/config.h:
38         cd lib && ./configure $(SHAREDIR) $(VERSION)
39
40 lspci: lspci.o common.o lib/$(PCILIB)
41 setpci: setpci.o common.o lib/$(PCILIB)
42
43 lspci.o: lspci.c pciutils.h
44 setpci.o: setpci.c pciutils.h
45 common.o: common.c pciutils.h
46
47 update-pciids: update-pciids.sh
48         sed <$< >$@ "s@^DEST=.*@DEST=$(SHAREDIR)/pci.ids@"
49
50 %.8: %.man
51         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)$(SUFFIX)/;s#@SHAREDIR@#$(SHAREDIR)#"
52
53 clean:
54         rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core`
55         rm -f update-pciids lspci setpci lib/config.* *.8 pci.ids.*
56
57 install: all
58 # -c is ignored on Linux, but required on FreeBSD
59         $(DIRINSTALL) -m 755 $(SBINDIR) $(SHAREDIR) $(MANDIR)/man8
60         $(INSTALL) -c -m 755 -s lspci setpci $(SBINDIR)
61         $(INSTALL) -c -m 755 update-pciids $(SBINDIR)
62         $(INSTALL) -c -m 644 pci.ids $(SHAREDIR)
63         $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(MANDIR)/man8
64
65 uninstall: all
66         rm -f $(SBINDIR)/lspci $(SBINDIR)/setpci $(SBINDIR)/update-pciids
67         rm -f $(SHAREDIR)/pci.ids
68         rm -f $(MANDIR)/man8/lspci.8 $(MANDIR)/man8/setpci.8 $(MANDIR)/man8/update-pciids.8
69
70 get-ids:
71         cp ~/tree/pciids/pci.ids pci.ids
72
73 pci.ids:
74         @ [ -f pci.ids ] || echo >&2 "The pci.ids file is no longer part of the CVS. Please do run update-ids.sh to download them." && false
75
76 release:
77         sed "s/^\\(Version:[    ]*\\)[0-9.]*/\\1$(VERSION)/;s/^\\(Entered-date:[        ]*\\)[0-9]*/\\1`date -d$(DATE) '+%y%m%d'`/;s/\\(pciutils-\\)[0-9.]*/\\1$(VERSION)\\./" <pciutils.lsm >pciutils.lsm.new
78         sed "s/^\\(Version:[    ]*\\)[0-9.]*/\\1$(VERSION)/" <pciutils.spec >pciutils.spec.new
79         sed "s/\\(, version \\).*\./\\1$(VERSION)$(SUFFIX)./" <README >README.new
80         mv pciutils.lsm.new pciutils.lsm
81         mv pciutils.spec.new pciutils.spec
82         mv README.new README
83
84 REL=pciutils-$(VERSION)$(SUFFIX)
85 DISTTMP=/tmp/pciutils-dist
86
87 dist: clean pci.ids
88         rm -rf $(DISTTMP)
89         mkdir $(DISTTMP)
90         cp -a . $(DISTTMP)/$(REL)
91         rm -rf `find $(DISTTMP)/$(REL) -name CVS -o -name tmp -o -name maint`
92         cd $(DISTTMP) ; tar czvvf /tmp/$(REL).tar.gz $(REL)
93         rm -rf $(DISTTMP)
94
95 upload: dist
96         maint/upload $(REL)
97
98 .PHONY: all lib clean install uninstall dist man release upload get-ids