[gupnp] build: Switch to meson



commit 0e5810ca2d9ab20923809a9057f76e9b59215428
Author: Jens Georg <mail jensge org>
Date:   Thu Nov 1 19:13:30 2018 +0100

    build: Switch to meson

 Makefile.am                           |  13 ---
 autogen.sh                            |  38 -------
 configure.ac                          | 184 -------------------------------
 doc/Makefile.am                       | 118 --------------------
 doc/meson.build                       |  27 +++++
 examples/Makefile.am                  |  15 ---
 examples/meson.build                  |  12 ++
 gupnp-1.2-uninstalled.pc.in           |  11 --
 gupnp-1.2.pc.in                       |  11 --
 libgupnp/Makefile.am                  | 201 ----------------------------------
 libgupnp/gupnp-enums.c.template       |  33 ++++++
 libgupnp/gupnp-enums.h.template       |  26 +++++
 libgupnp/meson.build                  | 128 ++++++++++++++++++++++
 m4/ax_append_compile_flags.m4         |  67 ------------
 m4/ax_append_flag.m4                  |  71 ------------
 m4/ax_append_link_flags.m4            |  65 -----------
 m4/ax_check_compile_flag.m4           |  74 -------------
 m4/ax_check_enable_debug.m4           | 124 ---------------------
 m4/ax_check_link_flag.m4              |  74 -------------
 m4/ax_compiler_flags.m4               | 158 --------------------------
 m4/ax_compiler_flags_cflags.m4        | 133 ----------------------
 m4/ax_compiler_flags_gir.m4           |  60 ----------
 m4/ax_compiler_flags_ldflags.m4       |  75 -------------
 m4/ax_is_release.m4                   |  69 ------------
 m4/ax_require_defined.m4              |  37 -------
 m4/guul.m4                            |  54 ---------
 m4/introspection.m4                   |  94 ----------------
 m4/vapigen.m4                         |  43 --------
 meson.build                           |  55 ++++++++++
 meson_options.txt                     |   5 +
 {libgupnp => subprojects/guul}/guul.c |   0
 {libgupnp => subprojects/guul}/guul.h |   4 -
 subprojects/guul/meson.build          |  33 ++++++
 tests/Makefile.am                     |  43 --------
 tests/gtest/Makefile.am               |  19 ----
 tests/gtest/meson.build               |  12 ++
 tests/meson.build                     |   9 ++
 tools/Makefile.am                     |   1 -
 tools/meson.build                     |   1 +
 vala/GUPnP-1.2.metadata               |   1 -
 vala/Makefile.am                      |  21 ----
 vala/meson.build                      |   5 +
 42 files changed, 346 insertions(+), 1878 deletions(-)
---
diff --git a/doc/meson.build b/doc/meson.build
new file mode 100644
index 0000000..cfaec18
--- /dev/null
+++ b/doc/meson.build
@@ -0,0 +1,27 @@
+entities = configuration_data()
+entities.set('VERSION', meson.project_version())
+configure_file(input: 'version.xml.in',
+               output: 'version.xml', configuration:
+               entities)
+
+gnome.gtkdoc('gupnp',
+             main_xml : 'gupnp-docs.xml',
+             src_dir : [join_paths(meson.source_root(), 'libgupnp'),
+                        join_paths(meson.build_root(), 'libgupnp')],
+             dependencies : libgupnp,
+             ignore_headers : [
+                 'gena-protocol.h',
+                 'xml-util.h',
+                 'gvalue-util.h',
+                 'http-headers.h',
+                 'gupnp-context-private.h',
+                 'gupnp-linux-context-manager.h',
+                 'gupnp-network-manager.h',
+                 'gupnp-unix-context-manager.h',
+                 'gupnp-device-info-private.h',
+                 'gupnp-error-private.h',
+                 'gupnp-resource-factory-private.h',
+                 'gupnp-service-introspection-private.h',
+                 'gupnp-types-private.h'
+             ],
+             install : true)
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..dccd47b
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,12 @@
+executable(
+    'light-server',
+    'light-server.c',
+     export_dynamic : true,
+     dependencies : gupnp
+)
+
+executable(
+    'light-client',
+    'light-client.c',
+    dependencies : gupnp
+)
diff --git a/libgupnp/gupnp-enums.c.template b/libgupnp/gupnp-enums.c.template
new file mode 100644
index 0000000..3ce5fa4
--- /dev/null
+++ b/libgupnp/gupnp-enums.c.template
@@ -0,0 +1,33 @@
+/*** BEGIN file-header ***/
+#include "gupnp-enums.h"
+
+/*** END file-header ***/
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+#include "@filename@"
+/*** END file-production ***/
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+    static GType type = 0;
+
+
+    if (!type)
+    {
+        static const G@Type@Value _@enum_name@_values[] = {
+/*** END value-header ***/
+/*** BEGIN value-production ***/
+            { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+/*** BEGIN value-tail ***/
+            { 0, NULL, NULL }
+        };
+
+        type = g_@type@_register_static ("@EnumName@", _@enum_name@_values);
+    }
+
+
+  return type;
+}
+/*** END value-tail ***/
diff --git a/libgupnp/gupnp-enums.h.template b/libgupnp/gupnp-enums.h.template
new file mode 100644
index 0000000..e88ffab
--- /dev/null
+++ b/libgupnp/gupnp-enums.h.template
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+#ifndef GUPNP_ENUMS_H
+#define GUPNP_ENUMS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from @basename@ */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void);
+#define GUPNP_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* GUPNP_ENUMS_H */
+/*** END file-tail ***/
diff --git a/libgupnp/meson.build b/libgupnp/meson.build
new file mode 100644
index 0000000..b86771a
--- /dev/null
+++ b/libgupnp/meson.build
@@ -0,0 +1,128 @@
+context_manager_impl = []
+context_manager_args = []
+
+if host_machine.system() == 'windows'
+    context_manager_impl += 'gupnp-windows-context-manager.c'
+else
+    if ifaddrs_available
+        context_manager_impl += 'gupnp-unix-context-manager.c'
+    endif
+    if get_option('context_manager') == 'network-manager'
+        context_manager_impl += 'gupnp-network-manager.c'
+        context_manager_args += '-DUSE_NETWORK_MANAGER'
+    endif
+    if get_option('context_manager') == 'connman'
+        context_manager_impl += 'gupnp-connman-manager.c'
+        context_manager_args += '-DUSE_CONNMAN'
+    endif
+endif
+
+if netlink_available
+    context_manager_impl += 'gupnp-linux-context-manager.c'
+endif
+
+if get_option('context_manager') == 'linux'
+    context_manager_args += '-DUSE_NETLINK'
+endif
+
+enums = gnome.mkenums(
+    'gupnp-enums',
+    sources : [
+        'gupnp-error.h',
+        'gupnp-service-introspection.h'
+    ],
+    identifier_prefix : 'GUPnP',
+    symbol_prefix : 'gupnp',
+    c_template : 'gupnp-enums.c.template',
+    h_template : 'gupnp-enums.h.template',
+    install_header : true,
+    install_dir : join_paths (get_option('includedir'), 'gupnp-1.2/libgupnp')
+)
+
+headers = files(
+    'gupnp-acl.h',
+    'gupnp-context.h',
+    'gupnp-context-manager.h',
+    'gupnp-control-point.h',
+    'gupnp-device.h',
+    'gupnp-device-info.h',
+    'gupnp-device-proxy.h',
+    'gupnp-error.h',
+    'gupnp.h',
+    'gupnp-resource-factory.h',
+    'gupnp-root-device.h',
+    'gupnp-service.h',
+    'gupnp-service-info.h',
+    'gupnp-service-introspection.h',
+    'gupnp-service-proxy.h',
+    'gupnp-types.h',
+    'gupnp-uuid.h',
+    'gupnp-white-list.h',
+    'gupnp-xml-doc.h'
+)
+install_headers(headers, subdir : 'gupnp-1.2/libgupnp')
+
+sources = files(
+    'gupnp-acl.c',
+    'gupnp-context.c',
+    'gupnp-context-manager.c',
+    'gupnp-control-point.c',
+    'gupnp-device.c',
+    'gupnp-device-info.c',
+    'gupnp-device-proxy.c',
+    'gupnp-error.c',
+    'gupnp-resource-factory.c',
+    'gupnp-root-device.c',
+    'gupnp-service.c',
+    'gupnp-service-info.c',
+    'gupnp-service-introspection.c',
+    'gupnp-service-proxy.c',
+    'gupnp-simple-context-manager.c',
+    'gupnp-types.c',
+    'gupnp-white-list.c',
+    'gupnp-xml-doc.c',
+    'gvalue-util.c',
+    'http-headers.c',
+    'xml-util.c'
+)
+
+libgupnp = library(
+    'gupnp-1.2',
+    sources + context_manager_impl + enums,
+    version : '0.0.0',
+    dependencies : dependencies,
+    c_args : context_manager_args,
+    include_directories: include_directories('..'),
+    install: true
+)
+
+gupnp = declare_dependency(
+    link_with: libgupnp,
+    include_directories : include_directories('..'),
+    dependencies : dependencies
+)
+
+pkg.generate(
+    libraries : libgupnp,
+    subdirs: 'gupnp-1.2',
+    name : 'gupnp-1.2',
+    description : 'GObject-based UPnP library',
+    version : meson.project_version(),
+    filebase : 'gupnp-1.2'
+)
+
+if get_option('introspection')
+    gir = gnome.generate_gir(
+        libgupnp,
+        sources : headers + sources + enums,
+        namespace : 'GUPnP',
+        nsversion : '1.2',
+        header : 'libgupnp/gupnp.h',
+        symbol_prefix : 'gupnp',
+        identifier_prefix : 'GUPnP',
+        export_packages : 'gupnp-1.2',
+        includes : ['GObject-2.0', 'Gio-2.0', 'Soup-2.4', 'GSSDP-1.2', 'libxml2-2.0'],
+        install : true,
+        extra_args : '-DGOBJECT_INTROSPECTION_SKIP'
+    )
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..e948cb0
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,55 @@
+project('gupnp', 'c', version : '1.1.0')
+gnome = import('gnome')
+pkg = import('pkgconfig')
+
+cc = meson.get_compiler('c')
+
+conf = configuration_data()
+conf.set_quoted('VERSION', meson.project_version())
+
+netlink_test = '''#include <sys/socket.h>
+#include <linux/rtnetlink.h>
+'''
+netlink_available = cc.compiles(netlink_test, name : 'linux/rtnetlink.h availability')
+conf.set('HAVE_NETLINK', netlink_available)
+
+ifaddrs_test = '#include <ifaddrs.h>'
+ifaddrs_available = cc.compiles(ifaddrs_test, name : 'ifaddrs.h availability')
+conf.set('HAVE_IFADDRS_H', ifaddrs_available)
+
+wireless_test ='''#include <sys/socket.h>
+#include <linux/wireless.h>
+'''
+conf.set('HAVE_LINUX_WIRELESS_H',
+         cc.compiles(wireless_test, name : 'linux/wireless.h availability'))
+
+config_h = configure_file(output : 'config.h', configuration : conf)
+add_global_arguments('-DHAVE_CONFIG_H=1', language : 'c')
+
+guul = subproject('guul', default_options : ['default_library=static'])
+
+dependencies = [
+    dependency('glib-2.0', version : '>= 2.40'),
+    dependency('gio-2.0', version : '>= 2.40'),
+    dependency('gmodule-2.0', version : '>= 2.40'),
+    dependency('gssdp-1.2', version : '>= 1.1'),
+    dependency('libsoup-2.4', version : '>= 2.48.0'),
+    dependency('libxml-2.0'),
+    guul.get_variable('guul')
+]
+
+subdir('libgupnp')
+subdir('tests')
+subdir('tools')
+
+if get_option('vapi') and get_option('introspection')
+    subdir('vala')
+endif
+
+if get_option('gtk_doc')
+    subdir('doc')
+endif
+
+if get_option('examples')
+    subdir('examples')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..3fa5392
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,5 @@
+option('context_manager', type : 'combo', choices : ['linux', 'network-manager', 'connman', 'system'], value 
: 'system', description: 'Which context manager to use for detecting network interfaces')
+option('introspection', type : 'boolean', value : 'true', description : 'Enable / disable the 
GObject-Introspection integration')
+option('vapi', type : 'boolean', value : 'true', description : ' Enable / disable VALA API file generation 
(needs -Dintrospection=true)')
+option('gtk_doc', type : 'boolean', value : 'false', description : 'Enable generation of the API 
documentation (needs GTK-Doc)')
+option('examples', type : 'boolean', value : 'true', description : 'Enable / disable building the examples')
diff --git a/libgupnp/guul.c b/subprojects/guul/guul.c
similarity index 100%
rename from libgupnp/guul.c
rename to subprojects/guul/guul.c
diff --git a/libgupnp/guul.h b/subprojects/guul/guul.h
similarity index 95%
rename from libgupnp/guul.h
rename to subprojects/guul/guul.h
index be0dde9..b96bab1 100644
--- a/libgupnp/guul.h
+++ b/subprojects/guul/guul.h
@@ -20,10 +20,6 @@
 #ifndef __GUUL_H
 #define __GUUL_H
 
-#ifdef HAVE_CONFIG_H
-#   include <config.h>
-#endif
-
 #include <glib.h>
 
 G_BEGIN_DECLS
diff --git a/subprojects/guul/meson.build b/subprojects/guul/meson.build
new file mode 100644
index 0000000..aea40c4
--- /dev/null
+++ b/subprojects/guul/meson.build
@@ -0,0 +1,33 @@
+project('guul', 'c', version : '0.1')
+
+cc = meson.get_compiler('c')
+dependencies = [
+    dependency('glib-2.0')
+]
+args = []
+
+if host_machine.system() == 'windows'
+    args += '-DGUUL_PLATFORM_WINDOWS'
+    dependencies += cc.find_library('rpcrt4')
+elif host_machine.system() == 'darwin'
+    args += '-DGUUL_PLATFORM_OSX'
+else
+    if not cc.has_function('uuid_to_string')
+        dependencies += dependency('uuid')
+        args += '-DGUUL_PLATFORM_GENERIC'
+    else
+        args += '-DGUUL_PLATFORM_BSD'
+    endif
+endif
+
+guul_lib = static_library(
+    'guul',
+    sources : 'guul.c',
+    c_args : args,
+    dependencies : dependencies
+)
+
+guul = declare_dependency (
+    link_with : guul_lib,
+    include_directories: include_directories('.')
+)
diff --git a/tests/gtest/meson.build b/tests/gtest/meson.build
new file mode 100644
index 0000000..33637d7
--- /dev/null
+++ b/tests/gtest/meson.build
@@ -0,0 +1,12 @@
+foreach program : ['context', 'bugs']
+    test(
+        program,
+        executable(
+            'test-' + program,
+            'test-@0@.c'.format (program),
+            dependencies : gupnp,
+            c_args : '-DDATA_PATH="@0@/data"'.format(meson.current_source_dir())
+        ),
+        is_parallel : false
+    )
+endforeach
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..61b91bc
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,9 @@
+foreach program : ['browsing', 'proxy', 'server', 'introspection', 'white-list']
+    executable(
+        'test-' + program,
+        sources : 'test-@0@.c'.format(program),
+        dependencies : gupnp
+    )
+endforeach
+
+subdir('gtest')
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..5960fba
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1 @@
+install_data('gupnp-binding-tool', install_dir : 'bin')
diff --git a/vala/GUPnP-1.2.metadata b/vala/GUPnP-1.2.metadata
index e3e6af2..4f0aedf 100644
--- a/vala/GUPnP-1.2.metadata
+++ b/vala/GUPnP-1.2.metadata
@@ -1,4 +1,3 @@
-GUPnP cheader_filename="libgupnp/gupnp.h"
 Acl
     .is_allowed skip
     .is_allowed_async skip
diff --git a/vala/meson.build b/vala/meson.build
new file mode 100644
index 0000000..6a9f9df
--- /dev/null
+++ b/vala/meson.build
@@ -0,0 +1,5 @@
+
+gnome.generate_vapi('gupnp-1.2',
+                    sources : [gir.get(0), 'gupnp-1.2-custom.vala'],
+                    packages : ['gio-2.0', 'libsoup-2.4', 'libxml-2.0'],
+                    install : true)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]