[OpenWrt-Devel] [PATCH] procd: Use pkg-config to find json-c

Yousong Zhou yszhou4tech at gmail.com
Wed Mar 4 21:13:03 EST 2015


Hi, Karl

On 4 March 2015 at 21:51, Karl Palsson <karlp at tweak.net.au> wrote:
>
> Comments inline, I thought I'd made similar comments earlier, but
> perhaps I forgot...
>
> William Holland <william.holland at codethink.co.uk> wrote:
>> ---
>>  CMakeLists.txt     |    4 ++++
>>  plug/hotplug.c     |    2 +-
>>  service/validate.c |    2 +-
>>  3 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/CMakeLists.txt b/CMakeLists.txt
>> index 5414677..0296735 100644
>> --- a/CMakeLists.txt
>> +++ b/CMakeLists.txt
>> @@ -14,6 +14,10 @@ SET(SOURCES procd.c signal.c watchdog.c state.c    inittab.c rcS.c ubus.c system.c
>>       service/service.c service/instance.c service/validate.c service/trigger.c service/watch.c
>>       plug/coldplug.c plug/hotplug.c utils/utils.c)
>>
>> +INCLUDE(FindPkgConfig)
>> +PKG_CHECK_MODULES(JSONC json-c json)
>> +INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
>> +
>>  find_library(json NAMES json-c json)
>
> procd is only used in openwrt in releases that came after the json-c
> library moved to version 0.11.  There's no need for this backward
> compatibility in "new code"
>

Yeah, legacy json-c support was dropped in libubox [1] and not long ago.

 [1] libubox: drop legacy json-c support,
http://git.openwrt.org/?p=project/libubox.git;a=commitdiff;h=cbf80de7f4df61960f386cb01a899cf4228d38f3

>
>>  SET(LIBS ubox ubus ${json} blobmsg_json json_script)
>>
>> diff --git a/plug/hotplug.c b/plug/hotplug.c
>> index 061833a..aa0e070 100644
>> --- a/plug/hotplug.c
>> +++ b/plug/hotplug.c
>> @@ -22,7 +22,7 @@
>>  #include <libubox/blobmsg_json.h>
>>  #include <libubox/json_script.h>
>>  #include <libubox/uloop.h>
>> -#include <json/json.h>
>> +#include <json.h>
>
> Why not <json-c/json.h> ? The package makefile for libjson-c installs
> into the json-c directory.  Why do you need this?  Why would you want to
> be different to other platforms?
>

Details about the practices used by other platforms will help here.  AFAIK,

 - pkg-config file of json-c project itself currently defines the
include path to be "usr/include/json-c"
 - "-I/usr/include/json-c" is the current output of "pkg-config
--cflags json-c" on Debian Wheezy, Ubuntu 14.04, and MacPorts for Mac
OS X Mavericks.
 - lldpd is the only package besides libubox among OpenWrt base
packages that depends on libjson-c and it expects to find the header
with "#include <json.h>" [2].

Well, current code mostly works and I am fine with it, but if
something was to be changed I hope the above information could be
useful.

 [2] https://github.com/vincentbernat/lldpd/blob/master/src/client/jsonc_writer.c#L26

Regards

                yousong

>>
>>  #include <fcntl.h>
>>  #include <unistd.h>
>> diff --git a/service/validate.c b/service/validate.c
>> index a33a48e..cedd1ed 100644
>> --- a/service/validate.c
>> +++ b/service/validate.c
>> @@ -13,7 +13,7 @@
>>
>>  #include <libubox/blobmsg_json.h>
>>  #include <libubox/avl-cmp.h>
>> -#include <json/json.h>
>> +#include <json.h>
>
> Same....
>
>>
>>  #include "../procd.h"
>>
>> --
>> 1.7.10.4
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel at lists.openwrt.org
>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
> --
> Sent using Mailpile, Free Software from www.mailpile.is
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list