]> git.ipfire.org Git - thirdparty/pciutils.git/blame - Makefile
Released as 3.2.0.
[thirdparty/pciutils.git] / Makefile
CommitLineData
4284af58 1# Makefile for The PCI Utilities
17ec7e70 2# (c) 1998--2013 Martin Mares <mj@ucw.cz>
98e39e09 3
54e13765 4OPT=-O2
3e9c7a18 5CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes
727ce158 6
6a4909ee
MM
7VERSION=3.2.0
8DATE=2013-04-19
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
17ec7e70
MM
24# Use libkmod to resolve kernel modules on Linux (yes/no, default: detect)
25LIBKMOD=
26
d7ea742c 27# ABI version suffix in the name of the shared library
dbe1e0a6 28# (as we use proper symbol versioning, this seldom needs changing)
cec9f7e7 29ABI_VERSION=.3
d7ea742c 30
3b75e19a 31# Installation directories
c83293eb
MM
32PREFIX=/usr/local
33SBINDIR=$(PREFIX)/sbin
34SHAREDIR=$(PREFIX)/share
54e13765 35IDSDIR=$(SHAREDIR)
b0f1a03b 36MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
5670e427 37INCDIR=$(PREFIX)/include
3052f51e 38LIBDIR=$(PREFIX)/lib
5670e427 39PKGCFDIR=$(LIBDIR)/pkgconfig
3b75e19a
MM
40
41# Commands
14d6c0a3
MM
42INSTALL=install
43DIRINSTALL=install -d
3b75e19a 44STRIP=-s
f683f54a
ABL
45CC=$(CROSS_COMPILE)gcc
46AR=$(CROSS_COMPILE)ar
47RANLIB=$(CROSS_COMPILE)ranlib
3b75e19a 48
d7ea742c
MM
49# Base name of the library (overriden on NetBSD, which has its own libpci)
50LIBNAME=libpci
c83293eb 51
cc062b4a 52-include lib/config.mk
f6c86928 53
d7ea742c
MM
54PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
55PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
56
727ce158
MM
57export
58
bc46bc39 59all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS)
727ce158 60
d7ea742c 61lib/$(PCILIB): $(PCIINC) force
727ce158 62 $(MAKE) -C lib all
e4842ff3 63
11f7b31b
MM
64force:
65
cc062b4a 66lib/config.h lib/config.mk:
3b75e19a 67 cd lib && ./configure
98e39e09 68
c7a34993 69lspci: lspci.o ls-vpd.o ls-caps.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o common.o lib/$(PCILIB)
d7ea742c 70setpci: setpci.o common.o lib/$(PCILIB)
727ce158 71
c7a34993
MM
72LSPCIINC=lspci.h pciutils.h $(PCIINC)
73lspci.o: lspci.c $(LSPCIINC)
74ls-vpd.o: ls-vpd.c $(LSPCIINC)
75ls-caps.o: ls-caps.c $(LSPCIINC)
76ls-ecaps.o: ls-ecaps.c $(LSPCIINC)
77ls-kernel.o: ls-kernel.c $(LSPCIINC)
78ls-tree.o: ls-tree.c $(LSPCIINC)
79ls-map.o: ls-map.c $(LSPCIINC)
80
4afd29d3
MM
81setpci.o: setpci.c pciutils.h $(PCIINC)
82common.o: common.c pciutils.h $(PCIINC)
727ce158 83
17ec7e70
MM
84lspci: LDLIBS+=$(LIBKMOD_LIBS)
85ls-kernel.o: CFLAGS+=$(LIBKMOD_CFLAGS)
86
1b95f396 87update-pciids: update-pciids.sh
cc062b4a
MM
88 sed <$< >$@ "s@^DEST=.*@DEST=$(IDSDIR)/$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@"
89 chmod +x $@
1b95f396 90
bc46bc39
MM
91# The example of use of libpci
92example: example.o lib/$(PCILIB)
93example.o: example.c $(PCIINC)
94
6cdb9d93
MM
95%: %.o
96 $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
97
f2bf13dc 98%.8 %.7: %.man
54e13765 99 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
100
101clean:
c7f5314d 102 rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
bc46bc39 103 rm -f update-pciids lspci setpci example lib/config.* *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
ab12277e
MM
104 rm -rf maint/dist
105
106distclean: clean
f17b962b
MM
107
108install: all
ee551b73 109# -c is ignored on Linux, but required on FreeBSD
cd73a9d0 110 $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
27fa4e65 111 $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR)
f4ddb8d3 112 $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
cc062b4a 113 $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
f4ddb8d3 114 $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
f2bf13dc 115 $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
d7ea742c 116ifeq ($(SHARED),yes)
349c0fe9 117 ln -sf $(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
d7ea742c 118endif
f17b962b 119
4baec529
MM
120ifeq ($(SHARED),yes)
121install: install-pcilib
122endif
123
124install-pcilib: lib/$(PCILIB)
125 $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR)
126 $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
127
ba92e154
KP
128install-lib: $(PCIINC_INS) lib/$(PCILIBPC) install-pcilib
129 $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(PKGCFDIR)
5670e427 130 $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci
d7ea742c 131 $(INSTALL) -c -m 644 lib/$(PCILIBPC) $(DESTDIR)$(PKGCFDIR)
349c0fe9
MM
132ifeq ($(SHARED),yes)
133 ln -sf $(LIBNAME).so$(ABI_VERSION) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so
134endif
3052f51e 135
82ce97c9 136uninstall: all
f4ddb8d3 137 rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
cc062b4a 138 rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
f4ddb8d3 139 rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
c2381ab5 140 rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
349c0fe9
MM
141ifeq ($(SHARED),yes)
142 rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
143endif
82ce97c9 144
cc062b4a 145pci.ids.gz: pci.ids
7b2bf3a2 146 gzip -9n <$< >$@
a33d0eb7 147
3b75e19a 148.PHONY: all clean distclean install install-lib uninstall force