Browse Source

ADD: switched to cmake for build project

master
Dominik Meyer 8 months ago
parent
commit
5b77d27689
No known key found for this signature in database
32 changed files with 168 additions and 154 deletions
  1. +1
    -0
      .gitignore
  2. +85
    -0
      CMakeLists.txt
  3. +0
    -42
      Makefile.am
  4. +0
    -6
      bootstrap.sh
  5. +21
    -0
      cmake/Modules/FindJSON-C.cmake
  6. +21
    -0
      cmake/Modules/Findwebsockets.cmake
  7. +0
    -66
      configure.ac
  8. +0
    -0
      include/moolticute.h
  9. +1
    -1
      src/callbacks/moolticute_cb_application_id.c
  10. +1
    -1
      src/callbacks/moolticute_cb_card_db_metadata.c
  11. +1
    -1
      src/callbacks/moolticute_cb_connected.c
  12. +2
    -2
      src/callbacks/moolticute_cb_failed_memorymgmt.c
  13. +1
    -1
      src/callbacks/moolticute_cb_memorymgmt_changed.c
  14. +1
    -1
      src/callbacks/moolticute_cb_memorymgmt_data.c
  15. +1
    -1
      src/callbacks/moolticute_cb_not_found.c
  16. +1
    -1
      src/callbacks/moolticute_cb_param_changed.c
  17. +1
    -1
      src/callbacks/moolticute_cb_progress.c
  18. +1
    -1
      src/callbacks/moolticute_cb_status_changed.c
  19. +1
    -1
      src/callbacks/moolticute_cb_version_changed.c
  20. +1
    -1
      src/cmds/moolticute_cmd_get_application_id.c
  21. +1
    -1
      src/cmds/moolticute_cmd_query_random_number.c
  22. +1
    -1
      src/cmds/moolticute_cmd_request_device_uid.c
  23. +2
    -2
      src/cmds/moolticute_cmd_request_password.c
  24. +2
    -2
      src/cmds/moolticute_cmd_service_exist.c
  25. +2
    -2
      src/cmds/moolticute_cmd_start_memory_management.c
  26. +1
    -1
      src/cmds/moolticute_cmd_stop_memory_management.c
  27. +1
    -1
      src/moolticute_array.c
  28. +1
    -1
      src/moolticute_callback.c
  29. +1
    -1
      src/moolticute_connect.c
  30. +13
    -13
      src/moolticute_init.c
  31. +1
    -1
      src/moolticute_register_cb.c
  32. +1
    -1
      src/mooltipass_memory.c

+ 1
- 0
.gitignore View File

@@ -26,3 +26,4 @@ config.h.in
**/*.gch
/cmds
/callbacks
build

+ 85
- 0
CMakeLists.txt View File

@@ -0,0 +1,85 @@
cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
project (libmoolticute-c VERSION 0.1.0 LANGUAGES C)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
include(GNUInstallDirs)
include(CTest)
enable_testing()

option(DOXYGEN "Also build the doxygen documentation" OFF)

find_package(Git)
find_package(Threads)
find_package(JSON-C REQUIRED)
find_package(websockets REQUIRED)


set(moolticute_sources
include/moolticute.h
src/mooltipass_memory.c
src/moolticute_register_cb.c
src/moolticute_init.c
src/moolticute_connect.c
src/moolticute_callback.c
src/moolticute_array.h
src/moolticute_array.c
src/callbacks/moolticute_cb_application_id.c
src/callbacks/moolticute_cb_application_id.h
src/callbacks/moolticute_cb_card_db_metadata.c
src/callbacks/moolticute_cb_card_db_metadata.h
src/callbacks/moolticute_cb_connected.c
src/callbacks/moolticute_cb_connected.h
src/callbacks/moolticute_cb_failed_memorymgmt.h
src/callbacks/moolticute_cb_failed_memorymgmt.c
src/callbacks/moolticute_cb_memorymgmt_changed.c
src/callbacks/moolticute_cb_memorymgmt_changed.h
src/callbacks/moolticute_cb_memorymgmt_data.h
src/callbacks/moolticute_cb_memorymgmt_data.c
src/callbacks/moolticute_cb_not_found.h
src/callbacks/moolticute_cb_not_found.c
src/callbacks/moolticute_cb_param_changed.c
src/callbacks/moolticute_cb_param_changed.h
src/callbacks/moolticute_cb_progress.h
src/callbacks/moolticute_cb_progress.c
src/callbacks/moolticute_cb_status_changed.h
src/callbacks/moolticute_cb_status_changed.c
src/callbacks/moolticute_cb_version_changed.h
src/callbacks/moolticute_cb_version_changed.c
src/cmds/moolticute_cmd_get_application_id.c
src/cmds/moolticute_cmd_query_random_number.c
src/cmds/moolticute_cmd_request_device_uid.c
src/cmds/moolticute_cmd_service_exist.c
src/cmds/moolticute_cmd_start_memory_management.c
src/cmds/moolticute_cmd_stop_memory_management.c
)

add_library(objlib OBJECT ${moolticute_sources})
set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
target_include_directories(objlib
PUBLIC
include
PRIVATE
src
)


add_library(moolticute SHARED $<TARGET_OBJECTS:objlib>)
add_library(moolticute-static STATIC $<TARGET_OBJECTS:objlib>)

target_link_libraries(moolticute ${CMAKE_THREAD_LIBS_INIT} ${WEBSOCKETS_LIBRARIES} ${JSON-C_LIBARIES})
target_link_libraries(moolticute-static ${CMAKE_THREAD_LIBS_INIT} ${WEBSOCKETS_LIBRARIES} ${JSON-C_LIBARIES})

target_include_directories(moolticute
PUBLIC
include
PRIVATE
src
)

target_include_directories(moolticute-static
PUBLIC
include
PRIVATE
src
)
set_target_properties(moolticute-static PROPERTIES OUTPUT_NAME moolticute)

+ 0
- 42
Makefile.am View File

@@ -1,42 +0,0 @@
noinst_LIBRARIES = libmoolticute.a

libmoolticute_a_SOURCES = src/callbacks/moolticute_cb_application_id.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_card_db_metadata.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_connected.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_failed_memorymgmt.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_memorymgmt_changed.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_memorymgmt_data.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_not_found.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_param_changed.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_progress.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_status_changed.c
libmoolticute_a_SOURCES += src/callbacks/moolticute_cb_version_changed.c

libmoolticute_a_SOURCES += src/cmds/moolticute_cmd_get_application_id.c
libmoolticute_a_SOURCES += src/cmds/moolticute_cmd_query_random_number.c
libmoolticute_a_SOURCES += src/cmds/moolticute_cmd_request_device_uid.c
libmoolticute_a_SOURCES += src/cmds/moolticute_cmd_request_password.c
libmoolticute_a_SOURCES += src/cmds/moolticute_cmd_service_exist.c
libmoolticute_a_SOURCES += src/cmds/moolticute_cmd_start_memory_management.c
libmoolticute_a_SOURCES += src/cmds/moolticute_cmd_stop_memory_management.c

libmoolticute_a_SOURCES += src/moolticute_array.c
libmoolticute_a_SOURCES += src/moolticute_callback.c
libmoolticute_a_SOURCES += src/moolticute_connect.c
libmoolticute_a_SOURCES += src/moolticute_init.c
libmoolticute_a_SOURCES += src/moolticute_register_cb.c
libmoolticute_a_SOURCES += src/mooltipass_memory.c

include_HEADERS = src/moolticute.h
nodist_include_HEADERS = src/moolticute_array.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_application_id.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_card_db_metadata.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_connected.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_failed_memorymgmt.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_memorymgmt_changed.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_memorymgmt_data.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_not_found.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_param_changed.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_progress.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_status_changed.h
nodist_include_HEADERS += src/callbacks/moolticute_cb_version_changed.h

+ 0
- 6
bootstrap.sh View File

@@ -1,6 +0,0 @@
#! /bin/sh
aclocal \
&& libtoolize \
&& autoheader \
&& automake --gnu --add-missing \
&& autoconf

+ 21
- 0
cmake/Modules/FindJSON-C.cmake View File

@@ -0,0 +1,21 @@
# JSON-C_FOUND - true if library and headers were found
# JSON-C_INCLUDE_DIRS - include directories
# JSON-C_LIBRARIES - library directories

find_package(PkgConfig)
pkg_check_modules(PC_JSON-C QUIET json-c)

find_path(JSON-C_INCLUDE_DIR json.h
HINTS ${PC_JSON-C_INCLUDEDIR} ${PC_JSON-C_INCLUDE_DIRS} PATH_SUFFIXES json-c json)

find_library(JSON-C_LIBRARY NAMES json-c libjson-c
HINTS ${PC_JSON-C_LIBDIR} ${PC_JSON-C_LIBRARY_DIRS})

set(JSON-C_LIBRARIES ${JSON-C_LIBRARY})
set(JSON-C_INCLUDE_DIRS ${JSON-C_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(JSON-C DEFAULT_MSG JSON-C_LIBRARY JSON-C_INCLUDE_DIR)

mark_as_advanced(JSON-C_INCLUDE_DIR JSON-C_LIBRARY)

+ 21
- 0
cmake/Modules/Findwebsockets.cmake View File

@@ -0,0 +1,21 @@
# WEBSOCKETS_FOUND - true if library and headers were found
# WEBSOCKETS_INCLUDE_DIRS - include directories
# WEBSOCKETS_LIBRARIES - library directories

find_package(PkgConfig)
pkg_check_modules(PC_WEBSOCKETS QUIET websockets)

find_path(WEBSOCKETS_INCLUDE_DIR libwebsockets.h
HINTS ${PC_WEBSOCKETS_INCLUDEDIR} ${PC_WEBSOCKETS_INCLUDE_DIRS})

find_library(WEBSOCKETS_LIBRARY NAMES libwebsockets.so
HINTS ${PC_WEBSOCKETS_LIBDIR} ${PC_WEBSOCKETS_LIBRARY_DIRS})

set(WEBSOCKETS_LIBRARIES ${JSON-C_LIBRARY})
set(WEBSOCKETS_INCLUDE_DIRS ${WEBSOCKETS_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(WEBSOCKETS DEFAULT_MSG WEBSOCKETS_LIBRARY WEBSOCKETS_INCLUDE_DIR)

mark_as_advanced(WEBSOCKETS_INCLUDE_DIR WEBSOCKETS_LIBRARY)

+ 0
- 66
configure.ac View File

@@ -1,66 +0,0 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_LANG_PUSH([C])
AC_INIT([libmoolticute-c], [0.0.1])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AM_PROG_AR
LT_INIT
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
])


# Checks for programs.
AC_PROG_CC
CFLAGS=-Wall

AC_SEARCH_LIBS([pthread_create], [pthread], [], [
AC_MSG_ERROR([unable to find pthread library])
])

AC_SEARCH_LIBS([json_object_new_object], [json-c], [], [
AC_MSG_ERROR([unable to find json-c library])
])

AC_SEARCH_LIBS([lws_create_context], [websockets], [], [
AC_MSG_ERROR([unable to find websockets library])
])

# Checks for header files.
AC_CHECK_HEADERS([stdint.h stdlib.h string.h stdio.h ])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memset strtol])


AC_ARG_ENABLE(valgrind,
AC_HELP_STRING([--enable-valgrind],
[Run libmoolticute-c using valgrind]))

AC_MSG_CHECKING([valgrind])
valgrind_status="yes"

AM_CONDITIONAL(WITH_VALGRIND, test "$enable_valgrind" = "run")

# Build valgrind support into code
if test "$enable_valgrind" = "yes"; then
CFLAGS="$CFLAGS -O0 -ggdb3"
AC_MSG_RESULT(yes)
# No valgrind
else
AC_MSG_RESULT(no)
valgrind_status="no"
fi



AC_OUTPUT

src/moolticute.h → include/moolticute.h View File


+ 1
- 1
src/callbacks/moolticute_cb_application_id.c View File

@@ -1,4 +1,4 @@
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>
#include <stdio.h>


+ 1
- 1
src/callbacks/moolticute_cb_card_db_metadata.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>

void moolticute_cb_card_db_metadata(void *user, struct json_object *jObj)

+ 1
- 1
src/callbacks/moolticute_cb_connected.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>

void moolticute_cb_connect(void *user, struct json_object *jObj)
{

+ 2
- 2
src/callbacks/moolticute_cb_failed_memorymgmt.c View File

@@ -23,8 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include "../moolticute_array.h"
#include <moolticute.h>
#include <moolticute_array.h>
#include <json-c/json.h>
#include <stdio.h>


+ 1
- 1
src/callbacks/moolticute_cb_memorymgmt_changed.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>

void moolticute_cb_memorymgmt_changed(void *user, struct json_object *jObj)
{

+ 1
- 1
src/callbacks/moolticute_cb_memorymgmt_data.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>

int mooltipass_penc_to_str(struct json_object *password_enc, char *password)

+ 1
- 1
src/callbacks/moolticute_cb_not_found.c View File

@@ -1,4 +1,4 @@
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>
#include <stdio.h>


+ 1
- 1
src/callbacks/moolticute_cb_param_changed.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>

int isTrue(const char *value)

+ 1
- 1
src/callbacks/moolticute_cb_progress.c View File

@@ -1,4 +1,4 @@
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>
#include <stdio.h>


+ 1
- 1
src/callbacks/moolticute_cb_status_changed.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>

void moolticute_cb_status_changed(void *user, struct json_object *jObj)

+ 1
- 1
src/callbacks/moolticute_cb_version_changed.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>

void moolticute_cb_version_changed(void *user, struct json_object *jObj)

+ 1
- 1
src/cmds/moolticute_cmd_get_application_id.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>
#include <libwebsockets.h>


+ 1
- 1
src/cmds/moolticute_cmd_query_random_number.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>
#include <libwebsockets.h>
#include <stdint.h>

+ 1
- 1
src/cmds/moolticute_cmd_request_device_uid.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>
#include <libwebsockets.h>


+ 2
- 2
src/cmds/moolticute_cmd_request_password.c View File

@@ -23,8 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include "../moolticute_array.h"
#include <moolticute.h>
#include <moolticute_array.h>
#include <json-c/json.h>
#include <libwebsockets.h>


+ 2
- 2
src/cmds/moolticute_cmd_service_exist.c View File

@@ -23,10 +23,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>
#include <libwebsockets.h>
#include "../moolticute_array.h"
#include <moolticute_array.h>

/**
* @brief callback for the credential_exist/data_node_exist message

+ 2
- 2
src/cmds/moolticute_cmd_start_memory_management.c View File

@@ -23,8 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include "../moolticute_array.h"
#include <moolticute.h>
#include <moolticute_array.h>
#include <json-c/json.h>
#include <libwebsockets.h>


+ 1
- 1
src/cmds/moolticute_cmd_stop_memory_management.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "../moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>
#include <libwebsockets.h>


+ 1
- 1
src/moolticute_array.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*/
#include <pthread.h>
#include "moolticute.h"
#include <moolticute.h>

/**
* @brief initialize the error and value structure in context

+ 1
- 1
src/moolticute_callback.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "moolticute.h"
#include <moolticute.h>
#include <json-c/json.h>



+ 1
- 1
src/moolticute_connect.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "moolticute.h"
#include <moolticute.h>

/*
* @brief websocket threat, calling the lws_service function every 250msecs

+ 13
- 13
src/moolticute_init.c View File

@@ -23,19 +23,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "moolticute.h"
#include "callbacks/moolticute_cb_not_found.h"
#include "callbacks/moolticute_cb_connected.h"
#include "callbacks/moolticute_cb_status_changed.h"
#include "callbacks/moolticute_cb_param_changed.h"
#include "callbacks/moolticute_cb_version_changed.h"
#include "callbacks/moolticute_cb_card_db_metadata.h"
#include "callbacks/moolticute_cb_memorymgmt_data.h"
#include "callbacks/moolticute_cb_memorymgmt_changed.h"
#include "callbacks/moolticute_cb_application_id.h"
#include "callbacks/moolticute_cb_progress.h"
#include "callbacks/moolticute_cb_failed_memorymgmt.h"
#include "moolticute_array.h"
#include <moolticute.h>
#include <callbacks/moolticute_cb_not_found.h>
#include <callbacks/moolticute_cb_connected.h>
#include <callbacks/moolticute_cb_status_changed.h>
#include <callbacks/moolticute_cb_param_changed.h>
#include <callbacks/moolticute_cb_version_changed.h>
#include <callbacks/moolticute_cb_card_db_metadata.h>
#include <callbacks/moolticute_cb_memorymgmt_data.h>
#include <callbacks/moolticute_cb_memorymgmt_changed.h>
#include <callbacks/moolticute_cb_application_id.h>
#include <callbacks/moolticute_cb_progress.h>
#include <callbacks/moolticute_cb_failed_memorymgmt.h>
#include <moolticute_array.h>
#include <libwebsockets.h>



+ 1
- 1
src/moolticute_register_cb.c View File

@@ -1,4 +1,4 @@
#include "moolticute.h"
#include <moolticute.h>
#include <string.h>

void moolticute_register_cb(struct moolticute_ctx *ctx,const char *cmd, void (*cb)(void *user,struct json_object *jObj))

+ 1
- 1
src/mooltipass_memory.c View File

@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2018 by Dominik Meyer
*
*/
#include "moolticute.h"
#include <moolticute.h>
#include <string.h>



Loading…
Cancel
Save