summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIñigo Martínez <inigomartinez@gmail.com>2021-04-22 23:57:36 +0200
committerIñigo Martínez <inigomartinez@gmail.com>2021-05-03 22:18:24 +0200
commita4decd1bd2dbcda163e72abbd68894b2b396e969 (patch)
tree1159bbb5435b1a69d9eeb54156a5633eaff5a3b0
parent13883cd5c4d28dbed3c49008430c7dbbae8d5ef0 (diff)
build: port to meson build system
meson is a build system focused on speed an ease of use, which helps speeding up the software development. This patch adds meson support along autotools.
-rw-r--r--docs/man/meson.build18
-rw-r--r--docs/reference/libmbim-glib/meson.build67
-rw-r--r--docs/reference/libmbim-glib/xml/gtkdocentities.ent.in7
-rw-r--r--docs/reference/libmbim-glib/xml/meson.build17
-rw-r--r--meson.build208
-rw-r--r--meson_options.txt6
-rw-r--r--meson_post_install.py14
-rw-r--r--src/common/meson.build17
-rw-r--r--src/common/test/meson.build11
-rw-r--r--src/libmbim-glib/generated/meson.build154
-rw-r--r--src/libmbim-glib/meson.build134
-rw-r--r--src/libmbim-glib/symbol.map6
-rw-r--r--src/libmbim-glib/test/meson.build39
-rw-r--r--src/mbim-proxy/meson.build22
-rw-r--r--src/mbimcli/meson.build38
-rw-r--r--src/meson.build7
-rw-r--r--utils/meson.build9
17 files changed, 774 insertions, 0 deletions
diff --git a/docs/man/meson.build b/docs/man/meson.build
new file mode 100644
index 0000000..a8e0cd7
--- /dev/null
+++ b/docs/man/meson.build
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+mans = [
+ ['mbimcli', [help2man, '--output=@OUTPUT@', '--name=Control MBIM devices', '--help-option="--help-all"', mbimcli], [mbimcli_sources]],
+ ['mbim-network', [help2man, '--output=@OUTPUT@', '--name=Simple network management of MBIM devices', mbim_network], []],
+]
+
+foreach man: mans
+ custom_target(
+ man[0],
+ output: man[0] + '.1',
+ command: man[1],
+ depend_files: man[2],
+ install: true,
+ install_dir: join_paths(mbim_mandir, 'man1'),
+ )
+endforeach
diff --git a/docs/reference/libmbim-glib/meson.build b/docs/reference/libmbim-glib/meson.build
new file mode 100644
index 0000000..ae7ac0c
--- /dev/null
+++ b/docs/reference/libmbim-glib/meson.build
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+subdir('xml')
+
+doc_module = 'libmbim-glib'
+
+src_dirs = [
+ generated_inc,
+ libmbim_glib_inc,
+]
+
+private_headers = [
+ 'mbim-helpers.h',
+ 'mbim-message-private.h',
+ 'mbim-net-port-manager.h',
+]
+
+scan_args = [
+ '--rebuild-types',
+ '--deprecated-guards="MBIM_DISABLE_DEPRECATED"',
+]
+
+glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
+
+fixxref_args = [
+ '--html-dir=' + join_paths(mbim_prefix, gnome.gtkdoc_html_dir(doc_module)),
+ '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('glib')),
+ '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('gio')),
+]
+
+name = doc_module + '-sections.txt'
+
+'''
+FIXME: gen_sections should be used in the `input` field but it would add
+ a dependency over file paths that are not yet created, so
+ the `depends` section is used to generate alternate dependency.
+ This is fixed in newer meson versions.
+'''
+sections_txt = custom_target(
+ name,
+ input: 'libmbim-glib-common.sections',
+ output: name,
+ capture: true,
+ command: [find_program('cat'), '@INPUT@'] + gen_sections,
+ depends: gen_sections_deps,
+)
+
+version_xml = configure_file(
+ input: 'version.xml.in',
+ output: '@BASENAME@',
+ configuration: version_conf,
+)
+
+gnome.gtkdoc(
+ doc_module,
+ main_xml: doc_module + '-docs.xml',
+ src_dir: src_dirs,
+ ignore_headers: private_headers,
+ include_directories: top_inc,
+ gobject_typesfile: doc_module + '.types',
+ dependencies: libmbim_glib_dep,
+ namespace: 'mbim',
+ scan_args: scan_args,
+ fixxref_args: fixxref_args,
+ install: true,
+)
diff --git a/docs/reference/libmbim-glib/xml/gtkdocentities.ent.in b/docs/reference/libmbim-glib/xml/gtkdocentities.ent.in
new file mode 100644
index 0000000..fd86c16
--- /dev/null
+++ b/docs/reference/libmbim-glib/xml/gtkdocentities.ent.in
@@ -0,0 +1,7 @@
+<!ENTITY package "@PACKAGE@">
+<!ENTITY package_bugreport "@PACKAGE_BUGREPORT@">
+<!ENTITY package_name "@PACKAGE_NAME@">
+<!ENTITY package_string "@PACKAGE_STRING@">
+<!ENTITY package_tarname "@PACKAGE_TARNAME@">
+<!ENTITY package_url "@PACKAGE_URL@">
+<!ENTITY package_version "@PACKAGE_VERSION@">
diff --git a/docs/reference/libmbim-glib/xml/meson.build b/docs/reference/libmbim-glib/xml/meson.build
new file mode 100644
index 0000000..990213c
--- /dev/null
+++ b/docs/reference/libmbim-glib/xml/meson.build
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+ent_conf = configuration_data()
+ent_conf.set('PACKAGE', meson.project_name())
+ent_conf.set('PACKAGE_BUGREPORT', meson.project_name() + '-devel@lists.freedesktop.org')
+ent_conf.set('PACKAGE_NAME', meson.project_name())
+ent_conf.set('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), mbim_version))
+ent_conf.set('PACKAGE_TARNAME', meson.project_name())
+ent_conf.set('PACKAGE_URL', '')
+ent_conf.set('PACKAGE_VERSION', mbim_version)
+
+gtkdocentities_ent = configure_file(
+ input: 'gtkdocentities.ent.in',
+ output: '@BASENAME@',
+ configuration: ent_conf,
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..9b8addb
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,208 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+project(
+ 'libmbim', 'c',
+ version: '1.25.3',
+ license: 'GPL2',
+ default_options: [
+ 'buildtype=debugoptimized',
+ 'c_std=gnu89',
+ 'warning_level=2',
+ ],
+ meson_version: '>= 0.45.1',
+)
+
+mbim_version = meson.project_version()
+version_array = mbim_version.split('.')
+mbim_major_version = version_array[0].to_int()
+mbim_minor_version = version_array[1].to_int()
+mbim_micro_version = version_array[2].to_int()
+
+mbim_prefix = get_option('prefix')
+mbim_bindir = get_option('bindir')
+mbim_includedir = get_option('includedir')
+mbim_libexecdir = get_option('libexecdir')
+mbim_mandir = get_option('mandir')
+
+mbim_glib_include_subdir = meson.project_name() + '-glib'
+mbim_glib_pkgincludedir = join_paths(mbim_includedir, mbim_glib_include_subdir)
+
+# libtool versioning for libmbim-glib (-version-info c:r:a)
+# - If the interface is unchanged, but the implementation has changed or been fixed, then increment r
+# - Otherwise, increment c and zero r.
+# - If the interface has grown (that is, the new library is compatible with old code), increment a.
+# - If the interface has changed in an incompatible way (that is, functions have changed or been removed), then zero a.
+current = 9
+revision = 0
+age = 5
+mbim_glib_version = '@0@.@1@.@2@'.format(current - age, age, revision)
+
+mbim_gir_version = '1.0'
+
+gnome = import('gnome')
+i18n = import('i18n')
+pkg = import('pkgconfig')
+python = import('python3').find_python()
+
+source_root = meson.current_source_dir()
+
+data_dir = join_paths(source_root, 'data')
+templates_dir = join_paths(source_root, 'build-aux/templates')
+
+mbim_codegen = find_program(join_paths(source_root, 'build-aux/mbim-codegen/mbim-codegen'))
+mbim_mkenums = find_program(join_paths(source_root, 'build-aux/mbim-mkenums'))
+
+top_inc = include_directories('.')
+
+cc = meson.get_compiler('c')
+
+config_h = configuration_data()
+config_h.set_quoted('PACKAGE_VERSION', mbim_version)
+
+# compiler flags
+common_flags = ['-DHAVE_CONFIG_H']
+
+# compiler flags that are always enabled, even in release builds
+cc_flags = cc.get_supported_arguments([
+ # warning on unused parameters is overkill, never do that
+ '-Wno-unused-parameter',
+ # function type cast disabled: used throughout the code especially to
+ # cast GAsyncReadyCallbacks with the real object type instead of GObject
+ '-Wno-cast-function-type',
+ # all message protocol structs are packed, never complain about it
+ '-Wno-packed',
+])
+
+# strict flags to use in debug builds
+if get_option('buildtype').contains('debug')
+ cc_flags += cc.get_supported_arguments([
+ '-fno-strict-aliasing',
+ '-Waggregate-return',
+ '-Wcast-align',
+ '-Wdeclaration-after-statement',
+ '-Wdouble-promotion',
+ '-Wduplicated-branches',
+ '-Wduplicated-cond',
+ '-Wfloat-equal',
+ '-Wformat=2',
+ '-Wformat-nonliteral',
+ '-Wformat-security',
+ '-Winit-self',
+ '-Winline',
+ '-Wjump-misses-init',
+ '-Wlogical-op',
+ '-Wnested-externs',
+ '-Wmissing-declarations',
+ '-Wmissing-format-attribute',
+ '-Wmissing-include-dirs',
+ '-Wmissing-noreturn',
+ '-Wmissing-prototypes',
+ '-Wnull-dereference',
+ '-Wpointer-arith',
+ '-Wredundant-decls',
+ '-Wrestrict',
+ '-Wreturn-type',
+ '-Wshadow',
+ '-Wstrict-prototypes',
+ '-Wsuggest-attribute=format',
+ '-Wswitch-default',
+ '-Wswitch-enum',
+ '-Wundef',
+ '-Wunused-but-set-variable',
+ '-Wwrite-strings',
+ ])
+endif
+
+add_project_arguments(common_flags + cc_flags, language: 'c')
+
+glib_version = '2.56'
+
+glib_dep = dependency('glib-2.0', version: '>= ' + glib_version)
+gio_unix_dep = dependency('gio-unix-2.0')
+
+deps = [
+ glib_dep,
+ dependency('gio-2.0'),
+ dependency('gobject-2.0'),
+]
+
+c_flags = [
+ '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_' + glib_version.underscorify(),
+ '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_' + glib_version.underscorify(),
+ '-DGLIB_DISABLE_DEPRECATION_WARNINGS',
+]
+
+glib_deps = declare_dependency(
+ dependencies: deps,
+ compile_args: c_flags,
+)
+
+bash_completion_completionsdir = dependency('bash-completion').get_pkgconfig_variable('completionsdir', define_variable: ['prefix', mbim_prefix])
+
+glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
+
+# MBIM username
+mbim_username = get_option('mbim_username')
+enable_mbim_username = (mbim_username != '')
+if enable_mbim_username
+ config_h.set_quoted('MBIM_USERNAME', mbim_username)
+
+ # FIXME: udev base directory, prefix can't be overrided
+ udev_udevdir = get_option('udevdir')
+ if udev_udevdir == ''
+ udev_udevdir = dependency('udev').get_variable(pkgconfig: 'udevdir')
+ endif
+else
+ mbim_username = 'no (root)'
+endif
+config_h.set('MBIM_USERNAME_ENABLED', enable_mbim_username)
+
+# introspection support
+enable_gir = get_option('introspection')
+if enable_gir
+ dependency('gobject-introspection-1.0', version: '>= 0.9.6')
+endif
+
+version_conf = configuration_data()
+version_conf.set('MBIM_MAJOR_VERSION', mbim_major_version)
+version_conf.set('MBIM_MINOR_VERSION', mbim_minor_version)
+version_conf.set('MBIM_MICRO_VERSION', mbim_micro_version)
+version_conf.set('VERSION', mbim_version)
+
+subdir('src')
+subdir('utils')
+
+enable_gtk_doc = get_option('gtk_doc')
+if enable_gtk_doc
+ subdir('docs/reference/libmbim-glib')
+endif
+
+help2man = find_program('help2man', required: false)
+if help2man.found()
+ subdir('docs/man')
+endif
+
+configure_file(
+ output: 'config.h',
+ configuration: config_h,
+)
+
+meson.add_install_script(
+ 'meson_post_install.py',
+ get_option('bindir'),
+ bash_completion_completionsdir,
+)
+
+output = '\n' + meson.project_name() + ' ' + meson.project_version() + '\n\n'
+output += ' Build\n'
+output += ' compiler: ' + cc.get_id() + '\n'
+output += ' cflags: ' + ' '.join(cc_flags) + '\n'
+output += ' Documentation: ' + enable_gtk_doc.to_string() + '\n'
+output += ' gobject introspection: ' + enable_gir.to_string() + '\n\n'
+output += ' System paths\n'
+output += ' prefix: ' + mbim_prefix + '\n'
+output += ' udev base directory: ' + mbim_username + '\n\n'
+output += ' Features\n'
+output += ' MBIM username: ' + mbim_username
+message(output)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..db87a7f
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,6 @@
+option('mbim_username', type: 'string', value: '', description: 'user allowed to access MBIM devices')
+
+option('udevdir', type: 'string', value: '', description: 'where udev base directory is')
+
+option('introspection', type: 'boolean', value: true, description: 'build introspection support')
+option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..fbf40fa
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+
+prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX']
+
+bindir = os.path.join(prefix, sys.argv[1])
+subprocess.check_call(['chmod', '755', os.path.join(bindir, 'mbim-network')])
+
+bash_completion_completionsdir = os.path.join(prefix, sys.argv[2])
+os.rename(os.path.join(bash_completion_completionsdir, 'mbimcli-completion'),
+ os.path.join(bash_completion_completionsdir, 'mbimcli'))
diff --git a/src/common/meson.build b/src/common/meson.build
new file mode 100644
index 0000000..f62b686
--- /dev/null
+++ b/src/common/meson.build
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+libmbim_common = static_library(
+ 'mbim-common',
+ sources: 'mbim-common.c',
+ include_directories: top_inc,
+ dependencies: glib_dep,
+)
+
+libmbim_common_dep = declare_dependency(
+ include_directories: include_directories('.'),
+ dependencies: glib_dep,
+ link_with: libmbim_common,
+)
+
+subdir('test')
diff --git a/src/common/test/meson.build b/src/common/test/meson.build
new file mode 100644
index 0000000..119dfd0
--- /dev/null
+++ b/src/common/test/meson.build
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+test_name = 'test-common'
+
+executable(
+ test_name,
+ sources: test_name + '.c',
+ include_directories: top_inc,
+ dependencies: libmbim_common_dep,
+)
diff --git a/src/libmbim-glib/generated/meson.build b/src/libmbim-glib/generated/meson.build
new file mode 100644
index 0000000..5feb402
--- /dev/null
+++ b/src/libmbim-glib/generated/meson.build
@@ -0,0 +1,154 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+generated_inc = include_directories('.')
+
+gen_sources = []
+gen_headers = []
+gen_sections = []
+gen_sections_deps = []
+
+# Error types
+enum_types = 'mbim-error-types'
+
+gen_headers += custom_target(
+ enum_types + '.h',
+ input: mbim_errors_header,
+ output: enum_types + '.h',
+ command: [
+ python,
+ mbim_mkenums,
+ '--fhead', '#ifndef __LIBMBIM_GLIB_ERROR_TYPES_H__\n#define __LIBMBIM_GLIB_ERROR_TYPES_H__\n#include "mbim-errors.h"\n',
+ '--template', files(join_paths(templates_dir, enum_types + '.h.template')),
+ '--ftail', '#endif /* __LIBMBIM_GLIB_ERROR_TYPES_H__ */\n',
+ '@INPUT@'],
+ capture: true,
+ install: true,
+ install_dir: mbim_glib_pkgincludedir,
+)
+
+gen_sources += custom_target(
+ enum_types + '.c',
+ input: mbim_errors_header,
+ output: enum_types + '.c',
+ command: [
+ python,
+ mbim_mkenums,
+ '--fhead', '#include "mbim-errors.h"\n#include "mbim-error-types.h"\n',
+ '--template', files(join_paths(templates_dir, enum_types + '.c.template')),
+ '@INPUT@'],
+ capture: true,
+)
+
+enum_types = 'mbim-error-quarks'
+
+gen_sources += custom_target(
+ enum_types + '.c',
+ input: mbim_errors_header,
+ output: enum_types + '.c',
+ command: [
+ python,
+ mbim_mkenums,
+ '--fhead', '#include "mbim-errors.h"\n#include "mbim-error-types.h"\n',
+ '--template', files(join_paths(templates_dir, enum_types + '.c.template')),
+ '@INPUT@'],
+ capture: true,
+)
+
+# Enum/Flag types
+enum_types = 'mbim-enum-types'
+
+gen_headers += custom_target(
+ enum_types + '.h',
+ input: mbim_enums_headers,
+ output: enum_types + '.h',
+ command: [
+ python,
+ mbim_mkenums,
+ '--fhead', '#ifndef __LIBMBIM_GLIB_ENUM_TYPES_H__\n#define __LIBMBIM_GLIB_ENUM_TYPES_H__\n#include "mbim-uuid.h"\n#include "mbim-cid.h"\n#include "mbim-message.h"\n#include "mbim-enums.h"\n',
+ '--template', files(join_paths(templates_dir, enum_types + '.h.template')),
+ '--ftail', '#endif /* __LIBMBIM_GLIB_ENUM_TYPES_H__ */\n',
+ '@INPUT@'],
+ capture: true,
+ install: true,
+ install_dir: mbim_glib_pkgincludedir,
+)
+
+gen_sources += custom_target(
+ enum_types + '.c',
+ input: mbim_enums_headers,
+ output: enum_types + '.c',
+ command: [
+ python,
+ mbim_mkenums,
+ '--fhead', '#include "mbim-enum-types.h"\n',
+ '--template', files(join_paths(templates_dir, enum_types + '.c.template')),
+ '@INPUT@'],
+ capture: true,
+)
+
+services_data = [
+ ['atds', true],
+ ['auth', true],
+ ['basic-connect', true],
+ ['dss', true],
+ ['intel-firmware-update', true],
+ ['ms-basic-connect-extensions', true],
+ ['ms-firmware-id', true],
+ ['ms-host-shutdown', true],
+ ['ms-sar', true],
+ ['phonebook', true],
+ ['proxy-control', false],
+ ['qdu', true],
+ ['qmi', true],
+ ['sms', true],
+ ['stk', true],
+ ['ussd', true],
+]
+
+foreach service_data: services_data
+ service = service_data[0]
+ name = 'mbim-' + service
+
+ generated = custom_target(
+ name,
+ input: join_paths(data_dir, 'mbim-service-@0@.json'.format(service)),
+ output: [name + '.c', name + '.h', name + '.sections'],
+ command: [mbim_codegen, '--input', '@INPUT@', '--output', join_paths('@OUTDIR@', name)],
+ install: true,
+ install_dir: [false, mbim_glib_pkgincludedir, false],
+ )
+
+ gen_sources += generated[0]
+ gen_headers += generated[1]
+
+ if service_data[1]
+ # FIXME: the third target generated by custom target can't by used because is not a known
+ # source file, to the path has to be used. the first workaround is to use the
+ # build paths to point to the files, and the second workaround is to use
+ # custom target objects to force its building.
+ gen_sections += [join_paths(meson.current_build_dir(), name + '.sections')]
+ gen_sections_deps += [generated]
+ endif
+endforeach
+
+c_flags = [
+ '-DLIBMBIM_GLIB_COMPILATION',
+ '-DG_LOG_DOMAIN="Mbim"',
+ '-Wno-unused-function',
+]
+
+libmbim_glib_generated = static_library(
+ 'mbim-glib-generated',
+ sources: gen_sources + gen_headers,
+ include_directories: libmbim_glib_inc,
+ dependencies: glib_deps,
+ c_args: c_flags,
+)
+
+libmbim_glib_generated_dep = declare_dependency(
+ sources: gen_headers,
+ include_directories: [libmbim_glib_inc, generated_inc],
+ dependencies: glib_deps,
+ link_with: libmbim_glib_generated,
+)
diff --git a/src/libmbim-glib/meson.build b/src/libmbim-glib/meson.build
new file mode 100644
index 0000000..2db5db8
--- /dev/null
+++ b/src/libmbim-glib/meson.build
@@ -0,0 +1,134 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+libmbim_glib_inc = include_directories('.')
+
+mbim_errors_header = files('mbim-errors.h')
+
+mbim_enums_headers = files(
+ 'mbim-cid.h',
+ 'mbim-enums.h',
+ 'mbim-message.h',
+ 'mbim-uuid.h',
+)
+
+subdir('generated')
+
+headers = mbim_errors_header + mbim_enums_headers + files(
+ 'libmbim-glib.h',
+ 'mbim-compat.h',
+ 'mbim-device.h',
+ 'mbim-proxy.h',
+ 'mbim-utils.h',
+)
+
+install_headers(
+ headers,
+ subdir: mbim_glib_include_subdir,
+)
+
+common_c_flags = [
+ '-DLIBMBIM_GLIB_COMPILATION',
+ '-DG_LOG_DOMAIN="Mbim"',
+ '-DLIBEXEC_PATH="@0@"'.format(join_paths(mbim_prefix, mbim_libexecdir)),
+]
+
+sources = files(
+ 'mbim-cid.c',
+ 'mbim-compat.c',
+ 'mbim-device.c',
+ 'mbim-helpers.c',
+ 'mbim-message.c',
+ 'mbim-net-port-manager.c',
+ 'mbim-proxy.c',
+ 'mbim-proxy-helpers.c',
+ 'mbim-utils.c',
+ 'mbim-uuid.c',
+)
+
+deps = [
+ libmbim_common_dep,
+ libmbim_glib_generated_dep,
+]
+
+libmbim_glib_core = static_library(
+ 'mbim-glib-core',
+ sources: sources,
+ include_directories: top_inc,
+ dependencies: deps + [gio_unix_dep],
+ c_args: common_c_flags,
+)
+
+libmbim_glib_core_dep = declare_dependency(
+ include_directories: libmbim_glib_inc,
+ dependencies: deps,
+ link_with: libmbim_glib_core,
+)
+
+libname = 'mbim-glib'
+
+version_header = configure_file(
+ input: 'mbim-version.h.in',
+ output: '@BASENAME@',
+ configuration: version_conf,
+ install_dir: mbim_glib_pkgincludedir,
+)
+
+symbol_map = join_paths(meson.current_source_dir(), 'symbol.map')
+
+libmbim_glib = shared_library(
+ libname,
+ version: mbim_glib_version,
+ sources: version_header,
+ include_directories: top_inc,
+ link_args: '-Wl,--version-script,' + symbol_map,
+ link_depends: symbol_map,
+ link_whole: libmbim_glib_core,
+ install: true,
+)
+
+libmbim_glib_dep = declare_dependency(
+ sources: [gen_headers, version_header],
+ include_directories: [libmbim_glib_inc, generated_inc],
+ dependencies: glib_deps,
+ link_with: libmbim_glib,
+)
+
+pkg.generate(
+ libraries: libmbim_glib,
+ version: mbim_version,
+ name: libname,
+ description: 'Library to communicate with MBIM-powered modems',
+ subdirs: mbim_glib_include_subdir,
+ # FIXME: produced by the inhability of meson to use internal dependencies
+ requires: ['glib-2.0', 'gobject-2.0', 'gio-2.0'],
+ variables: 'exec_prefix=${prefix}',
+)
+
+# Introspection
+if enable_gir
+ incs = [
+ 'Gio-2.0',
+ 'GLib-2.0',
+ 'GObject-2.0',
+ ]
+
+ ns = 'Mbim'
+
+ libmbim_glib_gir = gnome.generate_gir(
+ libmbim_glib,
+ sources: headers + [version_header] + gen_sources + gen_headers,
+ includes: incs,
+ dependencies: libmbim_glib_dep,
+ namespace: ns,
+ nsversion: mbim_gir_version,
+ identifier_prefix: ns,
+ symbol_prefix: ns.to_lower() + '_',
+ extra_args: common_c_flags + ['--identifier-prefix=' + ns.to_upper()],
+ header: 'libmbim-glib.h',
+ export_packages: 'libmbim-glib',
+ install: true,
+ )
+endif
+
+subdir('test')
diff --git a/src/libmbim-glib/symbol.map b/src/libmbim-glib/symbol.map
new file mode 100644
index 0000000..2a578e7
--- /dev/null
+++ b/src/libmbim-glib/symbol.map
@@ -0,0 +1,6 @@
+{
+global:
+ mbim_*;
+local:
+ *;
+};
diff --git a/src/libmbim-glib/test/meson.build b/src/libmbim-glib/test/meson.build
new file mode 100644
index 0000000..c3159da
--- /dev/null
+++ b/src/libmbim-glib/test/meson.build
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+test_units = [
+ 'uuid',
+ 'cid',
+ 'message',
+ 'fragment',
+ 'message-parser',
+ 'message-builder',
+ 'proxy-helpers',
+]
+
+random_number = mbim_minor_version + meson.version().split('.').get(1).to_int()
+
+test_env = environment()
+test_env.set('G_DEBUG', 'gc-friendly')
+test_env.set('MALLOC_CHECK_', '2')
+test_env.set('MALLOC_PERTURB_', (random_number % 256).to_string())
+test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
+test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+
+foreach test_unit: test_units
+ test_name = 'test-' + test_unit
+
+ exe = executable(
+ test_name,
+ sources: test_name + '.c',
+ include_directories: top_inc,
+ dependencies: libmbim_glib_core_dep,
+ c_args: '-DLIBMBIM_GLIB_COMPILATION',
+ )
+
+ test(
+ test_unit[0],
+ exe,
+ env: test_env,
+ )
+endforeach
diff --git a/src/mbim-proxy/meson.build b/src/mbim-proxy/meson.build
new file mode 100644
index 0000000..d90e236
--- /dev/null
+++ b/src/mbim-proxy/meson.build
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+name = 'mbim-proxy'
+
+executable(
+ name,
+ sources: name + '.c',
+ include_directories: top_inc,
+ dependencies: libmbim_glib_dep,
+ install: true,
+ install_dir: mbim_libexecdir,
+)
+
+if enable_mbim_username
+ configure_file(
+ input: '76-mbim-proxy-device-ownership.rules.in',
+ output: '@BASENAME@',
+ configuration: config_h,
+ install_dir: join_paths(udev_udevdir, 'rules.d'),
+ )
+endif
diff --git a/src/mbimcli/meson.build b/src/mbimcli/meson.build
new file mode 100644
index 0000000..fae60b8
--- /dev/null
+++ b/src/mbimcli/meson.build
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+mbimcli_sources = files(
+ 'mbimcli-atds.c',
+ 'mbimcli-basic-connect.c',
+ 'mbimcli.c',
+ 'mbimcli-dss.c',
+ 'mbimcli-intel-firmware-update.c',
+ 'mbimcli-ms-basic-connect-extensions.c',
+ 'mbimcli-ms-firmware-id.c',
+ 'mbimcli-ms-host-shutdown.c',
+ 'mbimcli-ms-sar.c',
+ 'mbimcli-phonebook.c',
+)
+
+sources = mbimcli_sources + files(
+ 'mbimcli-helpers.c',
+ 'mbimcli-link-management.c',
+)
+
+deps = [
+ libmbim_common_dep,
+ libmbim_glib_dep,
+]
+
+mbimcli = executable(
+ 'mbimcli',
+ sources: sources,
+ include_directories: top_inc,
+ dependencies: deps,
+ install: true,
+)
+
+install_data(
+ 'mbimcli-completion',
+ install_dir: bash_completion_completionsdir,
+)
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..ef06f0b
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+subdir('common')
+subdir('libmbim-glib')
+subdir('mbimcli')
+subdir('mbim-proxy')
diff --git a/utils/meson.build b/utils/meson.build
new file mode 100644
index 0000000..f4fffaa
--- /dev/null
+++ b/utils/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2
+# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
+
+mbim_network = configure_file(
+ input: 'mbim-network.in',
+ output: '@BASENAME@',
+ configuration: version_conf,
+ install_dir: mbim_bindir,
+)