From cf8dcdb8a4e874c77f3e9a8e9b643e8c17b19131 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 19 Apr 2015 12:42:10 +0200 Subject: [PATCH] add build flag to use libubox instead of provided base64 implementation Signed-off-by: Felix Fietkau --- CMakeLists.txt | 12 +++++++++++- base64.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8361171..68f50ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,18 @@ cmake_minimum_required(VERSION 2.8) PROJECT(usign C) ADD_DEFINITIONS(-O2 -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations) -SET(SOURCES ed25519.c edsign.c f25519.c fprime.c sha512.c base64.c main.c) +SET(SOURCES ed25519.c edsign.c f25519.c fprime.c sha512.c main.c) + +SET(LIBS) +IF(USE_LIBUBOX) + ADD_DEFINITIONS(-DUSE_LIBUBOX) + SET(LIBS ubox) +ELSE() + SET(SOURCES ${SOURCES} base64.c) +ENDIF() + ADD_EXECUTABLE(usign ${SOURCES}) +TARGET_LINK_LIBRARIES(usign ${LIBS}) INSTALL(TARGETS usign RUNTIME DESTINATION bin diff --git a/base64.h b/base64.h index 0f49e9a..9ae2b49 100644 --- a/base64.h +++ b/base64.h @@ -1,6 +1,9 @@ #ifndef __BASE64_H #define __BASE64_H +#ifdef USE_LIBUBOX +#include +#else int b64_encode(const void *src, size_t src_len, void *dest, size_t dest_len); @@ -8,5 +11,6 @@ int b64_decode(const void *src, void *dest, size_t dest_len); #define B64_ENCODE_LEN(_len) ((((_len) + 2) / 3) * 4 + 1) #define B64_DECODE_LEN(_len) (((_len) / 4) * 3 + 1) +#endif /* USE_LIBUBOX */ #endif -- 2.25.1