3rdparty: Add additional build facilities for 3rd-party code
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b9d2d81..57b4b3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -181,7 +181,7 @@
     set(LIB_INSTALL_DIR lib)
 endif()
 
-include_directories(include/ 3rdparty/everest/include/ 3rdparty/everest/include/everest/ 3rdparty/everest/include/everest/kremlin/ 3rdparty/everest/include/everest/kremlib/)
+include_directories(include/)
 
 if(ENABLE_ZLIB_SUPPORT)
     find_package(ZLIB)
@@ -192,6 +192,10 @@
 endif(ENABLE_ZLIB_SUPPORT)
 
 add_subdirectory(3rdparty)
+include_directories(${thirdparty_inc})
+list(APPEND libs ${thirdparty_lib})
+add_definitions(${thirdparty_def})
+
 add_subdirectory(library)
 add_subdirectory(include)
 add_subdirectory(crypto/library)
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index ef33fe8..c2f2bd4 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -3,9 +3,8 @@
 if(INSTALL_MBEDTLS_HEADERS)
 
     file(GLOB headers "mbedtls/*.h")
-    file(GLOB headers_everest "../3rdparty/everest/include/*.h")
 
-    install(FILES ${headers} ${headers_everest}
+    install(FILES ${headers}
         DESTINATION include/mbedtls
         PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index afabdf7..2afbfd7 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -64,9 +64,10 @@
     version.c
     version_features.c
     xtea.c
-    ${src_thirdparty}
 )
 
+list(APPEND src_crypto ${thirdparty_src})
+
 set(src_x509
     certs.c
     pkcs11.c
diff --git a/programs/Makefile b/programs/Makefile
index f094877..0e4f7d6 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -18,7 +18,8 @@
 LOCAL_CFLAGS += -I../crypto/include
 LOCAL_CXXFLAGS += -I../crypto/include
 
-LOCAL_CFLAGS+=-I../3rdparty/everest/include
+include ../3rdparty/Makefile.inc
+LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES)
 
 ifndef SHARED
 DEP=../crypto/library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
diff --git a/tests/Makefile b/tests/Makefile
index d1c265e..3857778 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -16,7 +16,8 @@
 LOCAL_CFLAGS += -I../crypto/include
 CRYPTO := ../crypto/library/
 
-LOCAL_CFLAGS+=-I../3rdparty/everest/include
+include ../3rdparty/Makefile.inc
+LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES)
 
 # Enable definition of various functions used throughout the testsuite
 # (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless