]> mj.ucw.cz Git - pciutils.git/blob - Makefile
65436dbd3eb9e6f3338657ce747adc6ca8e627c4
[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=lib/libpci.a
18 PCIINC=lib/config.h lib/header.h lib/pci.h
19
20 ifeq ($(shell uname),NetBSD)
21 PCILIB=libpciutils.a
22 LDFLAGS+=-lpci
23 else
24 ifeq ($(shell uname),AIX)
25 CFLAGS=-g
26 INSTALL=installbsd
27 DIRINSTALL=mkdir -p
28 endif
29 endif
30
31 export
32
33 all: $(PCILIB) lspci setpci lspci.8 setpci.8 update-pciids update-pciids.8 pci.ids
34
35 $(PCILIB): $(PCIINC)
36         $(MAKE) -C lib all
37
38 lib/config.h:
39         cd lib && ./configure $(SHAREDIR) $(VERSION)
40
41 lspci: lspci.o common.o $(PCILIB)
42 setpci: setpci.o common.o $(PCILIB)
43
44 lspci.o: lspci.c pciutils.h $(PCIINC)
45 setpci.o: setpci.c pciutils.h $(PCIINC)
46 common.o: common.c pciutils.h $(PCIINC)
47
48 update-pciids: update-pciids.sh
49         sed <$< >$@ "s@^DEST=.*@DEST=$(SHAREDIR)/pci.ids@"
50
51 %.8: %.man
52         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)#"
53
54 clean:
55         rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core`
56         rm -f update-pciids lspci setpci lib/config.* *.8 pci.ids.*
57
58 install: all
59 # -c is ignored on Linux, but required on FreeBSD
60         $(DIRINSTALL) -m 755 $(SBINDIR) $(SHAREDIR) $(MANDIR)/man8
61         $(INSTALL) -c -m 755 -s lspci setpci $(SBINDIR)
62         $(INSTALL) -c -m 755 update-pciids $(SBINDIR)
63         $(INSTALL) -c -m 644 pci.ids $(SHAREDIR)
64         $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(MANDIR)/man8
65
66 uninstall: all
67         rm -f $(SBINDIR)/lspci $(SBINDIR)/setpci $(SBINDIR)/update-pciids
68         rm -f $(SHAREDIR)/pci.ids
69         rm -f $(MANDIR)/man8/lspci.8 $(MANDIR)/man8/setpci.8 $(MANDIR)/man8/update-pciids.8
70
71 get-ids:
72         cp ~/tree/pciids/pci.ids pci.ids
73
74 pci.ids:
75         @ [ -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
76
77 release:
78         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
79         sed "s/^\\(Version:[    ]*\\)[0-9.]*/\\1$(VERSION)/" <pciutils.spec >pciutils.spec.new
80         sed "s/\\(, version \\).*\./\\1$(VERSION)$(SUFFIX)./" <README >README.new
81         mv pciutils.lsm.new pciutils.lsm
82         mv pciutils.spec.new pciutils.spec
83         mv README.new README
84
85 REL=pciutils-$(VERSION)$(SUFFIX)
86 DISTTMP=/tmp/pciutils-dist
87
88 dist: clean pci.ids
89         rm -rf $(DISTTMP)
90         mkdir $(DISTTMP)
91         cp -a . $(DISTTMP)/$(REL)
92         rm -rf `find $(DISTTMP)/$(REL) -name CVS -o -name tmp -o -name maint`
93         cd $(DISTTMP) ; tar czvvf /tmp/$(REL).tar.gz $(REL)
94         rm -rf $(DISTTMP)
95
96 upload: dist
97         maint/upload $(REL)
98
99 .PHONY: all lib clean install uninstall dist man release upload get-ids