add SMACK manifest file
[framework/system/pciutils.git] / Makefile
1 # Makefile for The PCI Utilities
2 # (c) 1998--2008 Martin Mares <mj@ucw.cz>
3
4 OPT=-O2 -g
5 CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes
6
7 VERSION=3.0.0
8 DATE=2008-04-10
9
10 # Host OS and release (override if you are cross-compiling)
11 HOST=
12 RELEASE=
13
14 # Support for compressed pci.ids (yes/no, default: detect)
15 ZLIB=
16
17 # Support for resolving ID's by DNS (yes/no, default: detect)
18 DNS=
19
20 # Build libpci as a shared library (yes/no; or local for testing; requires GCC)
21 SHARED=no
22
23 # ABI version suffix in the name of the shared library
24 ABI_VERSION=.3
25
26 # Installation directories
27 PREFIX=/usr/local
28 SBINDIR=$(PREFIX)/sbin
29 SHAREDIR=$(PREFIX)/share
30 IDSDIR=$(SHAREDIR)
31 MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
32 INCDIR=$(PREFIX)/include
33 LIBDIR=$(PREFIX)/lib
34 PKGCFDIR=$(LIBDIR)/pkgconfig
35
36 # Commands
37 INSTALL=install
38 DIRINSTALL=install -d
39 STRIP=-s
40 AR=ar
41 RANLIB=ranlib
42
43 # Base name of the library (overriden on NetBSD, which has its own libpci)
44 LIBNAME=libpci
45
46 -include lib/config.mk
47
48 PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h
49 PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
50
51 export
52
53 pcimod-$(PCI_OS_LINUX) := pcimodules
54 pcimod8-$(PCI_OS_LINUX) := pcimodules.8
55 all: lib/$(PCILIB) lspci lspci-udeb setpci example lspci.8 setpci.8 pcilib.7 update-pciids update-pciids.8 $(PCI_IDS) $(pcimod-1) $(pcimod8-1)
56
57 lib/$(PCILIB): $(PCIINC) force
58         $(MAKE) -C lib all
59
60 force:
61
62 lib/config.h lib/config.mk:
63         cd lib && ./configure
64
65 lspci: lspci.o common.o lib/$(PCILIB)
66 lspci-udeb: lspci.o common.o lib/libpci.a
67 setpci: setpci.o common.o lib/$(PCILIB)
68 pcimodules: pcimodules.o common.o lib/$(PCILIB)
69
70 lspci.o: lspci.c pciutils.h $(PCIINC)
71 setpci.o: setpci.c pciutils.h $(PCIINC)
72 pcimodules.o: pcimodules.c pciutils.h $(PCIINC)
73 common.o: common.c pciutils.h $(PCIINC)
74
75 update-pciids: update-pciids.sh
76         sed <$< >$@ "s@^FILE=.*@FILE=$(IDSDIR)/pci.ids@"
77         chmod +x $@
78
79 # The example of use of libpci
80 example: example.o lib/$(PCILIB)
81 example.o: example.c $(PCIINC)
82
83 %: %.o
84         $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
85
86 lspci-udeb: lspci.o
87         $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -lz -lresolv -o $@
88
89 %.8 %.7: %.man
90         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)#"
91
92 clean:
93         rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
94         rm -f update-pciids lspci setpci example lib/config.* *.[78] pci.ids.* lib/*.pc lib/*.so lib/*.so.*
95         rm -f pcimodules
96         rm -rf maint/dist
97
98 distclean: clean
99
100 install: all
101 # -c is ignored on Linux, but required on FreeBSD
102         $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7
103         $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(pcimod-1) $(DESTDIR)$(SBINDIR)
104         #$(INSTALL) -c -m 755 $(STRIP) lspci-udeb $(DESTDIR)-udeb$(SBINDIR)/lspci
105         $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
106         $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
107         $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(pcimod8-1) $(DESTDIR)$(MANDIR)/man8
108         $(INSTALL) -c -m 644 pcilib.7 $(DESTDIR)$(MANDIR)/man7
109 ifeq ($(SHARED),yes)
110         $(DIRINSTALL) -m 755 $(DESTDIR)$(LIBDIR)
111         $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
112         ln -sf $(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
113 endif
114
115 install-lib: $(PCIINC_INS) lib/$(PCILIB) lib/$(PCILIBPC)
116         $(DIRINSTALL) -m 755 $(DESTDIR)$(INCDIR)/pci $(DESTDIR)$(LIBDIR) $(DESTDIR)$(PKGCFDIR)
117         $(INSTALL) -c -m 644 $(PCIINC_INS) $(DESTDIR)$(INCDIR)/pci
118         $(INSTALL) -c -m 644 lib/$(PCILIB) $(DESTDIR)$(LIBDIR)
119         $(INSTALL) -c -m 644 lib/$(PCILIBPC) $(DESTDIR)$(PKGCFDIR)
120 ifeq ($(SHARED),yes)
121         ln -sf $(LIBNAME).so$(ABI_VERSION) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so
122 endif
123
124 uninstall: all
125         rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
126         rm -f $(DESTDIR)-udeb$(SBINDIR)/lspci
127         rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
128         rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
129         rm -f $(DESTDIR)$(SBINDIR)/pcimodules $(DESTDIR)$(MANDIR)/man8/pcimodules.8
130         rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
131 ifeq ($(SHARED),yes)
132         rm -f $(DESTDIR)$(LIBDIR)/$(PCILIB) $(DESTDIR)$(LIBDIR)/$(LIBNAME).so$(ABI_VERSION)
133 endif
134
135 pci.ids.gz: pci.ids
136         gzip -9 <$< >$@
137
138 .PHONY: all clean distclean install install-lib uninstall force