host: deal with host/peer null pointers in debug messages
[project/unetd.git] / CMakeLists.txt
index 50e18488997ec6430a91da11a152cff6468670dc..a7e3b8adb535958e8d4252f6f5a507185d65e1d5 100644 (file)
@@ -4,9 +4,8 @@ PROJECT(unetd C)
 
 
 SET(SOURCES
-       main.c ubus.c network.c host.c service.c pex.c utils.c
-       curve25519.c siphash.c
-       wg.c wg-dummy.c wg-user.c
+       main.c network.c host.c service.c pex.c
+       wg.c wg-user.c
 )
 
 SET(RUNSTATEDIR /var/run)
@@ -14,17 +13,33 @@ SET(RUNSTATEDIR /var/run)
 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations -DRUNSTATEDIR="${RUNSTATEDIR}")
 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)
+       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)
+  ADD_DEFINITIONS(-DUBUS_SUPPORT=1)
+  FIND_LIBRARY(ubus ubus)
+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 chacha20.c pex-msg.c utils.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
 )