forked from edrosten/libblepp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
171 lines (120 loc) · 4.11 KB
/
Makefile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#Standard boilerplate
prefix = @prefix@
exec_prefix = @exec_prefix@
mandir = @mandir@
includedir = @includedir@
datarootdir = @datarootdir@
pkgconfig = @PKGCONFIG_LIBDIR@
srcdir = @srcdir@
libdir=@libdir@
LOADLIBES = @LIBS@
vpath %.cc $(srcdir)
ifneq "$(DESTDIR)" ""
DESTDIR+=/
endif
CXX=@CXX@
LD=@CXX@
CXXFLAGS=@CXXFLAGS@ -I$(srcdir)
LDFLAGS=@LDFLAGS@
hdr = $(DESTDIR)$(includedir)/
lib = $(DESTDIR)$(libdir)/
archive=libble++.a
soname=libble++.so
soname1=libble++.so.0
soname2=libble++.so.0.5
set_soname=-Wl,-soname,libble++.so.0
LIBOBJS=src/att.o src/uuid.o src/bledevice.o src/att_pdu.o src/pretty_printers.o src/blestatemachine.o src/float.o src/logging.o src/lescan.o
PROGS=examples/lescan examples/blelogger examples/bluetooth examples/lescan_simple examples/temperature examples/read_device_name examples/write
.PHONY: all clean testclean install lib progs test doc install-so install-a install-hdr install-pkgconfig
all: lib progs test doc
lib: $(soname) $(archive)
progs:$(PROGS)
distclean: clean
rm -f Makefile config.log config.status libblepp.pc
clean: testclean
rm -f $(PROGS) *.o */*.o *.so.* *.so *.d */*.d $(soname) $(soname1) $(soname2) $(archive)
testclean:
rm -f tests/*.result tests/*.test tests/*.result_ tests/results
doc:
$(soname2): $(LIBOBJS)
$(LD) -shared -o $(soname2) $(LIBOBJS) $(LDFLAGS) $(LOADLIBES)
$(soname1): $(soname2)
rm -f $(soname1)
ln -s $(soname2) $(soname1)
$(soname): $(soname1)
rm -f $(soname)
ln -s $(soname1) $(soname)
$(archive): $(LIBOBJS)
ar crvs $(archive) $(LIBOBJS)
ranlib $(archive)
$(PROGS):|$(soname)
$(PROGS:%=%.o): | examples
$(PROGS): % : %.o | examples
$(LD) -o $@ $< -L. -lble++
install: install-so install-a install-hdr install-pkgconfig
install-a: $(archive) | $(lib)
cp $(archive) $(lib)
install-so: $(soname) $(soname1) $(soname2) | $(lib)
cp $(soname) $(soname1) $(soname2) $(lib)
install-hdr: | $(hdr)
cp -r $(srcdir)/blepp $(hdr)
install-pkgconfig:
[ "$(pkgconfig)" = "" ] || mkdir -p $(DESTDIR)$(pkgconfig)
[ "$(pkgconfig)" = "" ] || cp libblepp.pc $(DESTDIR)$(pkgconfig)/
docs:
doxygen
#Every .cc file in the tests directory is a test
TESTS=$(notdir $(basename $(wildcard $(srcdir)/tests/*.cc)))
#Get the intermediate file names from the list of tests.
TEST_RESULT=$(TESTS:%=tests/%.result)
# Don't delete the intermediate files, since these can take a
# long time to regenerate
.PRECIOUS: tests/%.result_ tests/%.test
test:tests/results
#We don't want this file hanging around on failure since we
#want the build depend on it. If we leave it behing then typing make
#twice in a row will suceed, since make will find the file and not try
#to rebuild it.
.DELETE_ON_ERROR: tests/results
tests/results:$(TEST_RESULT)
cat $(TEST_RESULT) > tests/results
@echo -------------- Test Results ---------------
@cat tests/results
@echo -------------------------------------------
@ ! grep -qv OK tests/results
#Build a test executable from a test program. On compile error,
#create an executable which declares the error.
tests/%.test: tests/%.cc $(LIBOBJS) | tests
$(CXX) $(CXXFLAGS) $^ -o $@ -I . $(LDFLAGS) $(LOADLIBES) || { echo "echo 'Compile error!' ; return 126" > $@ ; chmod +x $@; }
#Run the program and either use it's output (it should just say OK)
#or a failure message
tests/%.result_: tests/%.test | tests
$< > $@ 2>&1 ; \
a=$$? ;\
if [ $$a != 0 ]; \
then \
if [ $$a -ge 128 ] ; \
then \
echo Crash!! > $@ ; \
elif [ $$a -ne 126 ] ;\
then \
echo Failed > $@ ; \
fi;\
else\
echo OK >> $@;\
fi
tests/%.result: tests/%.result_
echo $*: `tail -1 $<` > $@
#Get the C style dependencies working. Note we need to massage the test dependencies
#to make the filenames correct
.deps:
rm -f .deps .sourcefiles
find . -name "*.cc" | xargs -IQQQ $(CXX) $(CXXFLAGS) -MM -MG QQQ | sed -e'/test/s!\(.*\)\.o:!tests/\1.test:!' > .deps
#Make compilation generate dependencies
%.o %d: %.cc
$(CXX) -o $@ -c $< $(CXXFLAGS) -MMD -MP -MF $*.d
include $(wildcard *.d */*.d)
$(LIBOBJS): | $(sort $(dir $(LIBOBJS)))
tests/results: | $(if $(wildcard tests),,tests)
examples tests $(sort $(dir $(LIBOBJS))) $(lib) $(hdr):
mkdir -p $@