diff --git a/c/Makefile.am b/c/Makefile.am
index 4e690d7932e7b1d5ff883ee5c3a0817f461eac63..983267969449f7d72687404b5d743fe717ff1620 100644
--- a/c/Makefile.am
+++ b/c/Makefile.am
@@ -1,7 +1,10 @@
 lib_LTLIBRARIES = libopendht-c.la
 noinst_HEADERS = opendht_c.h
 
-AM_CPPFLAGS = -isystem @top_srcdir@/include @JsonCpp_CFLAGS@ @MsgPack_CFLAGS@
+AM_CPPFLAGS = -DOPENDHT_C_BUILD -isystem @top_srcdir@/include @JsonCpp_CFLAGS@ @MsgPack_CFLAGS@
+if OPENDHT_SHARED
+AM_CPPFLAGS += -Dopendht_c_EXPORTS
+endif
 
 libopendht_c_la_LIBADD = $(LIBOBJS) ../src/.libs/libopendht.la
 
diff --git a/configure.ac b/configure.ac
index efabc9d75fefb3c0f76c4cfa253bcdcaa59e6cb7..ee9f1805206b0a188db472d97f116e0739488609 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,6 +21,12 @@ AS_IF([test "x$enable_debug" = "xyes"],
       [CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -O0 -pedantic-errors"],
       [CXXFLAGS="${CXXFLAGS} -O3 -pedantic-errors -fvisibility=hidden"])
 
+CPPFLAGS+=" -DOPENDHT_BUILD"
+AM_CONDITIONAL([OPENDHT_SHARED], [test "x$enable_shared" != xno])
+AM_COND_IF(OPENDHT_SHARED, [
+  CPPFLAGS+=" -Dopendht_EXPORTS"
+])
+
 AM_PROG_AR
 LT_INIT()
 LT_LANG(C++)
@@ -30,10 +36,8 @@ AX_CXX_COMPILE_STDCXX(17,[noext],[mandatory])
 
 dnl Check for logs
 AC_ARG_ENABLE([logs], [AS_HELP_STRING([--disable-logs], [Disable DHT logs])])
-AS_IF([test "x$enable_logs" != "xno"], [
-	AC_DEFINE([OPENDHT_LOG], [true], [Define if DHT logs are enabled])
-], [
-	AC_DEFINE([OPENDHT_LOG], [false], [Define if DHT logs are enabled])
+AS_IF([test "x$enable_logs" != "xno"], [], [
+	AC_DEFINE([OPENDHT_LOG], [false], [Define if DHT logs are disabled])
 ])
 
 dnl Check for C binding
diff --git a/src/Makefile.am b/src/Makefile.am
index 2820655ba7f8376460d4619b71e7c471e2746a2b..acaccf79620963c78278408aeca154b1c830cf2b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -84,6 +84,3 @@ if ENABLE_INDEXATION
 libopendht_la_SOURCES += indexation/pht.cpp
 nobase_include_HEADERS += ../include/opendht/indexation/pht.h
 endif
-
-clean-local:
-	rm -rf libargon2.la