Create util static library

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I72926c6aad2468f2f8b32685dc03b7d5004871f0
diff --git a/analyzer/meson.build b/analyzer/meson.build
index 0c69315..371e0b8 100644
--- a/analyzer/meson.build
+++ b/analyzer/meson.build
@@ -4,9 +4,6 @@
     'create_pel.cpp',
     'hei_user_interface.cpp',
     'initialize_isolator.cpp',
-    '../util/ffdc_file.cpp',
-    '../util/pdbg.cpp',
-    '../util/temporary_file.cpp',
 )
 
 # Library dependencies.
diff --git a/attn/meson.build b/attn/meson.build
index 294644f..ceaad7d 100644
--- a/attn/meson.build
+++ b/attn/meson.build
@@ -6,9 +6,6 @@
 # dependency to link gpiod support
 libgpiod = dependency('libgpiod', version : '>=1.4.1')
 
-# dependency to link libpdbg support
-libpdbg = cmplr.find_library('pdbg')
-
 # install systemd unit file
 configure_file(
     input: 'attn_handler.service',
@@ -35,6 +32,6 @@
 attn = static_library('attn_handler',
                       attn_src,
                       include_directories : incdir,
-                      dependencies : [libpdbg, sdbusplus_dep, libgpiod],
+                      dependencies : [libpdbg_dep, sdbusplus_dep, libgpiod],
                       cpp_args : [boost_args, test_arg],
                       install : true)
diff --git a/meson.build b/meson.build
index 9ddfa45..dd05445 100644
--- a/meson.build
+++ b/meson.build
@@ -8,6 +8,8 @@
           'cpp_args=-Wno-unused-parameter'
         ])
 
+cmplr = meson.get_compiler('cpp')
+
 # First, look if the libhei library has already been built and installed. If
 # not, default to the subproject.
 libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep'])
@@ -15,12 +17,13 @@
 sdbusplus_dep       = dependency('sdbusplus', version : '>=1.0')
 dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
 
+libpdbg_dep = cmplr.find_library('pdbg')
+
 incdir = include_directories('.')
 
 # See if phosphor-logging is available, if not use test case logging code. This
 # allows for local builds outside of CI test sandbox.
 h = 'phosphor-logging/log.hpp'
-cmplr = meson.get_compiler('cpp')
 if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h))
     test_arg = []
     phosphor_logging = true
@@ -33,6 +36,7 @@
 
 subdir('analyzer')
 subdir('attn')
+subdir('util')
 
 pthread = declare_dependency(link_args : '-pthread')
 lrt = declare_dependency(link_args : '-lrt')
@@ -41,12 +45,12 @@
 
 if not no_listener_mode.disabled()
   executable('openpower-hw-diags', 'main_nl.cpp', 'cli.cpp',
-              link_with : [analyzer, attn],
+              link_with : [analyzer, attn, util_lib],
               install : true)
 else
   executable('openpower-hw-diags', 'main.cpp', 'cli.cpp', 'listener.cpp',
               dependencies : [lrt, pthread],
-              link_with : [analyzer, attn],
+              link_with : [analyzer, attn, util_lib],
               cpp_args : test_arg,
               install : true)
 endif
diff --git a/test/end2end/meson.build b/test/end2end/meson.build
index 7508ae4..5b6451e 100644
--- a/test/end2end/meson.build
+++ b/test/end2end/meson.build
@@ -15,6 +15,7 @@
 end2end_libs = [
     analyzer,
     attn,
+    util_lib,
 ]
 
 # create openpower-hw-diags executable for local testing
diff --git a/util/meson.build b/util/meson.build
new file mode 100644
index 0000000..7618260
--- /dev/null
+++ b/util/meson.build
@@ -0,0 +1,23 @@
+# Source files.
+util_src = files(
+    'ffdc_file.cpp',
+    'pdbg.cpp',
+    'temporary_file.cpp',
+)
+
+# Library dependencies.
+util_deps = [
+    libhei_dep,
+    libpdbg_dep,
+]
+
+# Create static library.
+util_lib = static_library(
+    'util_lib',
+    util_src,
+    include_directories : incdir,
+    dependencies : util_deps,
+    cpp_args : test_arg,
+    install : false
+)
+