-cflags = -I$(incdir) \
- $(shell pkg-config --cflags --libs openssl libmicrohttpd json-c libsystemd uuid) \
- -ldl -lrt -lpthread
-
-afb_lib_src = $(shell ls $(srcdir)/*.c | egrep -v '/afs-|/main-|-so-v1|-so-vdyn|-fake|-api-dbus|-api-v1' )
-afb_clib_src = $(shell ls $(srcdir)/*.c | egrep -v '/afs-|/main-|-so-v1|-so-vdyn|-fake|-api-dbus|-api-v1|afb-supervision' )
-
-afb_daemon_srcs = $(srcdir)/main-afb-daemon.c $(afb_lib_src)
-afb_daemon_defs = '-DAFB_VERSION="cov"' -DAGL_DEVEL -DWITH_MONITORING_OPTION '-DBINDING_INSTALL_DIR="fake"'
-
-afb_client_srcs = $(srcdir)/main-afb-client-demo.c $(afb_clib_src)
-afb_client_defs = '-DAFB_VERSION="cov"' '-DBINDING_INSTALL_DIR="fake"'
-
+deps = openssl libmicrohttpd json-c libsystemd uuid
+
+ccflags = \
+ -g \
+ -I$(incdir) \
+ $(shell pkg-config --cflags $(deps))
+
+ldflags = -ldl -lrt -lpthread \
+ $(shell pkg-config --libs $(deps))
+
+cflags = $(ccflags) $(ldflags)
+
+defs = -DAGL_DEVEL=1 \
+ -DWITH_MONITORING_OPTION \
+ -DAFB_VERSION=\"cov\" \
+ -DUSE_SIG_MONITOR_DUMPSTACK=1 \
+ -DUSE_SIG_MONITOR_SIGNALS=1 \
+ -DUSE_SIG_MONITOR_FOR_CALL=1 \
+ -DUSE_SIG_MONITOR_TIMERS=1 \
+ -DWITH_AFB_HOOK=1 \
+ -DWITH_AFB_TRACE=1 \
+ -DWITH_LEGACY_BINDING_V1=0 \
+ -DWITH_LEGACY_BINDING_V2=1 \
+ -DWITH_LEGACY_BINDING_VDYN=0 \
+ -DWITH_DBUS_TRANSPARENCY=0 \
+ -DWITH_SUPERVISION=0 \
+ -DWITH_DYNAMIC_BINDING=1 \
+ -DBINDING_INSTALL_DIR=\"$(shell pwd)/fake\"
+
+afb_lib_src = $(shell ls $(srcdir)/*.c | egrep -v '/afs-|/main-|/fdev-epoll.c|/afb-ws-client.c' )
+afb_lib_obj = $(patsubst $(srcdir)/%.c,%.o,$(afb_lib_src))
+afb_lib = afb-lib.a
+afb_lib_defs = $(defs)
+
+afb_daemon_srcs = $(srcdir)/main-afb-daemon.c $(afb_lib_obj)
+afb_daemon_defs = $(afb_lib_defs)
+
+afb_client_srcs = $(srcdir)/main-afb-client-demo.c $(srcdir)/afb-ws-client.c $(afb_lib_src)
+afb_client_defs = $(defs)
+
+tst_defs = $(defs)
+tst_flags = $(cflags) \
+ -I$(srcdir) \
+ $(shell pkg-config --cflags --libs check)
+
+tst_defs = '-DAFB_VERSION="cov"' '-DBINDING_INSTALL_DIR="fake"'
+tst_flags = $(cflags) \
+ -I$(srcdir) \
+ $(shell pkg-config --cflags --libs check)
+
+hello2_src = $(samdir)/hello2.c