mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Migrate the compilation to cmake instead of autotools
This commit is contained in:
parent
291e11d67a
commit
6e5e5589ca
10 changed files with 76 additions and 243 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -39,3 +39,7 @@ missing
|
|||
*.gcda
|
||||
/icwmpd
|
||||
/Makefile
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ variables:
|
|||
DEBUG: 'TRUE'
|
||||
COMMON_IMAGE: "iopsys/code-analysis:0.27"
|
||||
RUN_CPPCHECK: "cppcheck --enable=all --error-exitcode=1 -D_GNU_SOURCE --suppress=unusedFunction -i ./test/ --inline-suppr"
|
||||
SOURCE_FOLDER: "."
|
||||
SOURCE_FOLDER: "./src"
|
||||
CWMP_WORKER_PROCESSES: 1
|
||||
NBI_WORKER_PROCESSES: 1
|
||||
FS_WORKER_PROCESSES: 1
|
||||
|
|
|
|||
44
CMakeLists.txt
Normal file
44
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
PROJECT(icwmp C)
|
||||
|
||||
ADD_DEFINITIONS(-Wall -Wextra -Werror -Wformat)
|
||||
ADD_DEFINITIONS(-D_GNU_SOURCE)
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}")
|
||||
|
||||
OPTION(WITH_WOLFSSL "build with lib wolfssl" OFF)
|
||||
OPTION(WITH_OPENSSL "build with lib openssl" OFF)
|
||||
OPTION(WITH_MBEDTLS "build with lib mbedtls" OFF)
|
||||
|
||||
IF(NOT WITH_WOLFSSL AND NOT WITH_OPENSSL AND NOT WITH_MBEDTLS)
|
||||
MESSAGE(FATAL_ERROR "You must enable one of the SSL libraries: {'WOLFSSL','OPENSSL','MBEDTLS'}")
|
||||
ENDIF()
|
||||
|
||||
FILE(GLOB ICWMP_SOURCES ${PROJECT_SOURCE_DIR}/src/*.c)
|
||||
|
||||
IF(WITH_WOLFSSL)
|
||||
SET(SSL_LIBS wolfssl)
|
||||
SET(SSL_LIBS crypto)
|
||||
add_compile_definitions(LWOLFSSL)
|
||||
ENDIF(WITH_WOLFSSL)
|
||||
|
||||
IF(WITH_OPENSSL)
|
||||
SET(SSL_LIBS ssl)
|
||||
SET(SSL_LIBS crypto)
|
||||
add_compile_definitions(LOPENSSL)
|
||||
ENDIF(WITH_OPENSSL)
|
||||
|
||||
IF(WITH_MBEDTLS)
|
||||
SET(SSL_LIBS mbedtls)
|
||||
SET(SSL_LIBS mbedcrypto)
|
||||
add_compile_definitions(LMBEDTLS)
|
||||
ENDIF(WITH_MBEDTLS)
|
||||
|
||||
ADD_EXECUTABLE(icwmpd ${ICWMP_SOURCES})
|
||||
|
||||
TARGET_LINK_LIBRARIES(icwmpd pthread z m json-c uci ubox ubus blobmsg_json curl mxml ${SSL_LIBS} ${CRYPTO_LIBS})
|
||||
|
||||
INSTALL(FILES icwmpd DESTINATION usr/sbin)
|
||||
|
||||
INSTALL(DIRECTORY DESTINATION etc/icwmpd)
|
||||
68
Makefile.am
68
Makefile.am
|
|
@ -1,68 +0,0 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
CWMP_VERSION = 3.0.1
|
||||
|
||||
bin_PROGRAMS = icwmpd
|
||||
|
||||
icwmpd_SOURCES = \
|
||||
./src/common.c \
|
||||
./src/log.c \
|
||||
./src/cwmp_uci.c \
|
||||
./src/config.c \
|
||||
./src/session.c \
|
||||
./src/backupSession.c \
|
||||
./src/digauth.c \
|
||||
./src/event.c \
|
||||
./src/http.c \
|
||||
./src/ubus_utils.c \
|
||||
./src/datamodel_interface.c \
|
||||
./src/cwmp_cli.c \
|
||||
./src/notifications.c \
|
||||
./src/cwmp_zlib.c \
|
||||
./src/cwmp_du_state.c \
|
||||
./src/download.c \
|
||||
./src/upload.c \
|
||||
./src/sched_inform.c \
|
||||
./src/xml.c \
|
||||
./src/rpc.c \
|
||||
./src/diagnostic.c \
|
||||
./src/reboot.c \
|
||||
./src/heartbeat.c \
|
||||
./src/cwmp.c \
|
||||
./src/ssl_utils.c
|
||||
|
||||
icwmpd_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
$(LIBUCI_CFLAGS) \
|
||||
$(LIBUBOX_CFLAGS) \
|
||||
$(LIBUBUS_CFLAGS) \
|
||||
$(LIBCURL_CFLAGS) \
|
||||
-Wall -Wextra -Werror \
|
||||
-Wformat
|
||||
|
||||
icwmpd_LDFLAGS = \
|
||||
$(AM_LDFLAGS) \
|
||||
$(LIBUCI_LDFLAGS) \
|
||||
$(LIBUBOX_LDFLAGS) \
|
||||
$(LIBUBUS_LDFLAGS) \
|
||||
$(LIBCURL_LDFLAGS) \
|
||||
-lmxml
|
||||
|
||||
icwmpd_LDADD = \
|
||||
$(AM_LIBS) \
|
||||
$(LIBUCI_LIBS) \
|
||||
$(LIBUBOX_LIBS) \
|
||||
$(LIBUBUS_LIBS) \
|
||||
$(LIBCURL_LIBS) \
|
||||
$(LIBPTHREAD_LIBS) \
|
||||
$(LCRYPTO_LIBS) \
|
||||
$(LSSL_LIBS) \
|
||||
$(LIBJSON_LIBS) \
|
||||
$(LBLOBMSG_LIBS) \
|
||||
$(LIBZ_LIBS) \
|
||||
$(LIBM_LIBS)
|
||||
|
||||
icwmpd_CFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
|
||||
icwmpd_LDFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
|
||||
|
||||
icwmpd_CFLAGS+=-I..
|
||||
125
configure.ac
125
configure.ac
|
|
@ -1,125 +0,0 @@
|
|||
AC_INIT([icwmp], [1.0], [dev@iopsys.eu])
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_SRCDIR([src/cwmp.c])
|
||||
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||
|
||||
# additional options
|
||||
|
||||
AC_ARG_ENABLE(acs, [AS_HELP_STRING([--enable-acs],
|
||||
[specify which ACS is going to be used; there are some optimizations available for HDM and Fusion ACS (default --enable-acs=multi]))],,
|
||||
[AC_DEFINE(ACS_MULTI)])
|
||||
|
||||
AS_IF([test "x$enable_acs" = "xhdm"], [AC_DEFINE(ACS_HDM)])
|
||||
AS_IF([test "x$enable_acs" = "xfusion"], [AC_DEFINE(ACS_FUSION)])
|
||||
AS_IF([test "x$enable_acs" = "xmulti"], [AC_DEFINE(ACS_MULTI)])
|
||||
AS_IF([test "x$enable_acs" = "xyes"], [AC_DEFINE(ACS_MULTI)])
|
||||
AS_IF([test "x$enable_acs" = "xno"], [AC_DEFINE(ACS_MULTI)])
|
||||
|
||||
AC_ARG_ENABLE(libopenssl, [AS_HELP_STRING([--enable-libopenssl], [enable libopenssl feature])], AC_DEFINE(LOPENSSL))
|
||||
AM_CONDITIONAL([LOPENSSL],[test "x$enable_libopenssl" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(libwolfssl, [AS_HELP_STRING([--enable-libwolfssl], [enable libwolfssl feature])], AC_DEFINE(LWOLFSSL))
|
||||
AM_CONDITIONAL([LWOLFSSL],[test "x$enable_libwolfssl" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(libmbedtls, [AS_HELP_STRING([--enable-libmbedtls], [enable libmbedtls feature])], AC_DEFINE(LMBEDTLS))
|
||||
AM_CONDITIONAL([LMBEDTLS],[test "x$enable_libmbedtls" = "xyes"])
|
||||
|
||||
# checks for programs
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
LT_INIT
|
||||
AC_ENABLE_SHARED
|
||||
|
||||
# checks for libraries
|
||||
LIBPTHREAD_LIBS='-lpthread'
|
||||
AC_SUBST([LIBPTHREAD_LIBS])
|
||||
|
||||
# checks for libraries
|
||||
LIBZ_LIBS='-lz'
|
||||
AC_SUBST([LIBZ_LIBS])
|
||||
|
||||
LIBM_LIBS='-lm'
|
||||
AC_SUBST([LIBM_LIBS])
|
||||
LIBJSON_LIBS='-ljson-c'
|
||||
AC_SUBST([LIBJSON_LIBS])
|
||||
|
||||
AC_ARG_WITH([uci-include-path],
|
||||
[AS_HELP_STRING([--with-uci-include-path],
|
||||
[location of the uci library headers])],
|
||||
[LIBUCI_CFLAGS="-I$withval"])
|
||||
AC_SUBST([LIBUCI_CFLAGS])
|
||||
|
||||
AC_ARG_WITH([uci-lib-path],
|
||||
[AS_HELP_STRING([--with-uci-lib-path], [location of the uci library])], [LIBUCI_LDFLAGS="-L$withval"])
|
||||
AC_SUBST([LIBUCI_LDFLAGS])
|
||||
|
||||
LIBUCI_LIBS='-luci'
|
||||
AC_SUBST([LIBUCI_LIBS])
|
||||
|
||||
AC_ARG_WITH([libubox-include-path],
|
||||
[AS_HELP_STRING([--with-libubox-include-path],
|
||||
[location of the libubox library headers])],
|
||||
[LIBUBOX_CFLAGS="-I$withval"])
|
||||
AC_SUBST([LIBUBOX_CFLAGS])
|
||||
|
||||
AC_ARG_WITH([libubox-lib-path],
|
||||
[AS_HELP_STRING([--with-libubox-lib-path], [location of the libubox library])], [LIBUBOX_LDFLAGS="-L$withval"])
|
||||
AC_SUBST([LIBUBOX_LDFLAGS])
|
||||
|
||||
LIBUBOX_LIBS='-lubox'
|
||||
AC_SUBST([LIBUBOX_LIBS])
|
||||
|
||||
AC_ARG_WITH([libubus-include-path],
|
||||
[AS_HELP_STRING([--with-libubus-include-path],
|
||||
[location of the libubus library headers])],
|
||||
[LIBUBUS_CFLAGS="-I$withval"])
|
||||
AC_SUBST([LIBUBUS_CFLAGS])
|
||||
|
||||
AC_ARG_WITH([libubus-lib-path],
|
||||
[AS_HELP_STRING([--with-libubus-lib-path], [location of the libubus library])], [LIBUBOX_LDFLAGS="-L$withval"])
|
||||
AC_SUBST([LIBUBUS_LDFLAGS])
|
||||
|
||||
LIBUBUS_LIBS='-lubus'
|
||||
AC_SUBST([LIBUBUS_LIBS])
|
||||
|
||||
LBLOBMSG_LIBS='-lblobmsg_json'
|
||||
AC_SUBST([LBLOBMSG_LIBS])
|
||||
|
||||
AM_COND_IF([LWOLFSSL], [
|
||||
LSSL_LIBS='-lwolfssl'
|
||||
AC_SUBST([LSSL_LIBS])
|
||||
AC_SUBST([LCRYPTO_LIBS])
|
||||
])
|
||||
|
||||
AM_COND_IF([LOPENSSL], [
|
||||
LSSL_LIBS='-lssl'
|
||||
LCRYPTO_LIBS='-lcrypto'
|
||||
AC_SUBST([LSSL_LIBS])
|
||||
AC_SUBST([LCRYPTO_LIBS])
|
||||
])
|
||||
|
||||
AM_COND_IF([LMBEDTLS], [
|
||||
LSSL_LIBS='-lmbedtls'
|
||||
LCRYPTO_LIBS='-lmbedcrypto'
|
||||
AC_SUBST([LSSL_LIBS])
|
||||
AC_SUBST([LCRYPTO_LIBS])
|
||||
])
|
||||
|
||||
PKG_CHECK_MODULES(LIBCURL, [libcurl])
|
||||
AC_SUBST(LIBCURL_CFLAGS)
|
||||
AC_SUBST(LIBCURL_LDFLAGS)
|
||||
AC_SUBST(LIBCURL_LIBS)
|
||||
|
||||
# checks for header files
|
||||
AC_CHECK_HEADERS([stdlib.h string.h])
|
||||
|
||||
# checks for typedefs, structures, and compiler characteristics
|
||||
AC_TYPE_UINT8_T
|
||||
|
||||
# Makefiles
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
|
@ -99,17 +99,18 @@ function check_cwmp_status()
|
|||
|
||||
function clean_icwmp()
|
||||
{
|
||||
if [ -f Makefile ]; then
|
||||
exec_cmd make maintainer-clean
|
||||
exec_cmd make -C test/cmocka clean
|
||||
find -name '*.gcda' -exec rm {} -fv \;
|
||||
find -name '*.gcno' -exec rm {} -fv \;
|
||||
find -name '*.gcov' -exec rm {} -fv \;
|
||||
find -name '*.deps' -exec rm {} -rfv \;
|
||||
find -name '*.so' -exec rm {} -fv \;
|
||||
rm -f *.o *.log *.xml vgcore.* firmware_v1.0.bin
|
||||
rm -rf report
|
||||
if [ -d build ]; then
|
||||
rm -rf build
|
||||
fi
|
||||
|
||||
exec_cmd make -C test/cmocka clean
|
||||
find -name '*.gcda' -exec rm {} -fv \;
|
||||
find -name '*.gcno' -exec rm {} -fv \;
|
||||
find -name '*.gcov' -exec rm {} -fv \;
|
||||
find -name '*.deps' -exec rm {} -rfv \;
|
||||
find -name '*.so' -exec rm {} -fv \;
|
||||
rm -f *.o *.log *.xml vgcore.* firmware_v1.0.bin
|
||||
rm -rf report
|
||||
}
|
||||
|
||||
function build_icwmp()
|
||||
|
|
@ -121,10 +122,15 @@ function build_icwmp()
|
|||
clean_icwmp
|
||||
|
||||
# compile icwmp
|
||||
autoreconf -i >/dev/null 2>&1
|
||||
./configure CFLAGS="$COV_CFLAGS" LDFLAGS="$COV_LDFLAGS" --enable-acs=multi --enable-debug --enable-libopenssl >/dev/null 2>&1
|
||||
make CFLAGS="$COV_CFLAGS" LDFLAGS="$COV_LDFLAGS"
|
||||
check_ret $?
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake ../ -DCMAKE_C_FLAGS="$COV_CFLAGS " -DCMAKE_EXE_LINKER_FLAGS="$COV_LDFLAGS" -DWITH_OPENSSL=ON -DCMAKE_INSTALL_PREFIX=/
|
||||
exec_cmd make
|
||||
|
||||
echo "installing icwmpd binary"
|
||||
exec_cmd cp icwmpd ../
|
||||
exec_cmd make install
|
||||
cd ..
|
||||
}
|
||||
|
||||
function install_uspd()
|
||||
|
|
|
|||
22
src/common.c
22
src/common.c
|
|
@ -22,11 +22,6 @@
|
|||
#include "ubus_utils.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
#ifndef CWMP_REVISION
|
||||
#define CWMP_REVISION "8.2.10"
|
||||
#endif
|
||||
|
||||
char *commandKey = NULL;
|
||||
bool thread_end = false;
|
||||
long int flashsize = 256000000;
|
||||
|
|
@ -91,18 +86,8 @@ static void show_help(void)
|
|||
printf("Usage: icwmpd [OPTIONS]\n");
|
||||
printf(" -b, --boot-event (CWMP daemon) Start CWMP with BOOT event\n");
|
||||
printf(" -g, --get-rpc-methods (CWMP daemon) Start CWMP with GetRPCMethods request to ACS\n");
|
||||
printf(" -c, --cli CWMP CLI\n");
|
||||
printf(" -c, --cli CWMP CLI\n");
|
||||
printf(" -h, --help Display this help text\n");
|
||||
printf(" -v, --version Display the version\n");
|
||||
}
|
||||
|
||||
static void show_version()
|
||||
{
|
||||
#ifndef CWMP_REVISION
|
||||
fprintf(stdout, "\nVersion: %s\n\n", CWMP_VERSION);
|
||||
#else
|
||||
fprintf(stdout, "\nVersion: %s revision %s\n\n", CWMP_VERSION, CWMP_REVISION);
|
||||
#endif
|
||||
}
|
||||
|
||||
int global_env_init(int argc, char **argv, struct env *env)
|
||||
|
|
@ -114,7 +99,6 @@ int global_env_init(int argc, char **argv, struct env *env)
|
|||
case 'b':
|
||||
env->boot = CWMP_START_BOOT;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
env->periodic = CWMP_START_PERIODIC;
|
||||
break;
|
||||
|
|
@ -124,10 +108,6 @@ int global_env_init(int argc, char **argv, struct env *env)
|
|||
case 'h':
|
||||
show_help();
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
show_version();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
return CWMP_OK;
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@
|
|||
#include <libubox/list.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef CWMP_VERSION
|
||||
#define CWMP_VERSION "3.0.0"
|
||||
#endif
|
||||
|
||||
#ifndef FREE
|
||||
#define FREE(x) do { if(x) {free(x); x = NULL;} } while (0)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -207,19 +207,17 @@ int icwmp_http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len, c
|
|||
http_c.header_list = curl_slist_append(http_c.header_list, "User-Agent: iopsys-cwmp");
|
||||
if (!http_c.header_list)
|
||||
return -1;
|
||||
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Type: text/xml");
|
||||
if (!http_c.header_list)
|
||||
return -1;
|
||||
#ifdef ACS_FUSION
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "Expect:");
|
||||
if (!http_c.header_list)
|
||||
return -1;
|
||||
#endif /* ACS_FUSION */
|
||||
|
||||
if (cwmp->conf.http_disable_100continue) {
|
||||
http_c.header_list = curl_slist_append(http_c.header_list, "Expect:");
|
||||
if (!http_c.header_list)
|
||||
return -1;
|
||||
}
|
||||
|
||||
http_set_connection_options(cwmp);
|
||||
http_set_security_options(cwmp);
|
||||
http_set_header_list_options(cwmp);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
include ../../Makefile.am
|
||||
|
||||
LIB_LDFLAGS:= -luci -lblobmsg_json -lubox\
|
||||
-ljson-c -lubus -lpthread -lcurl\
|
||||
-lcrypto -lmxml
|
||||
|
||||
LIB_CFLAGS:= -fPIC -I../../src/ -DLOPENSSL -g -O0
|
||||
LIB_CFLAGS:= -fPIC -I../../ -DLOPENSSL -g -O0
|
||||
UNIT_TESTS:= icwmp_unit_testd
|
||||
|
||||
VALGRIND = /usr/bin/valgrind --xml=yes --xml-file=memory-report.xml --leak-check=full --show-reachable=yes --show-leak-kinds=all --errors-for-leak-kinds=all
|
||||
|
||||
ICWMP_SOURCES=$(patsubst ./src/%.c, ../../src/%.c, $(icwmpd_SOURCES))
|
||||
ICWMP_OBJS=$(patsubst ../../src/%.c, %.o, $(ICWMP_SOURCES))
|
||||
|
||||
ICWMP_OBJS=$(patsubst ../../src/%.c, %.o, $(wildcard ../../src/*.c))
|
||||
TEST_SRCS = $(wildcard *.c)
|
||||
TEST_OBJS = $(TEST_SRCS:=.o)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue