add cli tool for signing network json files
[project/unetd.git] / CMakeLists.txt
index 73c4cfa55300003f9ba884a31f800e246425e071..651ac804ad6714a9ed22b2232fc4691c2e37544b 100644 (file)
@@ -5,8 +5,7 @@ PROJECT(unetd C)
 
 SET(SOURCES
        main.c network.c host.c service.c pex.c utils.c
-       curve25519.c siphash.c
-       wg.c wg-dummy.c wg-user.c
+       wg.c wg-user.c
 )
 
 SET(RUNSTATEDIR /var/run)
@@ -17,9 +16,11 @@ FIND_LIBRARY(libjson NAMES json-c json)
 OPTION(UBUS_SUPPORT "enable ubus support" ON)
 IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
        FIND_LIBRARY(nl nl-tiny)
-       SET(SOURCES ${SOURCES} wg-linux.c vxlan.c)
+       find_library(bpf NAMES bpf)
+       SET(SOURCES ${SOURCES} wg-linux.c vxlan.c bpf.c rtnl.c)
 ELSE()
        SET(nl "")
+       SET(bpf "")
 ENDIF()
 IF(UBUS_SUPPORT)
   SET(SOURCES ${SOURCES} ubus.c)
@@ -29,10 +30,16 @@ ELSE()
   SET(ubus "")
 ENDIF()
 
+ADD_LIBRARY(unet SHARED curve25519.c siphash.c sha512.c fprime.c f25519.c ed25519.c edsign.c auth-data.c)
+TARGET_LINK_LIBRARIES(unet ubox)
+
 ADD_EXECUTABLE(unetd ${SOURCES})
-TARGET_LINK_LIBRARIES(unetd ubox ${ubus} blobmsg_json ${libjson} ${nl})
+TARGET_LINK_LIBRARIES(unetd unet ubox ${ubus} blobmsg_json ${libjson} ${nl} ${bpf})
+
+ADD_EXECUTABLE(unet-tool cli.c)
+TARGET_LINK_LIBRARIES(unet-tool unet blobmsg_json ${libjson} ubox)
 
-INSTALL(TARGETS unetd
+INSTALL(TARGETS unetd unet unet-tool
        RUNTIME DESTINATION sbin
        LIBRARY DESTINATION lib
 )