diff --git a/meson.build b/meson.build index fffeada..de72a90 100644 --- a/meson.build +++ b/meson.build @@ -47,13 +47,18 @@ eg25_datadir = join_paths(full_datadir, meson.project_name()) add_global_arguments('-D@0@="@1@"'.format('EG25_CONFDIR', eg25_confdir), language : 'c') add_global_arguments('-D@0@="@1@"'.format('EG25_DATADIR', eg25_datadir), language : 'c') +mmglib_dep = dependency('mm-glib', required : false) +if mmglib_dep.found() + add_global_arguments('-DHAVE_MMGLIB=1', language : 'c') +endif + mgr_deps = [ dependency('glib-2.0'), dependency('gio-unix-2.0'), dependency('gudev-1.0'), dependency('libgpiod'), dependency('libusb-1.0'), - dependency('mm-glib'), + mmglib_dep, ] subdir('data') diff --git a/src/at.c b/src/at.c index 32138d0..a34025f 100644 --- a/src/at.c +++ b/src/at.c @@ -77,12 +77,14 @@ static gboolean send_at_command(struct EG25Manager *manager) g_message("Sending command: %s", g_strstrip(command)); } else if (manager->modem_state < EG25_STATE_CONFIGURED) { if (manager->modem_iface == MODEM_IFACE_MODEMMANAGER) { +#ifdef HAVE_MMGLIB MMModemState modem_state = mm_modem_get_state(manager->mm_modem); if (manager->mm_modem && modem_state >= MM_MODEM_STATE_REGISTERED) modem_update_state(manager, modem_state); else manager->modem_state = EG25_STATE_CONFIGURED; +#endif } else { manager->modem_state = EG25_STATE_CONFIGURED; } diff --git a/src/manager.c b/src/manager.c index dd857b6..c0b8a43 100644 --- a/src/manager.c +++ b/src/manager.c @@ -7,7 +7,11 @@ #include "at.h" #include "gpio.h" #include "manager.h" + +#ifdef HAVE_MMGLIB #include "mm-iface.h" +#endif + #include "ofono-iface.h" #include "suspend.h" #include "udev.h" @@ -35,7 +39,9 @@ static gboolean quit_app(struct EG25Manager *manager) g_message("Request to quit..."); at_destroy(manager); +#ifdef HAVE_MMGLIB mm_iface_destroy(manager); +#endif ofono_iface_destroy(manager); suspend_destroy(manager); udev_destroy(manager); @@ -100,6 +106,7 @@ static gboolean modem_start(struct EG25Manager *manager) return FALSE; } +#ifdef HAVE_MMGLIB void modem_update_state(struct EG25Manager *manager, MMModemState state) { switch (state) { @@ -116,6 +123,7 @@ void modem_update_state(struct EG25Manager *manager, MMModemState state) break; } } +#endif void modem_configure(struct EG25Manager *manager) { @@ -328,7 +336,9 @@ int main(int argc, char *argv[]) at_init(&manager, toml_table_in(toml_config, "at")); gpio_init(&manager, toml_table_in(toml_config, "gpio")); +#ifdef HAVE_MMGLIB mm_iface_init(&manager, toml_table_in(toml_config, "mm-iface")); +#endif ofono_iface_init(&manager); suspend_init(&manager, toml_table_in(toml_config, "suspend")); udev_init(&manager, toml_table_in(toml_config, "udev")); diff --git a/src/manager.h b/src/manager.h index d326dc1..30028e6 100644 --- a/src/manager.h +++ b/src/manager.h @@ -9,7 +9,9 @@ #include #include #include +#ifdef HAVE_MMGLIB #include +#endif #include #include "toml.h" @@ -51,9 +53,10 @@ struct EG25Manager { enum ModemIface modem_iface; guint mm_watch; +#ifdef HAVE_MMGLIB MMManager *mm_manager; MMModem *mm_modem; - +#endif guint ofono_watch; GDBOManager *ofono_manager; GDBusConnection *ofono_connection; @@ -80,4 +83,6 @@ void modem_suspend_pre(struct EG25Manager *data); void modem_suspend_post(struct EG25Manager *data); void modem_resume_pre(struct EG25Manager *data); void modem_resume_post(struct EG25Manager *data); +#ifdef HAVE_MMGLIB void modem_update_state(struct EG25Manager *data, MMModemState state); +#endif diff --git a/src/meson.build b/src/meson.build index 6a9f52d..f9eb27f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -7,18 +7,23 @@ subdir('libgdbofono') -executable ( - 'eg25manager', - [ +src = [ 'at.c', 'at.h', 'gpio.c', 'gpio.h', 'manager.c', 'manager.h', - 'mm-iface.c', 'mm-iface.h', 'ofono-iface.c', 'ofono-iface.h', 'suspend.c', 'suspend.h', 'toml.c', 'toml.h', 'udev.c', 'udev.h', - ], +] + +if mmglib_dep.found() + src += ['mm-iface.c', 'mm-iface.h'] +endif + +executable ( + 'eg25manager', + src, dependencies : mgr_deps, link_with: gdbofono_lib, install : true diff --git a/src/suspend.c b/src/suspend.c index b82ca7e..f9bedf9 100644 --- a/src/suspend.c +++ b/src/suspend.c @@ -170,7 +170,11 @@ static void signal_cb(GDBusProxy *proxy, g_message("system is resuming"); take_inhibitor(manager, FALSE); modem_resume_pre(manager); - if (manager->mm_modem || manager->modem_iface == MODEM_IFACE_OFONO) { + if ( +#ifdef HAVE_MMGLIB + manager->mm_modem || +#endif + manager->modem_iface == MODEM_IFACE_OFONO) { /* * On some systems ModemManager doesn't handle suspend/resume, so * we still have a valid/managed modem when resuming. In this case,