]> git.ipfire.org Git - thirdparty/pciutils.git/blame - Makefile
setpci: Better tracing and reporting of runtime errors.
[thirdparty/pciutils.git] / Makefile
CommitLineData
4284af58 1# Makefile for The PCI Utilities
bb8c9863 2# (c) 1998--2008 Martin Mares <mj@ucw.cz>
98e39e09 3
54e13765 4OPT=-O2
3e9c7a18 5CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes
727ce158 6
b282435d
MM
7VERSION=3.0.3
8DATE=2008-11-09
168b4f46 9
3b75e19a
MM
10# Host OS and release (override if you are cross-compiling)
11HOST=
12RELEASE=
f683f54a 13CROSS_COMPILE=
3b75e19a
MM
14
15# Support for compressed pci.ids (yes/no, default: detect)
16ZLIB=
17
18# Support for resolving ID's by DNS (yes/no, default: detect)
19DNS=
20
d7ea742c
MM
21# Build libpci as a shared library (yes/no; or local for testing; requires GCC)
22SHARED=no
23
24# ABI version suffix in the name of the shared library
cec9f7e7 25ABI_VERSION=.3
d7ea742c 26
3b75e19a 27# Installation directories
c83293eb
MM
28PREFIX=/usr/local
29SBINDIR=$(PREFIX)/sbin
30SHAREDIR=$(PREFIX)/share
54e13765 31IDSDIR=$(SHAREDIR)
b0f1a03b 32MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
5670e427 33INCDIR=$(PREFIX)/include
3052f51e 34LIBDIR=$(PREFIX)/lib
5670e427 35PKGCFDIR=$(LIBDIR)/pkgconfig
3b75e19a
MM
36
37# Commands
14d6c0a3
MM
38INSTALL=install
39DIRINSTALL=install -d
3b75e19a 40STRIP=-s
f683f54a
ABL
41CC=$(CROSS_COMPILE)gcc
42AR=$(CROSS_COMPILE)ar
43RANLIB=$(CROSS_COMPILE)ranlib
3b75e19a 44
d7ea742c
MM
45# Base name of the library (overriden on NetBSD, which has its own libpci)
46LIBNAME=libpci
c83293eb 47
cc062b4a 48-include lib/config.mk
f6c86928 49
d7ea742c
MM
50PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
51PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
52
727ce158
MM
53export
54
bc46bc39 55all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
727ce158 56
d7ea742c 57lib/$(PCILIB): $(PCIINC) force
727ce158 58 $(MAKE) -C lib all
e4842ff3 59
11f7b31b
MM
60force:
61
cc062b4a 62lib/config.h lib/config.mk:
3b75e19a 63 cd lib && ./configure
98e39e09 64
d7ea742c
MM
65lspci: lspci.o common.o lib/$(PCILIB)
66setpci: setpci.o common.o lib/$(PCILIB)
727ce158 67
4afd29d3
MM
68lspci.o: lspci.c pciutils.h $(PCIINC)
69setpci.o: setpci.c pciutils.h $(PCIINC)
70common.o: common.c pciutils.h $(PCIINC)
727ce158 71
1b95f396 72update-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
77example: example.o lib/$(PCILIB)
78example.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
86clean:
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
91distclean: clean
f17b962b
MM
92
93install: 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
101ifeq ($(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 105endif
f17b962b 106
d7ea742c 107install-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
112ifeq ($(SHARED),yes)
113 ln -sf $(LIBNAME).so$(ABI_VERSION) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so
114endif
3052f51e 115
82ce97c9 116uninstall: 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
121ifeq ($(SHARED),yes)
122 rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
123endif
82ce97c9 124
cc062b4a
MM
125pci.ids.gz: pci.ids
126 gzip -9 <$< >$@
a33d0eb7 127
3b75e19a 128.PHONY: all clean distclean install install-lib uninstall force