meson: Use doxygen to build documentation

Doxyfile.in contains a roughly-default setup, only building HTML
documentation based on the library headers and source files.

This gets a start on fixing issues highlighted by warnings over time.

Change-Id: Iaffc601c40a4131d069c52a5b49c60dfd066a15b
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/meson.build b/meson.build
index aab10c9..c62ff95 100644
--- a/meson.build
+++ b/meson.build
@@ -74,6 +74,34 @@
 subdir('include')
 subdir('src')
 
+doxygen = find_program('doxygen', required: false)
+if doxygen.found()
+    doxydata = configuration_data()
+    doxydata.set('description', meson.project_name())
+    doxydata.set('project', meson.project_name())
+    doxydata.set('version', meson.project_version())
+    doxydata.set(
+        'sources',
+        '@0@ @1@'.format(
+            meson.project_source_root() / 'include',
+            meson.project_source_root() / 'src',
+        ),
+    )
+    doxyfile = configure_file(
+        input: 'Doxyfile.in',
+        output: 'Doxyfile',
+        configuration: doxydata,
+        install: false,
+    )
+
+    docs = custom_target(
+        'docs',
+        input: doxyfile,
+        output: 'doxygen',
+        command: [doxygen, doxyfile],
+    )
+endif
+
 if get_option('tests')
     subdir('tests')
 endif