1 |
NAME = ldetect |
2 |
LIB_MAJOR = 0.12 |
3 |
LIB_MINOR = 1 |
4 |
VERSION=$(LIB_MAJOR).$(LIB_MINOR) |
5 |
|
6 |
prefix = /usr |
7 |
bindir = $(prefix)/bin |
8 |
libdir = $(prefix)/lib |
9 |
includedir = $(prefix)/include |
10 |
|
11 |
binaries = lspcidrake |
12 |
lib_objs = common.o hid.o modalias.o pciusb.o pci.o usb.o pciclass.o usbclass.o dmi.o sysfs_attr.o sysfs_utils.o names.o |
13 |
lib_major = libldetect.so.$(LIB_MAJOR) |
14 |
libraries = libldetect.so $(lib_major) $(lib_major).$(LIB_MINOR) libldetect.a |
15 |
CFLAGS = -Wall -W -Wstrict-prototypes -Os -fPIC -fvisibility=hidden -g |
16 |
|
17 |
RPM ?= $(HOME)/rpm |
18 |
|
19 |
build: $(binaries) $(libraries) |
20 |
|
21 |
lspcidrake.static: lspcidrake.c libldetect.a |
22 |
$(CC) $(CFLAGS) -o $@ $^ -lpci -lkmod -llzma -lz -lcompat -lc |
23 |
#$(CC) $(CFLAGS) $^ libldetect.a -lkmod -lxz -lz.a -o $@ |
24 |
|
25 |
lspcidrake: lspcidrake.c libldetect.so |
26 |
|
27 |
$(lib_major).$(LIB_MINOR): $(lib_objs) |
28 |
$(CC) -shared -Wl,-z,relro -Wl,-O1,-soname,$(lib_major) -o $@ $^ -lpci -lkmod -lz |
29 |
$(lib_major): $(lib_major).$(LIB_MINOR) |
30 |
ln -sf $< $@ |
31 |
libldetect.so: $(lib_major) |
32 |
ln -sf $< $@ |
33 |
|
34 |
libldetect.a: $(lib_objs) |
35 |
ar -cru $@ $^ |
36 |
ranlib $@ |
37 |
|
38 |
pciclass.c: /usr/include/linux/pci.h /usr/include/linux/pci_ids.h |
39 |
rm -f $@ |
40 |
perl generate_pciclass.pl $^ > $@ |
41 |
chmod a-w $@ |
42 |
|
43 |
usbclass.c: /usr/share/usb.ids |
44 |
rm -f $@ |
45 |
perl generate_usbclass.pl $^ > $@ |
46 |
chmod a-w $@ |
47 |
|
48 |
common.o: common.c common.h |
49 |
pciusb.o: pciusb.c libldetect.h common.h |
50 |
pci.o: pci.c libldetect.h common.h |
51 |
usb.o: usb.c libldetect.h common.h names.h |
52 |
dmi.o: dmi.c libldetect.h common.h |
53 |
names.o: names.c names.h |
54 |
sysfs_attr.o: sysfs_attr.c sysfs.h libsysfs.h |
55 |
sysfs_utils.o: sysfs_utils.c sysfs.h libsysfs.h |
56 |
|
57 |
clean: |
58 |
rm -f *~ *.o pciclass.c usbclass.c $(binaries) $(libraries) |
59 |
|
60 |
install: build |
61 |
install -d $(bindir) $(libdir) $(includedir) |
62 |
install $(binaries) $(bindir) |
63 |
cp -a $(libraries) $(libdir) |
64 |
install libldetect.h $(includedir) |
65 |
|
66 |
dist: dis |
67 |
dis ../$(NAME)-$(VERSION).tar.bz2: tar |
68 |
|
69 |
tar: |
70 |
@if [ -e ".svn" ]; then \ |
71 |
$(MAKE) dist-svn; \ |
72 |
elif [ -e ".git" ]; then \ |
73 |
$(MAKE) dist-git; \ |
74 |
else \ |
75 |
echo "Unknown SCM (not SVN nor GIT)";\ |
76 |
exit 1; \ |
77 |
fi; |
78 |
$(info $(NAME)-$(VERSION).tar.bz2 is ready) |
79 |
|
80 |
dist-svn: |
81 |
svn export -q -rBASE . $(NAME)-$(VERSION) |
82 |
tar cfa ../$(NAME)-$(VERSION).tar.xz $(NAME)-$(VERSION) |
83 |
rm -rf $(NAME)-$(VERSION) |
84 |
|
85 |
dist-git: |
86 |
@git archive --prefix=$(NAME)-$(VERSION)/ HEAD | xz >../$(NAME)-$(VERSION).tar.xz; |
87 |
|
88 |
|
89 |
log: |
90 |
svn2cl --authors ../common/username.xml --accum |
91 |
|
92 |
run: lspcidrake |
93 |
LD_LIBRARY_PATH=$(PWD) ./lspcidrake |