Signed-off-by: Felix Fietkau <nbd@openwrt.org>
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
#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);
#define B64_ENCODE_LEN(_len) ((((_len) + 2) / 3) * 4 + 1)
#define B64_DECODE_LEN(_len) (((_len) / 4) * 3 + 1)
+#endif /* USE_LIBUBOX */
#endif