From 44a251de56adf280dc0a72ff7d9068a0268bc01f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Tue, 28 Jun 2022 16:23:40 -0400
Subject: [PATCH] build/autotools: don't export internal symbols

---
 c/Makefile.am   |  5 ++++-
 configure.ac    | 12 ++++++++----
 src/Makefile.am |  3 ---
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/c/Makefile.am b/c/Makefile.am
index 4e690d79..98326796 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 efabc9d7..ee9f1805 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 2820655b..acaccf79 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
-- 
GitLab