Make pip buildable

This package would be very useful if able to be built with pip.  This
commit makes libcper usable from python with
git clone git@github.com:openbmc/libcper.git
pip install libcper

The API at the moment is primitive, and only supports the parse api.  An
example of its usage is included.

Change-Id: I944565c71f616735a738bcc4f815d25251ed27bb
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/subprojects/packagefiles/json-c/config/meson.build b/subprojects/packagefiles/json-c/config/meson.build
new file mode 100644
index 0000000..0c57785
--- /dev/null
+++ b/subprojects/packagefiles/json-c/config/meson.build
@@ -0,0 +1,110 @@
+conf = configuration_data()
+check_headers = [
+    'dlfcn.h',
+    'endian.h',
+    'fcntl.h',
+    'float.h',
+    'inttypes.h',
+    'limits.h',
+    'memory.h',
+    'stdarg.h',
+    'stdint.h',
+    'stdlib.h',
+    'strings.h',
+    'string.h',
+    'syslog.h',
+    'sys/cdefs.h',
+    'sys/param.h',
+    'sys/stat.h',
+    'sys/types.h',
+    'unistd.h',
+    'xlocale.h',
+]
+
+foreach header : check_headers
+    if cc.has_header(header)
+        conf.set('HAVE_@0@'.format(header.underscorify().to_upper()), 1)
+    endif
+endforeach
+
+have_stdc = true
+foreach header : ['stdlib.h', 'stdarg.h', 'string.h', 'float.h']
+    if not conf.has('HAVE_@0@'.format(header.underscorify().to_upper()))
+        have_stdc = false
+    endif
+endforeach
+conf.set10('STDC_HEADERS', have_stdc)
+
+foreach symbol : ['_isnan', '_finite']
+    if cc.has_header_symbol('float.h', symbol)
+        conf.set('HAVE_DECL_@0@'.format(symbol.to_upper()), 1)
+    endif
+endforeach
+
+foreach symbol : ['INFINITY', 'isinf', 'isnan', 'nan']
+    if cc.has_header_symbol('math.h', symbol)
+        conf.set('HAVE_DECL_@0@'.format(symbol.to_upper()), 1)
+    endif
+endforeach
+
+check_function = [
+    'vasprintf',
+    'realloc',
+    'strcasecmp',
+    'strdup',
+    'strerror',
+    'vsyslog',
+    'open',
+    'strtoll',
+]
+
+if conf.has('HAVE_STRINGS_H')
+    check_function += 'strncasecmp'
+endif
+
+foreach function : check_function
+    if cc.has_function(function)
+        conf.set('HAVE_@0@'.format(function.to_upper()), 1)
+    endif
+endforeach
+conf.set10('HAVE_DOPRNT', cc.has_function('_doprnt'))
+
+foreach f : ['snprintf', 'vsnprintf', 'vprintf']
+    if cc.has_header_symbol('stdio.h', f)
+        conf.set('HAVE_@0@'.format(f.to_upper()), 1)
+    endif
+endforeach
+
+size = cc.sizeof('size_t', prefix: '#include <stddef.h>')
+conf.set('SIZEOF_SIZE_T', size)
+
+if cc.get_argument_syntax() == 'msvc'
+    size = cc.sizeof('SSIZE_T', prefix: '#include <BaseTsd.h>')
+else
+    size = cc.sizeof('ssize_t', prefix: '#include <sys/types.h>')
+endif
+conf.set('SIZEOF_SSIZE_T', size)
+
+foreach type : ['int', 'int64_t', 'long', 'long long']
+    size = cc.sizeof(type, prefix: '#include <stdint.h>')
+    conf.set('SIZEOF_@0@'.format(type.underscorify().to_upper()), size)
+endforeach
+
+if cc.links('int main(){__sync_synchronize();}', name: 'atomic builtins')
+    conf.set('HAVE_ATOMIC_BUILTINS', 1)
+endif
+
+if cc.compiles('static __thread int x = 0;', name: '__thread')
+    conf.set('HAVE___THREAD', 1)
+endif
+
+if conf.has('HAVE___THREAD')
+    conf.set('SPEC___THREAD', '__thread')
+elif cc.get_argument_syntax() == 'msvc'
+    conf.set('SPEC___THREAD', '__declspec(thread)')
+endif
+
+conf.set_quoted('VERSION', meson.project_version())
+
+config_h = configure_file(configuration: conf, output: 'config.h')
+
diff --git a/subprojects/packagefiles/json-c/meson.build b/subprojects/packagefiles/json-c/meson.build
new file mode 100644
index 0000000..c2d1c03
--- /dev/null
+++ b/subprojects/packagefiles/json-c/meson.build
@@ -0,0 +1,111 @@
+project(
+    'json-c',
+    'c',
+    version: '0.18',
+    license: 'MIT',
+    meson_version: '>=0.49',
+    default_options: [
+        meson.version().version_compare('>=1.3.0') ? 'c_std=gnu99,c99' : 'c_std=gnu99',
+    ],
+)
+
+cc = meson.get_compiler('c')
+
+if cc.get_argument_syntax() == 'msvc'
+    add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c')
+else
+    add_project_arguments('-D_GNU_SOURCE', language: 'c')
+endif
+
+if get_option('default_library') != 'static'
+    add_project_arguments('-DJSON_C_DLL', language: 'c')
+endif
+
+add_project_arguments(
+    cc.get_supported_arguments('-Wno-deprecated-declarations'),
+    language: 'c',
+)
+
+threads = dependency('threads', required: false)
+math = cc.find_library('m', required: false)
+
+subdir('config')
+inc = include_directories('config')
+
+json_config = configuration_data()
+if conf.has('HAVE_INTTYPES_H')
+    json_config.set('JSON_C_HAVE_INTTYPES_H', 1)
+endif
+json_config_h = configure_file(
+    configuration: json_config,
+    output: 'json_config.h',
+)
+
+jconf = configuration_data()
+jconf.set('JSON_H_JSON_POINTER', '#include "json_pointer.h"')
+jconf.set('JSON_H_JSON_PATCH', '#include "json_patch.h"')
+
+json_h = configure_file(
+    input: 'json.h.cmakein',
+    output: 'json.h',
+    format: 'cmake@',
+    configuration: jconf,
+)
+
+public_headers = [
+    json_config_h,
+    json_h,
+    'arraylist.h',
+    'debug.h',
+    'json_c_version.h',
+    'json_inttypes.h',
+    'json_object.h',
+    'json_pointer.h',
+    'json_tokener.h',
+    'json_util.h',
+    'linkhash.h',
+    'printbuf.h',
+]
+
+sources = files(
+    'arraylist.c',
+    'debug.c',
+    'json_c_version.c',
+    'json_object.c',
+    'json_object_iterator.c',
+    'json_pointer.c',
+    'json_tokener.c',
+    'json_util.c',
+    'json_visit.c',
+    'linkhash.c',
+    'printbuf.c',
+    'random_seed.c',
+    'strerror_override.c',
+)
+
+libjson_c = library(
+    'json-c',
+    sources,
+    include_directories: inc,
+    install: true,
+    version: '5.4.0',
+)
+
+json_c_dep = declare_dependency(
+    link_with: libjson_c,
+    include_directories: include_directories('.', '..'),
+    dependencies: [math, threads],
+    sources: json_config_h,
+)
+
+install_headers(public_headers, subdir: 'json-c')
+
+pkgconfig = import('pkgconfig')
+pkgconfig.generate(
+    libjson_c,
+    description: 'A JSON implementation in C',
+    version: meson.project_version(),
+    filebase: meson.project_name(),
+    name: meson.project_name(),
+    subdirs: 'json-c',
+)