diff mbox

json: allow for different paths to json.h (LP: #1326911)

Message ID 1411640244-8727-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Sept. 25, 2014, 10:17 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Some distros (such as Arch Linux) are using json-c with
headers in a different location to Debian/Ubuntu. To cater for
this, explicitly add the possible paths into the Makefiles and
change #include <json/json.h> to <json.h>.

Since json.h is included via including fwts.h, we can use this
opportunity to the remove the json.h include from several source files
too.

Test built on Ubuntu and Arch Linux

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/Makefile.am                    | 2 ++
 src/acpi/syntaxcheck/syntaxcheck.c | 1 -
 src/acpica/Makefile.am             | 2 ++
 src/lib/include/fwts_json.h        | 2 +-
 src/lib/src/Makefile.am            | 4 +++-
 src/lib/src/fwts_klog.c            | 1 -
 src/lib/src/fwts_log_json.c        | 1 -
 src/utilities/Makefile.am          | 3 ++-
 src/utilities/kernelscan.c         | 2 +-
 9 files changed, 11 insertions(+), 7 deletions(-)

Comments

Alex Hung Sept. 29, 2014, 8:17 a.m. UTC | #1
On 09/25/2014 06:17 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Some distros (such as Arch Linux) are using json-c with
> headers in a different location to Debian/Ubuntu. To cater for
> this, explicitly add the possible paths into the Makefiles and
> change #include <json/json.h> to <json.h>.
> 
> Since json.h is included via including fwts.h, we can use this
> opportunity to the remove the json.h include from several source files
> too.
> 
> Test built on Ubuntu and Arch Linux
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/Makefile.am                    | 2 ++
>  src/acpi/syntaxcheck/syntaxcheck.c | 1 -
>  src/acpica/Makefile.am             | 2 ++
>  src/lib/include/fwts_json.h        | 2 +-
>  src/lib/src/Makefile.am            | 4 +++-
>  src/lib/src/fwts_klog.c            | 1 -
>  src/lib/src/fwts_log_json.c        | 1 -
>  src/utilities/Makefile.am          | 3 ++-
>  src/utilities/kernelscan.c         | 2 +-
>  9 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index d472d5c..51d09a0 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -11,6 +11,8 @@ AM_CPPFLAGS = \
>  	-I$(top_srcdir)/src/acpica/source/include \
>  	-I$(top_srcdir)/src/acpica/source/compiler \
>  	-I$(top_srcdir)/efi_runtime \
> +	-I/usr/include/json \
> +	-I/usr/include/json-c \
>  	-pthread `pkg-config --cflags glib-2.0 gio-2.0` \
>  	-Wall -Werror -Wextra
>  
> diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
> index 7b26b9f..7d365e8 100644
> --- a/src/acpi/syntaxcheck/syntaxcheck.c
> +++ b/src/acpi/syntaxcheck/syntaxcheck.c
> @@ -25,7 +25,6 @@
>  #include <unistd.h>
>  #include <string.h>
>  
> -#include <json/json.h>
>  #define MAX_TABLES	(128)
>  
>  #define ASL_EXCEPTIONS
> diff --git a/src/acpica/Makefile.am b/src/acpica/Makefile.am
> index cbd38c6..8c3f307 100644
> --- a/src/acpica/Makefile.am
> +++ b/src/acpica/Makefile.am
> @@ -8,6 +8,8 @@ AM_CPPFLAGS = 						\
>  	-D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP	\
>  	-I$(top_srcdir)/src/lib/include			\
>  	-I$(srcdir)/source/include			\
> +	-I/usr/include/json				\
> +	-I/usr/include/json-c				\
>  	-Wall -fno-strict-aliasing
>  
>  #
> diff --git a/src/lib/include/fwts_json.h b/src/lib/include/fwts_json.h
> index ad5d8ed..d1f54d8 100644
> --- a/src/lib/include/fwts_json.h
> +++ b/src/lib/include/fwts_json.h
> @@ -20,7 +20,7 @@
>  #ifndef __FWTS_JSON_H__
>  #define __FWTS_JSON_H__
>  
> -#include <json/json.h>
> +#include <json.h>
>  
>  #define __FWTS_JSON_ERR_PTR__ ((json_object*) -1)
>  /*
> diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
> index fca9c06..33f81f4 100644
> --- a/src/lib/src/Makefile.am
> +++ b/src/lib/src/Makefile.am
> @@ -2,7 +2,9 @@ AM_CPPFLAGS = \
>  	-I$(top_srcdir)/src/lib/include 		\
>  	-I$(top_srcdir)/src/acpica/source/include	\
>  	-I$(top_srcdir)/src/acpica/source/compiler	\
> -	`pkg-config --cflags glib-2.0 gio-2.0` \
> +	-I/usr/include/json				\
> +	-I/usr/include/json-c				\
> +	`pkg-config --cflags glib-2.0 gio-2.0` 		\
>  	-DDATAROOTDIR=\"$(datarootdir)\"		\
>  	-Wall -Werror -Wextra
>  
> diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
> index ae6e396..8b4a9ed 100644
> --- a/src/lib/src/fwts_klog.c
> +++ b/src/lib/src/fwts_klog.c
> @@ -23,7 +23,6 @@
>  #include <stdbool.h>
>  #include <sys/types.h>
>  #include <pcre.h>
> -#include <json/json.h>
>  #include <ctype.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
> diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
> index 98224b2..075cc34 100644
> --- a/src/lib/src/fwts_log_json.c
> +++ b/src/lib/src/fwts_log_json.c
> @@ -26,7 +26,6 @@
>  #include <sys/ioctl.h>
>  #include <time.h>
>  
> -#include <json/json.h>
>  #include "fwts.h"
>  
>  #define MAX_JSON_STACK	(64)
> diff --git a/src/utilities/Makefile.am b/src/utilities/Makefile.am
> index 01b534a..c681676 100644
> --- a/src/utilities/Makefile.am
> +++ b/src/utilities/Makefile.am
> @@ -1,4 +1,5 @@
> -AM_CPPFLAGS = -Wall -Werror -Wextra -DDATAROOTDIR=\"$(datarootdir)\"
> +AM_CPPFLAGS = -Wall -Werror -Wextra -DDATAROOTDIR=\"$(datarootdir)\" \
> +	-I/usr/include/json -I/usr/include/json-c
>  
>  bin_PROGRAMS = kernelscan
>  kernelscan_SOURCES = kernelscan.c
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 78c70d5..0eeeb95 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -25,7 +25,7 @@
>  #include <unistd.h>
>  
>  #include <pcre.h>
> -#include <json/json.h>
> +#include <json.h>
>  #include "config.h"
>  
>  #define PARSER_OK		0
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin Sept. 29, 2014, 8:44 a.m. UTC | #2
On Thu, Sep 25, 2014 at 6:17 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Some distros (such as Arch Linux) are using json-c with
> headers in a different location to Debian/Ubuntu. To cater for
> this, explicitly add the possible paths into the Makefiles and
> change #include <json/json.h> to <json.h>.
>
> Since json.h is included via including fwts.h, we can use this
> opportunity to the remove the json.h include from several source files
> too.
>
> Test built on Ubuntu and Arch Linux
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/Makefile.am                    | 2 ++
>  src/acpi/syntaxcheck/syntaxcheck.c | 1 -
>  src/acpica/Makefile.am             | 2 ++
>  src/lib/include/fwts_json.h        | 2 +-
>  src/lib/src/Makefile.am            | 4 +++-
>  src/lib/src/fwts_klog.c            | 1 -
>  src/lib/src/fwts_log_json.c        | 1 -
>  src/utilities/Makefile.am          | 3 ++-
>  src/utilities/kernelscan.c         | 2 +-
>  9 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index d472d5c..51d09a0 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -11,6 +11,8 @@ AM_CPPFLAGS = \
>         -I$(top_srcdir)/src/acpica/source/include \
>         -I$(top_srcdir)/src/acpica/source/compiler \
>         -I$(top_srcdir)/efi_runtime \
> +       -I/usr/include/json \
> +       -I/usr/include/json-c \
>         -pthread `pkg-config --cflags glib-2.0 gio-2.0` \
>         -Wall -Werror -Wextra
>
> diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
> index 7b26b9f..7d365e8 100644
> --- a/src/acpi/syntaxcheck/syntaxcheck.c
> +++ b/src/acpi/syntaxcheck/syntaxcheck.c
> @@ -25,7 +25,6 @@
>  #include <unistd.h>
>  #include <string.h>
>
> -#include <json/json.h>
>  #define MAX_TABLES     (128)
>
>  #define ASL_EXCEPTIONS
> diff --git a/src/acpica/Makefile.am b/src/acpica/Makefile.am
> index cbd38c6..8c3f307 100644
> --- a/src/acpica/Makefile.am
> +++ b/src/acpica/Makefile.am
> @@ -8,6 +8,8 @@ AM_CPPFLAGS =                                           \
>         -D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP    \
>         -I$(top_srcdir)/src/lib/include                 \
>         -I$(srcdir)/source/include                      \
> +       -I/usr/include/json                             \
> +       -I/usr/include/json-c                           \
>         -Wall -fno-strict-aliasing
>
>  #
> diff --git a/src/lib/include/fwts_json.h b/src/lib/include/fwts_json.h
> index ad5d8ed..d1f54d8 100644
> --- a/src/lib/include/fwts_json.h
> +++ b/src/lib/include/fwts_json.h
> @@ -20,7 +20,7 @@
>  #ifndef __FWTS_JSON_H__
>  #define __FWTS_JSON_H__
>
> -#include <json/json.h>
> +#include <json.h>
>
>  #define __FWTS_JSON_ERR_PTR__ ((json_object*) -1)
>  /*
> diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
> index fca9c06..33f81f4 100644
> --- a/src/lib/src/Makefile.am
> +++ b/src/lib/src/Makefile.am
> @@ -2,7 +2,9 @@ AM_CPPFLAGS = \
>         -I$(top_srcdir)/src/lib/include                 \
>         -I$(top_srcdir)/src/acpica/source/include       \
>         -I$(top_srcdir)/src/acpica/source/compiler      \
> -       `pkg-config --cflags glib-2.0 gio-2.0` \
> +       -I/usr/include/json                             \
> +       -I/usr/include/json-c                           \
> +       `pkg-config --cflags glib-2.0 gio-2.0`          \
>         -DDATAROOTDIR=\"$(datarootdir)\"                \
>         -Wall -Werror -Wextra
>
> diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
> index ae6e396..8b4a9ed 100644
> --- a/src/lib/src/fwts_klog.c
> +++ b/src/lib/src/fwts_klog.c
> @@ -23,7 +23,6 @@
>  #include <stdbool.h>
>  #include <sys/types.h>
>  #include <pcre.h>
> -#include <json/json.h>
>  #include <ctype.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
> diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
> index 98224b2..075cc34 100644
> --- a/src/lib/src/fwts_log_json.c
> +++ b/src/lib/src/fwts_log_json.c
> @@ -26,7 +26,6 @@
>  #include <sys/ioctl.h>
>  #include <time.h>
>
> -#include <json/json.h>
>  #include "fwts.h"
>
>  #define MAX_JSON_STACK (64)
> diff --git a/src/utilities/Makefile.am b/src/utilities/Makefile.am
> index 01b534a..c681676 100644
> --- a/src/utilities/Makefile.am
> +++ b/src/utilities/Makefile.am
> @@ -1,4 +1,5 @@
> -AM_CPPFLAGS = -Wall -Werror -Wextra -DDATAROOTDIR=\"$(datarootdir)\"
> +AM_CPPFLAGS = -Wall -Werror -Wextra -DDATAROOTDIR=\"$(datarootdir)\" \
> +       -I/usr/include/json -I/usr/include/json-c
>
>  bin_PROGRAMS = kernelscan
>  kernelscan_SOURCES = kernelscan.c
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 78c70d5..0eeeb95 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -25,7 +25,7 @@
>  #include <unistd.h>
>
>  #include <pcre.h>
> -#include <json/json.h>
> +#include <json.h>
>  #include "config.h"
>
>  #define PARSER_OK              0
> --
> 2.1.0
>
>

Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/Makefile.am b/src/Makefile.am
index d472d5c..51d09a0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,8 @@  AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/acpica/source/include \
 	-I$(top_srcdir)/src/acpica/source/compiler \
 	-I$(top_srcdir)/efi_runtime \
+	-I/usr/include/json \
+	-I/usr/include/json-c \
 	-pthread `pkg-config --cflags glib-2.0 gio-2.0` \
 	-Wall -Werror -Wextra
 
diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
index 7b26b9f..7d365e8 100644
--- a/src/acpi/syntaxcheck/syntaxcheck.c
+++ b/src/acpi/syntaxcheck/syntaxcheck.c
@@ -25,7 +25,6 @@ 
 #include <unistd.h>
 #include <string.h>
 
-#include <json/json.h>
 #define MAX_TABLES	(128)
 
 #define ASL_EXCEPTIONS
diff --git a/src/acpica/Makefile.am b/src/acpica/Makefile.am
index cbd38c6..8c3f307 100644
--- a/src/acpica/Makefile.am
+++ b/src/acpica/Makefile.am
@@ -8,6 +8,8 @@  AM_CPPFLAGS = 						\
 	-D_LINUX -DNDEBUG -D_CONSOLE -DACPI_EXEC_APP	\
 	-I$(top_srcdir)/src/lib/include			\
 	-I$(srcdir)/source/include			\
+	-I/usr/include/json				\
+	-I/usr/include/json-c				\
 	-Wall -fno-strict-aliasing
 
 #
diff --git a/src/lib/include/fwts_json.h b/src/lib/include/fwts_json.h
index ad5d8ed..d1f54d8 100644
--- a/src/lib/include/fwts_json.h
+++ b/src/lib/include/fwts_json.h
@@ -20,7 +20,7 @@ 
 #ifndef __FWTS_JSON_H__
 #define __FWTS_JSON_H__
 
-#include <json/json.h>
+#include <json.h>
 
 #define __FWTS_JSON_ERR_PTR__ ((json_object*) -1)
 /*
diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
index fca9c06..33f81f4 100644
--- a/src/lib/src/Makefile.am
+++ b/src/lib/src/Makefile.am
@@ -2,7 +2,9 @@  AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/lib/include 		\
 	-I$(top_srcdir)/src/acpica/source/include	\
 	-I$(top_srcdir)/src/acpica/source/compiler	\
-	`pkg-config --cflags glib-2.0 gio-2.0` \
+	-I/usr/include/json				\
+	-I/usr/include/json-c				\
+	`pkg-config --cflags glib-2.0 gio-2.0` 		\
 	-DDATAROOTDIR=\"$(datarootdir)\"		\
 	-Wall -Werror -Wextra
 
diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
index ae6e396..8b4a9ed 100644
--- a/src/lib/src/fwts_klog.c
+++ b/src/lib/src/fwts_klog.c
@@ -23,7 +23,6 @@ 
 #include <stdbool.h>
 #include <sys/types.h>
 #include <pcre.h>
-#include <json/json.h>
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/src/lib/src/fwts_log_json.c b/src/lib/src/fwts_log_json.c
index 98224b2..075cc34 100644
--- a/src/lib/src/fwts_log_json.c
+++ b/src/lib/src/fwts_log_json.c
@@ -26,7 +26,6 @@ 
 #include <sys/ioctl.h>
 #include <time.h>
 
-#include <json/json.h>
 #include "fwts.h"
 
 #define MAX_JSON_STACK	(64)
diff --git a/src/utilities/Makefile.am b/src/utilities/Makefile.am
index 01b534a..c681676 100644
--- a/src/utilities/Makefile.am
+++ b/src/utilities/Makefile.am
@@ -1,4 +1,5 @@ 
-AM_CPPFLAGS = -Wall -Werror -Wextra -DDATAROOTDIR=\"$(datarootdir)\"
+AM_CPPFLAGS = -Wall -Werror -Wextra -DDATAROOTDIR=\"$(datarootdir)\" \
+	-I/usr/include/json -I/usr/include/json-c
 
 bin_PROGRAMS = kernelscan
 kernelscan_SOURCES = kernelscan.c
diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
index 78c70d5..0eeeb95 100644
--- a/src/utilities/kernelscan.c
+++ b/src/utilities/kernelscan.c
@@ -25,7 +25,7 @@ 
 #include <unistd.h>
 
 #include <pcre.h>
-#include <json/json.h>
+#include <json.h>
 #include "config.h"
 
 #define PARSER_OK		0