-noinst_SCRIPTS = test_kernel test_ust
-EXTRA_DIST = test_kernel test_ust
+AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(srcdir)
+AM_LDFLAGS =
+
+if NO_SHARED
+
+CLEANFILES = librelayd_state.so librelayd_state.so.debug
+EXTRA_DIST = test_kernel test_ust common_test relayd_state_testpoint.c
+
+else
+# The testpoint library must be built as .so to be able to LD_PRELOAD it.
+FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \
+ -rpath $(abs_builddir)
+
+librelayd_state_la_SOURCES = relayd_state_testpoint.c
+librelayd_state_la_LIBADD = $(top_builddir)/src/common/libcommon.la $(DL_LIBS)
+librelayd_state_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS)
+noinst_LTLIBRARIES = librelayd_state.la
+
+noinst_SCRIPTS = test_kernel test_ust common_test
+EXTRA_DIST = test_kernel test_ust common_test
all-local:
@if [ x"$(srcdir)" != x"$(builddir)" ]; then \
rm -f $(builddir)/$$script; \
done; \
fi
+endif