diff --git a/README.md b/README.md
index 5a20b66..623b581 100644
--- a/README.md
+++ b/README.md
@@ -10,15 +10,21 @@ which lines were entered by the user.
- gcc
- libqrtr
- - make
+ - meson or make
- protobuf-c
- qmic (https://github.com/andersson/qmic)
# Installation
-There is a Makefile to compile this:
+This can be compiled using Meson:
- $ make
+ $ meson setup build
+ $ ninja -C build
+
+There is also a Makefile to compile this, if you can get it to work:
+
+ $ mkdir build
+ $ make -k
# Usage
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..f9645a5
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,34 @@
+#
+# Build system root
+#
+# Copyright (C) 2023 Richard Acayan
+#
+# This file is part of sensh.
+#
+# Sensh is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+project('sensh', 'c')
+
+libqrtr = meson.get_compiler('c').find_library('qrtr')
+libprotobuf_c = dependency('libprotobuf-c')
+
+subdir('protobuf')
+subdir('qmi')
+
+executable('sensh',
+ 'sensh.c',
+ qmi,
+ protobufs,
+ dependencies : [libprotobuf_c, libqrtr])
diff --git a/protobuf/meson.build b/protobuf/meson.build
new file mode 100644
index 0000000..46a7e7d
--- /dev/null
+++ b/protobuf/meson.build
@@ -0,0 +1,48 @@
+#
+# Protocol buffers build system
+#
+# Copyright (C) 2023 Richard Acayan
+#
+# This file is part of sensh.
+#
+# Sensh is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+protoc = find_program('protoc-c')
+
+protobuf_src = [
+ 'sns_client_event_msg',
+ 'sns_client_request_msg',
+ 'sns_proximity_event',
+ 'sns_std_attr_event',
+ 'sns_std_attr_req',
+ 'sns_std_sensor_event',
+ 'sns_std_suid',
+ 'sns_suid_event',
+ 'sns_suid_req']
+
+protobufs = []
+
+foreach protobuf : protobuf_src
+ protobufs += custom_target(protobuf,
+ command : [
+ protoc,
+ '--c_out=@OUTDIR@',
+ '--proto_path=@CURRENT_SOURCE_DIR@',
+ '--dependency_out=@DEPFILE@',
+ '@INPUT@'],
+ input : protobuf + '.proto',
+ output : ['@BASENAME@.pb-c.c', '@BASENAME@.pb-c.h'],
+ depfile : '@BASENAME@.pb-c.d')
+endforeach
diff --git a/qmi/meson.build b/qmi/meson.build
new file mode 100644
index 0000000..ece4cad
--- /dev/null
+++ b/qmi/meson.build
@@ -0,0 +1,28 @@
+#
+# QMI Build system
+#
+# Copyright (C) 2023 Richard Acayan
+#
+# This file is part of sensh.
+#
+# Sensh is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+qmic = find_program('qmic')
+wrapper = files('qmic_wrapper.sh')
+
+qmi = custom_target('qmi_sns_client',
+ command : [wrapper, qmic, '@INPUT@', '@OUTDIR@'],
+ input : 'sns_client.qmi',
+ output : ['qmi_sns_client.c', 'qmi_sns_client.h'])
diff --git a/qmi/qmic_wrapper.sh b/qmi/qmic_wrapper.sh
new file mode 100755
index 0000000..9b5db85
--- /dev/null
+++ b/qmi/qmic_wrapper.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+#
+# QMI interface compiler wrapper
+#
+# Copyright (C) 2023 Richard Acayan
+#
+# This file is part of sensh.
+#
+# Sensh is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+qmic="$1"
+
+#
+# Usage: qmic_wrapper.sh QMIC INPUT OUTPUT_DIRECTORY
+#
+# Example: qmic_wrapper.sh /usr/bin/qmic ../qmi/sns_client.qmi qmi/
+#
+
+#
+# We need to move into the output directory so QMIC puts the files in the
+# correct place, but the path to the input might be relative to the directory
+# we are already in. Open the file now and pipe it to stdin so the pathname
+# gets processed relative to the correct directory.
+#
+exec < "$2"
+
+cd "$3"
+exec "$qmic" -k