From 43fabff6d48017e9b55fb981b519f5e67a6c328e Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Sun, 27 Sep 2020 12:02:48 +0200
Subject: [PATCH] MISC: Add json-c to dependency dl, but need need cmake

---
 README.md            |  8 ++++++--
 depends/depends.txt  |  1 +
 depends/rules.txt    |  1 +
 scripts/depends.bash | 12 ++++++++++++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 2b61bf0d..442a5342 100644
--- a/README.md
+++ b/README.md
@@ -41,9 +41,13 @@ configuration file:
 If you use the configure with the `--with-depends` option (needed on debian
 10), you will need the following dependencies:
 
-- the [curl](https://curl.haxx.se/) command line utility
-- the [wget](https://www.gnu.org/software/wget/) command line utility
+- the [curl](https://curl.haxx.se/) command line utility. It can be replaced by
+  the wget command line utility.
+- the [wget](https://www.gnu.org/software/wget/) command line utility. Can be
+  replaced by curl command line utility.
 - the [git](https://git-scm.com/) command line utility
+- the [cmake](https://cmake.org/download/) command line utility (to be deleted
+  when use of json-c is dropped)
 
 Note that because of the use of `curl` and `get`, building behind a proxy may
 be challenging.
diff --git a/depends/depends.txt b/depends/depends.txt
index 7c36c16c..4d80e86e 100644
--- a/depends/depends.txt
+++ b/depends/depends.txt
@@ -4,3 +4,4 @@ wget    libcurl     https://curl.haxx.se/download/curl-7.72.0.tar.gz
 wget    zlib        https://zlib.net/zlib-1.2.11.tar.gz                         zlib.tar.gz
 wget    iconv       https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz   iconv.tar.gz
 wget    openssl     https://www.openssl.org/source/openssl-1.1.1h.tar.gz        openssl.tar.gz
+git     json-c      https://github.com/json-c/json-c.git                        json-c
diff --git a/depends/rules.txt b/depends/rules.txt
index 6e50ecb2..fee92de3 100644
--- a/depends/rules.txt
+++ b/depends/rules.txt
@@ -4,3 +4,4 @@ openssl		sslconfigure	no-shared -fPIC no-hw
 sqlite3     configure   	--disable-shared --disable-tcl CFLAGS=-fPIC --enable-update-limit --with-zlib=__BUILD_DIR__
 sdl2        configure   	--disable-shared --enable-fcitx --enable-input-tslib=no CFLAGS=-fPIC
 libcurl     configure   	--disable-shared --without-zlib --enable-optimize --disable-rt --disable-pop3 --disable-imap --disable-rtsp --disable-smtp --disable-smb --disable-smbs --disable-dict --disable-tftp --enable-https --enable-http --enable-mime --disable-threaded-resolver --without-zsh-functions-dir --without-fish-functions-dir --with-ssl=__BUILD_DIR__ --with-zlib=__BUILD_DIR__
+json-c      cmake           -DCMAKE_INSTALL_PREFIX=__BUILD_DIR__ -DBUILD_SHARED_LIBS=OFF -DDISABLE_STATIC_FPIC=OFF -DDISABLE_THREAD_LOCAL_STORAGE=OFF -DENABLE_THREADING=OFF -DDISABLE_WERROR=OFF
diff --git a/scripts/depends.bash b/scripts/depends.bash
index fe74458a..71461bd9 100755
--- a/scripts/depends.bash
+++ b/scripts/depends.bash
@@ -34,6 +34,11 @@ function git ()
     [ $? -ne 0 ] && die "Failed to clone $URL into folder $DEST with options $OPT"
 }
 
+function cmake ()
+{
+    $CMAKE $*
+}
+
 function get ()
 {
     local NUM=$1
@@ -61,10 +66,13 @@ CURL=`which curl 2>/dev/null`
 [ $? -ne 0 ] && die "Failed to find the curl binary"
 WGET=`which wget 2>/dev/null`
 [ $? -ne 0 ] && die "Failed to find the wget binary"
+
 TAR=`which tar 2>/dev/null`
 [ $? -ne 0 ] && die "Failed to find the tar binary"
 GIT=`which git 2>/dev/null`
 [ $? -ne 0 ] && die "Failed to find the git binary"
+CMAKE=`which cmake 2>/dev/null`
+[ $? -ne 0 ] && die "Failed to find the cmake binary"
 
 ! [ -f $DEPENDS_FILE ] && die "You must run this script from the root of the project"
 ! [ -f $PWD/scripts/depends.bash ] && die "You must run thus script from the root of the project"
@@ -168,6 +176,10 @@ do
             [ $? -ne 0 ] && die "Failed to configure $FOLD"
             INSTALL="install_sw"
             ;;
+        cmake)
+            # Yes, some projects build with cmake, will be deleted in future commits
+            CC=$CC CXX=$CXX cmake $ROOT_DIR/depends/$FOLD/ $OPT
+            [ $? -ne 0 ] && die "Failed to configure $FOLD"
     esac
 
     # Common part
-- 
GitLab