CMakeLists: don't enable libubox md5 implementation by default
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 16 Mar 2017 20:17:24 +0000 (21:17 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 16 Mar 2017 20:33:23 +0000 (21:33 +0100)
Simplify odhcp6c standalone compilation by selecting local md5
implementation by default

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
CMakeLists.txt
README
src/dhcpv6.c

index 745fba2de29671c586a58967f72a45f0b52e322f..a5b0cb397e0965550fb5710b62165e06c3a598db 100644 (file)
@@ -5,7 +5,6 @@ cmake_policy(SET CMP0015 NEW)
 project(odhcp6c C)
 set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=c99")
-set(LIBUBOX 1 CACHE BOOL "Link with libubox")
 add_definitions(-D_GNU_SOURCE -Wall -Werror -Wextra -pedantic)
 
 if(${EXT_PREFIX_CLASS})
@@ -17,15 +16,20 @@ if(${EXT_CER_ID})
 endif(${EXT_CER_ID})
 
 set(SOURCES src/odhcp6c.c src/dhcpv6.c src/ra.c src/script.c)
-if(LIBUBOX EQUAL 0)
-       set(SOURCES ${SOURCES} src/md5.c)
-endif()
-add_executable(odhcp6c ${SOURCES})
 
 set(LIBRARIES resolv)
-if(LIBUBOX EQUAL 1)
+
+if(USE_LIBUBOX)
+       add_definitions(-DUSE_LIBUBOX)
        set(LIBRARIES ${LIBRARIES} ubox)
+       FIND_PATH(ubox_include_dir libubox/md5.h)
+       INCLUDE_DIRECTORIES(${ubox_include_dir})
+else()
+       set(SOURCES ${SOURCES} src/md5.c)
 endif()
+
+add_executable(odhcp6c ${SOURCES})
+
 target_link_libraries(odhcp6c ${LIBRARIES})
 
 # Installation
diff --git a/README b/README
index 70389842bda1679bffecc4674d39125c42ea8bf7..e79fea106240e846abbadb24b91d1e3a8f085019 100644 (file)
--- a/README
+++ b/README
@@ -39,7 +39,7 @@ especially routers. It compiles to only about 35 KB (-Os -s).
 ** Compiling **
 
 odhcp6c uses cmake:
-* To prepare a Makefile use:  "cmake -DLIBUBOX=0 ."
+* To prepare a Makefile use:  "cmake ."
 * To build / install use: "make" / "make install" afterwards.
 * To build DEB or RPM packages use: "make package" afterwards.
 
index 30bfa50339b026167d3b26f84b0ff63d6cc6940c..b7322579cdca59822d5a543d02ba482c39de04e9 100644 (file)
@@ -36,7 +36,7 @@
 #include <net/ethernet.h>
 
 #include "odhcp6c.h"
-#ifdef LIBUBOX
+#ifdef USE_LIBUBOX
 #include <libubox/md5.h>
 #else
 #include "md5.h"