diff --git a/configure.ac b/configure.ac
index cb768a6cf239b349b9e828d706418f1dd980ba97..56032574091377576048a1c5b50f8af7e3accb27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,10 +35,14 @@ AS_IF([test "x$enable_logs" != "xno"], [
 dnl Check for indexation
 AC_ARG_ENABLE([indexation], [AS_HELP_STRING([--disable-indexation], [Disable DHT indexation])])
 AM_CONDITIONAL(ENABLE_INDEXATION, test x$enable_indexation != "xno")
-AS_IF([test "x$enable_indexation" != "xno"], [
-	AC_DEFINE([OPENDHT_INDEXATION], [1], [Define if DHT indexation is enabled])
+AM_COND_IF(ENABLE_INDEXATION, [
+	AC_DEFINE([OPENDHT_INDEXATION], [], [Define if DHT indexation is enabled])
 ])
 
+AC_ARG_ENABLE([peer-discovery], [AS_HELP_STRING([--disable-peer-discovery], [Disable peer-discovery])])
+AM_CONDITIONAL(ENABLE_PEER_DISCOVERY, test x$enable_peer_discovery != "xno")
+AM_COND_IF(ENABLE_PEER_DISCOVERY, [AC_DEFINE([OPENDHT_PEER_DISCOVERY], [], [Define if peer discovery is enabled])])
+
 dnl Check for Doxygen
 AC_ARG_ENABLE([doc], AS_HELP_STRING([--enable-doc], [Enable documentation generation (doxygen)]))
 AS_IF([test "x$enable_doc" = "xyes"], [
diff --git a/src/Makefile.am b/src/Makefile.am
index 7aaef0c6a5b3daff07315dc583275d482bdc283c..76560aa467211d733d681f9d0857fd9ce7c67d79 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,7 +27,6 @@ libopendht_la_SOURCES  = \
         dhtrunner.cpp \
         default_types.cpp \
         log.cpp \
-        peer_discovery.cpp \
         network_utils.cpp \
         thread_pool.cpp
 
@@ -56,7 +55,6 @@ nobase_include_HEADERS = \
         ../include/opendht/default_types.h \
         ../include/opendht/log.h \
         ../include/opendht/log_enable.h \
-        ../include/opendht/peer_discovery.h \
         ../include/opendht/network_utils.h \
         ../include/opendht/rng.h \
         ../include/opendht/thread_pool.h
@@ -77,6 +75,11 @@ libopendht_la_SOURCES += http.cpp
 nobase_include_HEADERS += ../include/opendht/proxy.h ../include/opendht/http.h
 endif
 
+if ENABLE_PEER_DISCOVERY
+libopendht_la_SOURCES += peer_discovery.cpp
+nobase_include_HEADERS += ../include/opendht/peer_discovery.h
+endif
+
 if ENABLE_INDEXATION
 libopendht_la_SOURCES += indexation/pht.cpp
 nobase_include_HEADERS += ../include/opendht/indexation/pht.h