9ebfa9d789b2a212c244b8b1981fd60db38e693b
[src/app-framework-binder.git] / coverage / bin / Makefile
1
2 .PHONY: clean binaries
3
4 heredir = .
5 basedir = ../..
6
7 bindings = \
8         hi3.so \
9         hello.so \
10         salut.so \
11         salam.so \
12         shalom.so \
13         demat.so \
14         hellov2.so
15
16 bugs = $(foreach i,\
17         1 2 3 4 5 6 7 8 9 \
18         10 11 12 13 14 15 16 17 18 19 \
19         20 21, \
20         bugs/bug$i.so)
21
22 tests = \
23         test-apiset \
24         test-session \
25         test-wrap-json
26
27 targets = \
28         afb-daemon-nocov \
29         afb-daemon-cov \
30         afb-client \
31         $(tests) \
32         $(bindings) \
33         $(bugs)
34
35 binaries: $(targets)
36
37 clean:
38         @echo remove all binaries
39         @rm $(targets) *.gcno *.gcda *.o  2>/dev/null || true
40
41 #======================================================================================
42 # definitions
43 #======================================================================================
44
45 incdir = $(basedir)/include
46 srcdir = $(basedir)/src
47 tstdir = $(basedir)/src/tests
48 samdir = $(basedir)/bindings/samples
49
50 bindir = $(heredir)/bin
51
52 deps = openssl libmicrohttpd json-c libsystemd uuid
53
54 ccflags = \
55         -g \
56         -I$(incdir) \
57         $(shell pkg-config --cflags $(deps))
58
59 ldflags = -ldl -lrt -lpthread \
60         $(shell pkg-config --libs $(deps))
61
62 cflags = $(ccflags) $(ldflags)
63
64 defs =  -DAGL_DEVEL=1 \
65         -DWITH_MONITORING_OPTION \
66         -DAFB_VERSION=\"cov\" \
67         -DUSE_SIG_MONITOR_DUMPSTACK=1 \
68         -DUSE_SIG_MONITOR_SIGNALS=1 \
69         -DUSE_SIG_MONITOR_FOR_CALL=1 \
70         -DUSE_SIG_MONITOR_TIMERS=1 \
71         -DWITH_AFB_HOOK=1 \
72         -DWITH_AFB_TRACE=1 \
73         -DWITH_LEGACY_BINDING_V1=0 \
74         -DWITH_LEGACY_BINDING_V2=1 \
75         -DWITH_LEGACY_BINDING_VDYN=0 \
76         -DWITH_DBUS_TRANSPARENCY=0 \
77         -DWITH_SUPERVISION=0 \
78         -DWITH_DYNAMIC_BINDING=1 \
79         -DINTRINSIC_BINDING_DIR=\"$(shell pwd)/fake\"
80
81 afb_lib_src = $(shell ls $(srcdir)/*.c | egrep -v '/afs-|/main-|/fdev-epoll.c|/afb-ws-client.c' )
82 afb_lib_obj = $(patsubst $(srcdir)/%.c,%.o,$(afb_lib_src))
83 afb_lib = afb-lib.a
84 afb_lib_defs = $(defs)
85
86 afb_daemon_srcs = $(srcdir)/main-afb-daemon.c
87 afb_daemon_defs = $(afb_lib_defs)
88
89 afb_client_srcs = $(srcdir)/main-afb-client-demo.c $(srcdir)/afb-ws-client.c $(afb_lib_src)
90 afb_client_defs = $(defs)
91
92 tst_defs = $(defs)
93 tst_flags = $(cflags) \
94         -I$(srcdir) \
95         $(shell pkg-config --cflags --libs check)
96
97 tst_defs = '-DAFB_VERSION="cov"' '-DINTRINSIC_BINDING_DIR="fake"'
98 tst_flags = $(cflags) \
99         -I$(srcdir) \
100         $(shell pkg-config --cflags --libs check)
101
102 hello2_src = $(samdir)/hello2.c
103 hello3_src = $(samdir)/hello3.c
104 hi_src = $(samdir)/hi3.c
105 binding_flags = -shared -fPIC -Wl,--version-script=$(samdir)/export.map
106
107 #======================================================================================
108 # creates the targets
109 #======================================================================================
110
111 %.o: $(srcdir)/%.c
112         @echo creation of $@
113         @gcc -c -o $@ $< --coverage $(afb_lib_defs) $(ccflags)
114
115 afb-daemon-cov: $(afb_daemon_srcs) $(afb_lib_obj)
116         @echo creation of $@
117         @gcc -o $@ $(afb_daemon_srcs) $(afb_lib_obj) --coverage $(afb_daemon_defs) $(cflags)
118
119 afb-daemon-nocov: $(afb_daemon_srcs) $(afb_lib_src)
120         @echo creation of $@
121         @gcc -o $@ $(afb_daemon_srcs) $(afb_lib_src) $(afb_daemon_defs) $(cflags)
122
123 afb-client: $(afb_client_srcs)
124         @echo creation of $@
125         @gcc -o $@ $(afb_client_srcs) $(afb_client_defs) $(cflags)
126
127 #======================================================================================
128 # create test
129 #======================================================================================
130
131 test-apiset: $(tstdir)/apiset/test-apiset.c $(afb_lib_obj)
132         @echo creation of $@
133         @gcc -o $@ $(tstdir)/apiset/test-apiset.c $(afb_lib_obj) --coverage $(tst_defs) $(tst_flags)
134
135 test-session: $(tstdir)/session/test-session.c $(afb_lib_obj)
136         @echo creation of $@
137         @gcc -o $@ $(tstdir)/session/test-session.c $(afb_lib_obj) --coverage $(tst_defs) $(tst_flags)
138
139 test-wrap-json: $(tstdir)/session/test-session.c $(afb_lib_obj)
140         @echo creation of $@
141         @gcc -o $@ $(tstdir)/wrap-json/test-wrap-json.c $(afb_lib_obj) --coverage $(tst_defs) $(tst_flags)
142
143 #======================================================================================
144 # create bindings
145 #======================================================================================
146
147 hi3.so: $(hi3_src)
148         @echo creation of $@
149         @gcc -o $@ $(hi3_src) $(binding_flags) $(cflags)
150
151 hello.so: $(hello3_src)
152         @echo creation of $@
153         @gcc -o $@ $(hello3_src) '-DAPINAME="hello"' '-DPREINIT_PROVIDE_CLASS="class1 class2"' $(binding_flags) $(cflags)
154
155 salut.so: $(hello3_src)
156         @echo creation of $@
157         @gcc -o $@ $(hello3_src) '-DAPINAME="salut"' '-DPREINIT_REQUIRE_CLASS="class2"' $(binding_flags) $(cflags)
158
159 salam.so: $(hello3_src)
160         @echo creation of $@
161         @gcc -o $@ $(hello3_src) '-DAPINAME="salam"' '-DINIT_REQUIRE_API="hello salut"' $(binding_flags) $(cflags)
162
163 shalom.so: $(hello3_src)
164         @echo creation of $@
165         @gcc -o $@ $(hello3_src) '-DAPINAME="shalom"' $(binding_flags) $(cflags)
166
167 demat.so: $(hello3_src)
168         @echo creation of $@
169         @gcc -o $@ $(hello3_src) '-DAPINAME="demat"' $(binding_flags) $(cflags)
170
171 hellov2.so: $(hello2_src)
172         @echo creation of $@
173         @gcc -o $@ $(hello2_src) '-DAPINAME="hello-v2"' $(binding_flags) $(cflags)
174
175 #======================================================================================
176 # create bugs
177 #======================================================================================
178
179 bugs:
180         @echo creation of directory bugs
181         @mkdir bugs
182
183 bugs/bug%.so: bug.c bugs
184         @echo creation of $@
185         @gcc -o $@ bug.c $(binding_flags) $(cflags) -D$(patsubst bugs/bug%.so,BUG%,$@)