logread: fix reconnect logd logic
[project/ubox.git] / CMakeLists.txt
index 69c000d..62de1d4 100644 (file)
@@ -11,28 +11,32 @@ IF(APPLE)
 ENDIF()
 
 find_library(json NAMES json-c json)
-SET(LIBS ubox uci ubus ${json} blobmsg_json)
 
 IF(DEBUG)
   ADD_DEFINITIONS(-DDEBUG -g3)
 ENDIF()
 
-ADD_EXECUTABLE(kmodloader kmodloader.c)
-TARGET_LINK_LIBRARIES(kmodloader ${LIBS})
+INCLUDE (CheckSymbolExists)
+CHECK_SYMBOL_EXISTS(SYS_getrandom syscall.h getrandom)
 
-INSTALL(TARGETS kmodloader
-       RUNTIME DESTINATION sbin
-)
+IF(getrandom)
+  ADD_EXECUTABLE(getrandom getrandom.c)
+  INSTALL(TARGETS getrandom
+          RUNTIME DESTINATION bin
+  )
+ELSE()
+  message( FATAL_ERROR "Kernel too old, missing SYS_getrandom system call")
+ENDIF()
 
-ADD_EXECUTABLE(board board.c)
-TARGET_LINK_LIBRARIES(board ${LIBS})
+ADD_EXECUTABLE(kmodloader kmodloader.c)
+TARGET_LINK_LIBRARIES(kmodloader ubox)
 
-INSTALL(TARGETS board
+INSTALL(TARGETS kmodloader
        RUNTIME DESTINATION sbin
 )
 
 ADD_EXECUTABLE(lsbloader lsbloader.c)
-TARGET_LINK_LIBRARIES(lsbloader ${LIBS})
+TARGET_LINK_LIBRARIES(lsbloader ubox ubus)
 
 INSTALL(TARGETS lsbloader
        RUNTIME DESTINATION sbin
@@ -43,20 +47,23 @@ INSTALL(TARGETS validate
        LIBRARY DESTINATION lib
 )
 
+FIND_PATH(uci_include_dir uci.h)
+INCLUDE_DIRECTORIES(${uci_include_dir})
+
 ADD_EXECUTABLE(validate_data validate/cli.c)
-TARGET_LINK_LIBRARIES(validate_data ${LIBS} validate)
+TARGET_LINK_LIBRARIES(validate_data ubox uci validate)
 INSTALL(TARGETS validate_data
        RUNTIME DESTINATION sbin
 )
 
 ADD_EXECUTABLE(logd log/logd.c log/syslog.c)
-TARGET_LINK_LIBRARIES(logd ${LIBS})
+TARGET_LINK_LIBRARIES(logd ubox ubus)
 INSTALL(TARGETS logd
        RUNTIME DESTINATION sbin
 )
 
 ADD_EXECUTABLE(logread log/logread.c)
-TARGET_LINK_LIBRARIES(logread ${LIBS})
+TARGET_LINK_LIBRARIES(logread ubox ubus ${json} blobmsg_json)
 INSTALL(TARGETS logread
        RUNTIME DESTINATION sbin
 )