add build flag to use libubox instead of provided base64 implementation

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
Felix Fietkau 2015-04-19 12:42:10 +02:00
parent 24f880d718
commit cf8dcdb8a4
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -1,6 +1,9 @@
#ifndef __BASE64_H
#define __BASE64_H
#ifdef USE_LIBUBOX
#include <libubox/utils.h>
#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