1 |
NAME = ldetect |
2 |
LIB_MAJOR = 0.11 |
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: lspcidrake.c libldetect.so |
22 |
|
23 |
$(lib_major).$(LIB_MINOR): $(lib_objs) |
24 |
$(CC) -shared -Wl,-z,relro -Wl,-O1,-soname,$(lib_major) -o $@ $^ -lpci -Wl,-Bstatic -lmodprobe -Wl,-Bdynamic -lz |
25 |
$(lib_major): $(lib_major).$(LIB_MINOR) |
26 |
ln -sf $< $@ |
27 |
libldetect.so: $(lib_major) |
28 |
ln -sf $< $@ |
29 |
|
30 |
libldetect.a: $(lib_objs) |
31 |
ar -cru $@ $^ |
32 |
ranlib $@ |
33 |
|
34 |
pciclass.c: /usr/include/linux/pci.h /usr/include/linux/pci_ids.h |
35 |
rm -f $@ |
36 |
perl generate_pciclass.pl $^ > $@ |
37 |
chmod a-w $@ |
38 |
|
39 |
usbclass.c: /usr/share/usb.ids |
40 |
rm -f $@ |
41 |
perl generate_usbclass.pl $^ > $@ |
42 |
chmod a-w $@ |
43 |
|
44 |
common.o: common.c common.h |
45 |
pciusb.o: pciusb.c libldetect.h common.h |
46 |
pci.o: pci.c libldetect.h common.h |
47 |
usb.o: usb.c libldetect.h common.h names.h |
48 |
dmi.o: dmi.c libldetect.h common.h |
49 |
names.o: names.c names.h |
50 |
sysfs_attr.o: sysfs_attr.c sysfs.h libsysfs.h |
51 |
sysfs_utils.o: sysfs_utils.c sysfs.h libsysfs.h |
52 |
|
53 |
clean: |
54 |
rm -f *~ *.o pciclass.c usbclass.c $(binaries) $(libraries) |
55 |
|
56 |
install: build |
57 |
install -d $(bindir) $(libdir) $(includedir) |
58 |
install $(binaries) $(bindir) |
59 |
cp -a $(libraries) $(libdir) |
60 |
install libldetect.h $(includedir) |
61 |
|
62 |
dist: dis |
63 |
dis ../$(NAME)-$(VERSION).tar.bz2: tar |
64 |
|
65 |
tar: |
66 |
@if [ -e ".svn" ]; then \ |
67 |
$(MAKE) dist-svn; \ |
68 |
elif [ -e ".git" ]; then \ |
69 |
$(MAKE) dist-git; \ |
70 |
else \ |
71 |
echo "Unknown SCM (not SVN nor GIT)";\ |
72 |
exit 1; \ |
73 |
fi; |
74 |
$(info $(NAME)-$(VERSION).tar.bz2 is ready) |
75 |
|
76 |
dist-svn: |
77 |
svn export -q -rBASE . $(NAME)-$(VERSION) |
78 |
tar cfj ../$(NAME)-$(VERSION).tar.bz2 $(NAME)-$(VERSION) |
79 |
rm -rf $(NAME)-$(VERSION) |
80 |
|
81 |
dist-git: |
82 |
@git archive --prefix=$(NAME)-$(VERSION)/ HEAD | bzip2 >../$(NAME)-$(VERSION).tar.bz2; |
83 |
|
84 |
|
85 |
log: |
86 |
svn2cl --authors ../common/username.xml --accum |
87 |
|
88 |
run: lspcidrake |
89 |
LD_LIBRARY_PATH=$(PWD) ./lspcidrake |