-option(USE_SHARED_POLARSSL_LIBRARY "Build PolarSSL as a shared library." OFF)
+option(USE_STATIC_POLARSSL_LIBRARY "Build PolarSSL static library." ON)
+option(USE_SHARED_POLARSSL_LIBRARY "Build PolarSSL shared library." OFF)
+option(LINK_WITH_PTHREAD "Explicitly link PolarSSL library to pthread." OFF)
set(src
aes.c
+ aesni.c
arc4.c
asn1parse.c
asn1write.c
bignum.c
blowfish.c
camellia.c
+ ccm.c
certs.c
cipher.c
cipher_wrap.c
des.c
dhm.c
ecp.c
+ ecp_curves.c
ecdh.c
ecdsa.c
entropy.c
error.c
gcm.c
havege.c
+ hmac_drbg.c
md.c
md_wrap.c
md2.c
md4.c
md5.c
- memory.c
memory_buffer_alloc.c
net.c
oid.c
pk_wrap.c
pkparse.c
pkwrite.c
+ platform.c
+ ripemd160.c
rsa.c
sha1.c
sha256.c
threading.c
timing.c
version.c
+ version_features.c
x509.c
x509_crt.c
x509_crl.c
set(libs ws2_32)
endif(WIN32)
-if(NOT USE_SHARED_POLARSSL_LIBRARY)
+if(CMAKE_COMPILER_IS_GNUCC)
+ set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS_CHECK} -Wmissing-declarations -Wmissing-prototypes")
+ set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual")
+endif(CMAKE_COMPILER_IS_GNUCC)
-add_library(polarssl STATIC ${src})
+if(CMAKE_COMPILER_IS_CLANG)
+ set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS_CHECK} -Wmissing-declarations -Wmissing-prototypes")
+endif(CMAKE_COMPILER_IS_CLANG)
-else(NOT USE_SHARED_POLARSSL_LIBRARY)
+if (NOT USE_STATIC_POLARSSL_LIBRARY AND NOT USE_SHARED_POLARSSL_LIBRARY)
+ message(FATAL_ERROR "Need to choose static or shared polarssl build!")
+endif(NOT USE_STATIC_POLARSSL_LIBRARY AND NOT USE_SHARED_POLARSSL_LIBRARY)
-add_library(polarssl SHARED ${src})
-set_target_properties(polarssl PROPERTIES VERSION 1.3.2 SOVERSION 5)
+if(USE_STATIC_POLARSSL_LIBRARY AND USE_SHARED_POLARSSL_LIBRARY)
+ # if we build both static an shared, then let
+ # tests and programs link to the shared lib target
+ set(polarssl_static_target "polarssl_static")
+elseif(USE_STATIC_POLARSSL_LIBRARY)
+ set(polarssl_static_target "polarssl")
+endif()
-endif(NOT USE_SHARED_POLARSSL_LIBRARY)
+if(USE_STATIC_POLARSSL_LIBRARY)
+ add_library(${polarssl_static_target} STATIC ${src})
+ set_target_properties(${polarssl_static_target} PROPERTIES OUTPUT_NAME polarssl)
+ target_link_libraries(${polarssl_static_target} ${libs})
-target_link_libraries(polarssl ${libs})
+ if(ZLIB_FOUND)
+ target_link_libraries(${polarssl_static_target} ${ZLIB_LIBRARIES})
+ endif(ZLIB_FOUND)
-install(TARGETS polarssl
- DESTINATION ${LIB_INSTALL_DIR}
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ if(LINK_WITH_PTHREAD)
+ target_link_libraries(${polarssl_static_target} pthread)
+ endif()
+
+ install(TARGETS ${polarssl_static_target}
+ DESTINATION ${LIB_INSTALL_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+endif()
+
+if(USE_SHARED_POLARSSL_LIBRARY)
+ add_library(polarssl SHARED ${src})
+ set_target_properties(polarssl PROPERTIES VERSION 1.3.8 SOVERSION 7)
+
+ target_link_libraries(polarssl ${libs})
+
+ if(ZLIB_FOUND)
+ target_link_libraries(polarssl ${ZLIB_LIBRARIES})
+ endif(ZLIB_FOUND)
+
+ if(LINK_WITH_PTHREAD)
+ target_link_libraries(polarssl pthread)
+ endif()
+
+ install(TARGETS polarssl
+ DESTINATION ${LIB_INSTALL_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+endif(USE_SHARED_POLARSSL_LIBRARY)
+++ /dev/null
-/*
- * Memory allocation layer
- *
- * Copyright (C) 2006-2013, Brainspark B.V.
- *
- * This file is part of PolarSSL (http://www.polarssl.org)
- * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "polarssl/config.h"
-
-#if defined(POLARSSL_MEMORY_C)
-
-#include "polarssl/memory.h"
-
-#if !defined(POLARSSL_MEMORY_STDMALLOC)
-static void *memory_malloc_uninit( size_t len )
-{
- ((void) len);
- return( NULL );
-}
-
-#define POLARSSL_MEMORY_STDMALLOC memory_malloc_uninit
-#endif /* !POLARSSL_MEMORY_STDMALLOC */
-
-#if !defined(POLARSSL_MEMORY_STDFREE)
-static void memory_free_uninit( void *ptr )
-{
- ((void) ptr);
-}
-
-#define POLARSSL_MEMORY_STDFREE memory_free_uninit
-#endif /* !POLARSSL_MEMORY_STDFREE */
-
-void * (*polarssl_malloc)( size_t ) = POLARSSL_MEMORY_STDMALLOC;
-void (*polarssl_free)( void * ) = POLARSSL_MEMORY_STDFREE;
-
-int memory_set_own( void * (*malloc_func)( size_t ),
- void (*free_func)( void * ) )
-{
- polarssl_malloc = malloc_func;
- polarssl_free = free_func;
-
- return( 0 );
-}
-
-#endif /* POLARSSL_MEMORY_C */