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/meson.build b/meson.build
index 4240cd3..ede0bf1 100644
--- a/meson.build
+++ b/meson.build
@@ -2,10 +2,9 @@
     'libcper',
     'c',
     version: '0.1',
-    meson_version: '>=1.1.1',
+    meson_version: '>=1.2.0',
     default_options: [
         'c_std=c18',
-        'cpp_std=c++23',
         'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
         'warning_level=2',
         'werror=true',
@@ -74,7 +73,11 @@
 
 cc = meson.get_compiler('c')
 
-json_c_dep = dependency('json-c')
+json_c = dependency('json-c', default_options: {'warning_level': '0'})
+json_c_dep = declare_dependency(
+    include_directories: include_directories('subprojects'),
+    dependencies: json_c,
+)
 libcper_include = ['include']
 libcper_include_dir = include_directories(libcper_include, is_system: true)
 
@@ -89,6 +92,8 @@
 
 subdir('include')
 
+install = get_option('install').allowed()
+
 libcper_parse = library(
     'cper-parse',
     libcper_parse_sources,
@@ -97,8 +102,7 @@
     include_directories: libcper_include_dir,
     c_args: '-Wno-address-of-packed-member',
     dependencies: [json_c_dep],
-    install: true,
-    install_dir: get_option('libdir'),
+    install: install,
 )
 libcper_parse_dep = declare_dependency(
     include_directories: libcper_include_dir,
@@ -117,20 +121,21 @@
     include_directories: libcper_include_dir,
     dependencies: [json_c_dep],
     link_with: [libcper_parse],
-    install: true,
-    install_dir: get_option('libdir'),
+    install: install,
 )
 libcper_generate_dep = declare_dependency(
     include_directories: libcper_include_dir,
     link_with: libcper_generate,
 )
 
-import('pkgconfig').generate(
-    libcper_parse,
-    name: meson.project_name(),
-    version: meson.project_version(),
-    description: 'C bindings for parsing CPER',
-)
+if get_option('pkgconfig').allowed()
+    import('pkgconfig').generate(
+        libcper_parse,
+        name: meson.project_name(),
+        version: meson.project_version(),
+        description: 'C bindings for parsing CPER',
+    )
+endif
 
 if get_option('utility').allowed()
     executable(
@@ -139,7 +144,7 @@
         include_directories: libcper_include_dir,
         dependencies: [json_c_dep],
         link_with: [libcper_parse, libcper_generate],
-        install: true,
+        install: install,
         install_dir: get_option('bindir'),
     )
 
@@ -149,7 +154,7 @@
         edk_sources,
         include_directories: libcper_include_dir,
         link_with: [libcper_parse, libcper_generate],
-        install: true,
+        install: install,
         install_dir: get_option('bindir'),
     )
 endif
@@ -161,3 +166,14 @@
         subdir('tests')
     endif
 endif
+
+if get_option('python').allowed()
+    py = import('python').find_installation(pure: false)
+    py.extension_module(
+        'cper',
+        'pycper.c',
+        c_args: ['-DLIBCPER_PYTHON'],
+        dependencies: [libcper_parse_dep, json_c_dep],
+        install: true,
+    )
+endif